2

I'm using PHP to send a text in a script but it won't send! It sends emails fine but it won't send to texts.....

My code:

mail('##########@txt.att.net', '', 'This is a test.');
A Clockwork Orange
  • 23,913
  • 7
  • 25
  • 28

4 Answers4

0

You need to send the appropriate headers (param 4 or use PEAR MAIL) for the respective SMS gateways.

At the very least...

'From','To','Subject','Reply-To','MIME-Version', & 'Content-type'

... and depending upon the carrier, possibly:

'charset','Content-Transfer-Encoding, & 'Content-Disposition'

Ensure the "Date" header is being properly configured & added by your system, and use SMTP authentication.

We recently had trouble with Verizon (vtext.com) not delivering texts OR bouncing them back to us. Turns out the headers made the message TOO long for their gateway, and I could only text Verizon employees by removing those last three. :-/

Using the carriers' free E-mail->SMS gateways is not a good business solution. Very hit-or-miss. :-/

0

You are missing the header parameter in your line of code.

Current: mail('##########@txt.att.net', '', 'This is a test.');

Should be: mail('##########@txt.att.net', '', 'This is a test.', $header);

Where $header is the actual header information.

Ex: $headers = "From: [email protected]";

Hope this helps. -Dan

0

Most email-to-text gateways are very strict about what they will accept. Assuming that you have the correct address, are not blocked, and don't have an open relay, there are some other things you need to check.

  • Include a valid subject line
  • Make sure your From: envelope header is set to a valid address, and not the default on your server

See this question for setting From: properly: https://stackoverflow.com/a/2014104/362536

Community
  • 1
  • 1
Brad
  • 159,648
  • 54
  • 349
  • 530
0

From my experience most telco providers use a service like senderbase to check if the mail is coming from an open relay, reputation, spf records and more. Try using the PEAR mail package and authenticate through an smtp server for sending. I use it successfully for all major telcos. The php mail function will not work, it needs to come from a real address - also make sure you have proper rdns set up.

Jeff Wooden
  • 5,339
  • 2
  • 19
  • 24
  • The PHP mail function definitely *can* work if used properly. I've done it. – Brad Jan 13 '12 at 01:00
  • Edit: my bad the mail function should work if your using a real address, still u need to make sure the other things in my post are happening - i prefer the PEAR package because of flexibility. – Jeff Wooden Jan 13 '12 at 01:07