Last active
May 29, 2022 02:04
-
-
Save pH-7/d8c9e6ff7f92e255d20a to your computer and use it in GitHub Desktop.
Send SMS/Text with PHP http://01script.com/envoyer-des-sms-avec-php/
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$sPhoneNum = '**********'; // Le numéro de téléphone qui recevra l'SMS (avec le préfixe, ex: +33) | |
$aProviders = array('vtext.com', 'tmomail.net', 'txt.att.net', 'mobile.pinger.com', 'page.nextel.com'); | |
foreach ($aProviders as $sProvider) | |
{ | |
if (mail($sPhoneNum . '@' . $sProvider, '', 'Ce texto a été envoyé avec PHP, tout simplement !')) | |
{ | |
// C'est bon, l'SMS a correctement été envoyé avec le fournissuer | |
break; | |
} | |
else | |
{ | |
// L'envoi de l'SMS a échoué avec le fournisseur, nous en essayons un autre dans la liste $aProviders | |
continue; | |
} | |
} | |
?> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* | |
* Fichier texte contenant les numéros de téléphone. Un numéro par ligne, car la séparation de ceux-ci est le "retour à la ligne". | |
*/ | |
$rNumList = file_get_contents('phone_number_list.txt'); | |
$aPhoneNums = explode("\r", $rNumList); // On met tous les numéros dans un tableau | |
foreach ($aPhoneNums as $sPhoneNum) | |
{ | |
sendSMS($sPhoneNum); | |
} | |
function sendSMS($sPhoneNum) | |
{ | |
$aProviders = array('vtext.com', 'tmomail.net', 'txt.att.net', 'mobile.pinger.com', 'page.nextel.com'); | |
foreach ($aProviders as $sProvider) | |
{ | |
if (mail($sPhoneNum . '@' . $sProvider, '', 'Ce texto a été envoyé avec PHP, tout simplement !')) | |
{ | |
// C'est bon, l'SMS a correctement été envoyé avec le fournissuer | |
break; | |
} | |
else | |
{ | |
// L'envoi de l'SMS a échoué avec le fournisseur, nous en essayons un autre dans la liste $aProviders | |
continue; | |
} | |
} | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Très intéressé par la fonction mail de php pour l'envoi gratuit de sms depuis une application web, avez-vous testé ce code, et est-il toujours fonctionnel aujourd'hui, en version 7 de php ?