Hi all,
I am using php to send text messages to cell phones. Just using the mail function to send to the providers' smtp to sms gateway (ie sending email to phonenumber@txt.att.net, etc).
It works fine, except in the phone, where it normally shows the contact id of the person sending the text, it puts a rather larger number (ie. 1420000008). And then at each successive text that the phone receives, it increments that number. I have the same issue when I send the text from gmail and other email systems. Does anyone know a way around this? As, it is pretty ugly and confusing to those who receive the texts. It would be great if were instead to simply show the email address as the contact (or at least a constant number)
Thanks,
-Adam
send text message via php - odd contact id
Moderator: General Moderators
-
adamSpline
- Forum Newbie
- Posts: 11
- Joined: Fri Sep 16, 2011 1:30 pm
Re: send text message via php - odd contact id
Could you show us the script that you are using to send this message and also confirm the service provider you are using to send this message?
Best wishes
Best wishes
Re: send text message via php - odd contact id
I was writing a script for that very thing a few weeks ago and ran into the same situation/problem. The way I solved it was by using the “headers”, specifically the “From:” header. In essence, since the text message is basically an e-mail, I played around with the headers in like manner:
Hope it helps!
Code: Select all
// shows the number; however, I haven't figured out how to successfully reply
"From: 1234567890 <>"
// Shows the the name specified
"From: Yourname <>"
-
adamSpline
- Forum Newbie
- Posts: 11
- Joined: Fri Sep 16, 2011 1:30 pm
Re: send text message via php - odd contact id
Hi,
Thanks for your help. I will soon try what xtiano77 suggested. In the meantime, here is my php code that Iuse to send email. I am just using this to send a text to phonenumber@txt.att.net. The recieving text gets the "from" attribute correct, but it puts a unique caller id (incrementing that id at each tect) to each text that comes in. Note, that the same thing happens if I email the text via gmail, yahoo, etc. So, I do not think this is php specific, I am just wondering if I can do something within php to get rid of that functionality.
Here is the php code I use to send email. I grabbed it sometime back, and it has worked well for sending regular emails.
Thanks for your help. I will soon try what xtiano77 suggested. In the meantime, here is my php code that Iuse to send email. I am just using this to send a text to phonenumber@txt.att.net. The recieving text gets the "from" attribute correct, but it puts a unique caller id (incrementing that id at each tect) to each text that comes in. Note, that the same thing happens if I email the text via gmail, yahoo, etc. So, I do not think this is php specific, I am just wondering if I can do something within php to get rid of that functionality.
Here is the php code I use to send email. I grabbed it sometime back, and it has worked well for sending regular emails.
Code: Select all
// variables set elsewhere
//$to
//$from
//$subject
//$text_content
//$html_content
$headers = "From:" . $from;
$mime_boundary = 'Multipart_Boundary_x' . md5(time()) . 'x';
$headers = "MIME-Version: 1.0\r\n";
$headers .= "Content-Type: multipart/alternative; boundary=\"$mime_boundary\"\r\n";
$headers .= "Content-Transfer-Encoding: 7bit\r\n";
$body = "This is a multi-part message in mime format.\n\n";
$body .= "--$mime_boundary\n";
$body .= "Content-Type: text/plain; charset=\"charset=us-ascii\"\n";
$body .= "Content-Transfer-Encoding: 7bit\n\n";
$body .= $text_content;
$body .= "\n\n";
$body .= "--$mime_boundary\n";
$body .= "Content-Type: text/html; charset=\"UTF-8\"\n";
$body .= "Content-Transfer-Encoding: 7bit\n\n";
$body .= $html_content;
$body .= "\n\n";
$body .= "--$mime_boundary--\n";
$headers .= "From: $from\r\n";
$headers .= "X-Sender-IP: $_SERVER[SERVER_ADDR]\r\n";
$headers .= 'Date: ' . date('n/d/Y g:i A') . "\r\n";
mail($to, $subject, $body, $headers);
Re: send text message via php - odd contact id
If it is doing the same thing no matter what service you use to send the message to the email address, then I can only suggest that it is the service provider that is incrementing this and you should contact them as you already use the FROM header in your script, so this is not really a PHP issue like you say.
If you are using GMAIL and YAHOO and the same thing is happening then contact your service provider for the SMS services and see if it is not an additional service you have to get added such as display unique name or number as the contact it comes from. Some SMS services do not include this as standard.
Best wishes
If you are using GMAIL and YAHOO and the same thing is happening then contact your service provider for the SMS services and see if it is not an additional service you have to get added such as display unique name or number as the contact it comes from. Some SMS services do not include this as standard.
Best wishes
-
adamSpline
- Forum Newbie
- Posts: 11
- Joined: Fri Sep 16, 2011 1:30 pm
Re: send text message via php - odd contact id
phphelpme. I think you are correct. I am contacting the SMS provider to see what the deal is. If I get an answer, I will re-post back here.