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.');
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.');
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. :-/
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: anyverified@emailaddress.com";
Hope this helps. -Dan
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.
From:
envelope header is set to a valid address, and not the default on your serverSee this question for setting From:
properly: https://stackoverflow.com/a/2014104/362536
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.