Sending Mail (text message) from 'Phone Number' in PHP

Posted on 2009-04-28
Last Modified: 2012-06-27
I have setup an ecommerce site for a customer and we set it up to notify them via text-messages to their phone every time a new order is placed or something on the site needs attention.  It works great, however, the from "number" in the text message is always some random 10 digit number.

I'm wondering if there is a way to make this look like it is coming from a specific phone number.
function textMessage($txtnum,$orderNum){


	$from_name	=	'';

	$from_email	=	'8882019987';  // From Phone Number

	$sendto = $txtnum;

	$orderno = $orderNum;

	$headers .= "MIME-Version: 1.0\r\n";

	$headers .= "Content-type: text/html; charset=iso-8859-1\r\n";

	$headers .= "From: ".$from_email."\r\n";

	$headers .= "Reply-To: ".$from_name." <".$from_email.">\r\n";

	$headers .= "X-Mailer: PHP v".phpversion().$eol; 

	$subj = "New Order: $orderNum"; 

	$body = "New Order on the Online Store";		


	mail($sendto, $subj, $body, $headers);


Open in new window

Question by:beigs
    1 Comment
    LVL 4

    Accepted Solution

    Generally the SMS provider has a limited set of numbers that the message can be sent from - you would need to talk to them about the best solution for you.  I very much doubt you'll be able to specify the exact phone number, but they may be able to set you up so the messages are sent from a more friendly number.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    6 Surprising Benefits of Threat Intelligence

    All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

    A colleague recently asked me about how to give his client a small part of the web site that could be completely under the client's control.  Since I have done this sort of thing before to add emergency banners to a web site, I decided I would creat…
    Deprecated and Headed for the Dustbin By now, you have probably heard that some PHP features, while convenient, can also cause PHP security problems.  This article discusses one of those, called register_globals.  It is a thing you do not want.  …
    Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
    The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

    761 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    11 Experts available now in Live!

    Get 1:1 Help Now