Note that there are some explanatory texts on larger screens.

plurals
  1. PODoes anyone want to send text messages from PHP?
    primarykey
    data
    text
    <p>I made a PHP class that dramatically simplifies sending text messages with PHP. I know this isn't really a "help me out!" type question per se, but I would like to share the code because I have found it to be tremendously useful. You're free to do whatever you'd like with the code . You can even go around telling people you made it. Just don't accuse me if anything goes wrong. </p> <p>Without further ado:</p> <pre><code>&lt;?php // Carrier email suffixes define('ATT', 'txt.att.net'); define('SPRINT', 'messaging.sprintpcs.com'); define('TMOBILE', 'tmomail.net'); define('US_CELLULAR', 'email.uscc.net'); define('VERIZON', 'vtext.com'); define('VIRGIN_MOBILE', 'vmobl.com'); // Message parameters define('MAX_SMS_LENGTH', 140); define('DEFAULT_CELL_SENDER', 'sender@example.com'); class Cell { public static function send($pNumber, $pCarrier, $pMessage) { // Keep a notifier of whether the message was sent or not $Success = true; // Define the recipient address $Recipient = $pNumber . '@' . $pCarrier; // Find out how many message will have to be sent $MessageCount = ceil(strlen($pMessage) / MAX_SMS_LENGTH); for ($i = 0; $i &lt; $MessageCount; $i++) { // Calculate the subset of the entire message that can be sent at once $StartIndex = $i * MAX_SMS_LENGTH; $Message = stripslashes(substr($pMessage, $StartIndex, MAX_SMS_LENGTH)); // Display page numbers on messages that span multiple iterations if ($MessageCount &gt; 1) { $Message .= ' (' . ($i + 1) . '/' . $MessageCount . ')'; } // Send the message $Success &amp;= mail($Recipient, null, $Message, 'From: ' . DEFAULT_CELL_SENDER); } return $Success; } } ?&gt; </code></pre> <p>It automatically handles paging across multiple text messages. Also, I know text messages are generally restricted to 160 characters, not 140. I reduced the limit by 20 characters to leave room for the email address. </p> <p>I hope this helps someone out there. Cheers!</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload