A Brief History

I like to call this my instant call back feature. Basically I knew that you can send a text message to your phone through email. So I said to myself, "self, why not send yourself the text message through a web form through some type of sendmail script!". So that is how I came up with this little script several years ago, it has been my little secret ever since. I use it on my Real Estate Web Site program, where I build web sites for real estate agents. Basically I label "Instant Call Back Feature", to imply that as soon as they enter the information, the real estate agent will call them instantly. The user fills out the form and then a text message is sent to the web site owners phone alerting them that they had a web site visitor that wants them to call them. I have only seen a handfull of people on the net think of it as well and implement their own variations, but today I decided to teach you!

Examples of Potential Script Use!

- instant call feature
- alert web site owner of a sale
- send personal messages
- alert web site owner they are out of inventory

How to send text messages to your phone via email

ussually your email for text messaging is your phone number w/areacode (without spaces) @ your provider.com You will have to go to your providers web site and look it up.

Here are some examples I know;

4075551212 {@} messaging.sprintpcs.com (sprint pcs)
4075551212 {@} tmomail.net (T mobile)
4075551212 {@} vtext.com (Verizon)

The Tutorial

We are going to make this as simple as possible. We are going to create 2 pages, these pages are sample.htm and sampleproc.cfm.

There will be 3 sets of code snippets used, they are;

- the form
- javascript validation
- the processing form

sample.htm

here is the code to put in your sample.htm page.

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Sample Page!</title>
<script language="javascript">
<!--
function validateit()
{
temp = true;
 if(document.form.name.value == '' || document.form.phone.value == '')
	{
	temp = false;
	alert('Please fill out the Name and Phone field to continue...');
	}
 return temp;
}
//-->
</script>
</head>
<body>
<p align="center"><strong>INSTANT CALL BACK</strong><br>enter you name and number<br>and I will call you immediately.</p>
            <form name="form" action="sampleproc.cfm" method="post" enctype="multipart/form-data" onSubmit="return validateit();">
			<table width="300" border="0" align="center" cellpadding="2" cellspacing="0">       
			  <tr> 
                <td width="125" valign="middle"> <div align="right">Your Name:&nbsp; </div></td>
                <td width="150" valign="top"><input type="text" name="name" onFocus="this.value=''" style="width:150px"></td>
			    <td width="25" valign="middle"><div align="center">*</div></td>
			  </tr>
              <tr> 
                <td valign="middle"> <div align="right">Phone Number:&nbsp; </div></td>
                <td valign="top"><input type="text" name="phone" onFocus="this.value=''" style="width:150px" ></td>
                <td valign="middle"><div align="center">*</div></td>
              </tr>
              <tr>
                <td valign="top"><div align="right">
                  </div></td>
                <td valign="top"><div align="right">
                  <input type="submit" name="Submit" value="Call Me">
                </div></td>
                <td valign="top">&nbsp;</td>
              </tr>
            </table>
</form>
</body>
</html>

Basically, we have the HTML code for the form as well as an easy javascript fro you to undertand to validate the form before submitting it to the next page.

sampleproc.cfm

This is where we will process the code. Put this in your sampleproc.cfm page.

<CFMAIL To="phonenumber@cellphoneprovider.com" From="you@youremail.com" Subject="Web Alert" server="mail.yourmailserver.com">
call #form.name# at #form.phone#
FROM WEB SITE, Instant Call Back
</CFMAIL>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Confirmation</title>
<script language="javascript" type="text/javascript">
	alert( "I have received your request and will be contacting you shortly" );
	location.href = "sample.htm";
</script>
</head><body></body></html>

Okay Thats it, have fun and remember to "think outside of the box".

Cool idea.
I notice your phone number there is a US one, where you have the state/region code and then phone number.
How would this work in other countries ? would we need to add the country code ( e.g. Uk = +44 so "44") followed by the mobile phone number ?
Does the format follow the common UK practise of add country code and drop the leading 0 on the phone number ?...

These guidlines would be set by your cell phone (mobile) provider.

It should work because it is just like an email address. All emails are unique and if your cell phone provider gave you a unique one, then it will not matter what country can send you a message.

Send your self an email first before you upload this to your site.

Is there anyway that we can send messages to somebody else using this code. FOr example using my phone number in this code but to send the text message to somebody else phone number.

I've also modified the code from my cell phone provider's website. They usually have the form right on there to send a text message... grab the code from there and use your cell phone provider's already-in-place processing.

Is there anyway that we can send messages to somebody else using this code. FOr example using my phone number in this code but to send the text message to somebody else phone number.

Of coarse you can, just put in there telephone number instead of yours. Find out what provider they have and get the email address information. Easy.

cool feature. but i'm problem implementing it, for the part "phonenumber@cellphoneprovider.com", what do i put down for "cellphoneprovider.com"? does it work for any phone provider in the world?

you would put YOUR cell phone provider! Who ever gives you service, you need to find out what the email address of your phone is. So you would go to the website of your service provider and look for this information or read your manaul.

Does anyone know what it is for Cingular service?

hi der!!! its such a kewl idea to do sumthng like dat by coding.......i am not clear on how to use the code.....it wud be great if u cud elaborate stepwise on how to use the code.....thanx a lot....appreciate ur help...
insatiable

Hey, i just figured out wat to do with the code, but halfway thru.....the code which says 'sampleproc.cfm' dint work for me..........wats exactly '.cfm' code???? i really dint understand how the code works......can u plz explain...am curious...thnk u!!!!
........insatiable

is there a way to have a field in the form that will allow a user to type in any mobile# they want? I need for the option of this to enable a user to suubmit a message to any mobile phone. If you could figure this out I could compensate you.

i am making a site and having problem with the script and i want to know what should be in the action field i am using dreamweaver i put smaple.cfm but it poped up and then i put http://9547090928@mymetropcs.com and it still no work i was wonder if i am doin something wrong in posting it i need help with this

I have tried the web pages that you have created, entering the phone number that i wish for the text message to go to and changing email addresses, however when I click on the call me button, it opens up a file download field, asking if i would like to open or save the file. If I click open it opens in Dreamweaver and does not send the message. Can you please help ?
I can attach the code back if you would like to make sure that I didn't do anything wrong.

I have tried the web pages that you have created, entering the phone number that i wish for the text message to go to and changing email addresses, however when I click on the call me button, it opens up a file download field, asking if i would like to open or save the file. If I click open it opens in Dreamweaver and does not send the message. Can you please help ?
I can attach the code back if you would like to make sure that I didn't do anything wrong.

Are you serving the pages from a coldfusion server.
It sounds like you are not hence the file download.

Matt

Hey, i just figured out wat to do with the code, but halfway thru.....the code which says 'sampleproc.cfm' dint work for me..........wats exactly '.cfm' code???? i really dint understand how the code works......can u plz explain...am curious...thnk u!!!!
........insatiable

.cfm is a Coldfusion page, similar to asp, php scripting.

To make this code work the pages need to be served (hosted) on a coldfusion server otherwise this will not work.

Matt

I've also modified the code from my cell phone provider's website. They usually have the form right on there to send a text message... grab the code from there and use your cell phone provider's already-in-place processing.

Hello... Although I came across your thread a tad late, I've been Googling everywhere trying to find others who could help me solve a matter of how to create a SEND-TO-PHONE function on my website. The thing is, I want visitors to input their own 10-digit number in the small form, Click the SEND TO PHONE button...and within seconds, they automatically receive a txtmsg which includes the URL to my mobile website. Any ideas how I can do this in a cost effective manor? I've checked out quite a few sms gateway services that handle this, yet they're a bit to costly for my budget at this point in time.

TextMarks (www.textmarks.com) has a cool app that allows you to create a keyword and use it with their dedicated 5-digit number, so you can do your own "Txt 'keyword' to 12345" promotion campaigns, etc. The catch is, it has to be txted from a mobile phone. I wish I could borrow that code and implement it on my website, so that visitors can also txt their 10-digit number from my site and they get the txtmsg bounced to their phone. Any help with this matter would be greatly appreciated.

Thanks!
Keith Welch

Hi QuantumPHP! :-) Tried responding to you earlier today, yet I think it didn't go through when I hit SEND. First of all, I want to thank You so, so much for leading me towards the right direction with an answer to the mystical "Send a TxtMsg to your phone from your Site"! LOL!!!! Wow!! I downloaded those files and truth be told, it does actually work!! I'm Thrilled!! :-)

Of course...heh-heh... I do have a couple of questions for ya... I'm not a php master by far, yet I noticed the smsphp form has a 'print' command/function which displays whatever text is written in that area, onto a web page (user side)...ok... Well, here's two things that came up... On one hand, I slightly modified the smsphp form and I tried using it within an iFrame on my Site, which looked and worked quite well. The problem is, when you enter a phone number/click send-to-phone, that's when the "Your Txt Was Sent Successfully" msg displays itself within the iFrame... h'mmmm. Sort of looks quite out of place against the color background surrounding the rest of the site. Somehow, I need to have it be a separate web page linked to the form, so that I could have a bit more control over the look of the web page color/font, etc. (hope I'm explaining it correctly). Also, if there's a way to make it work as I explained, then I think a RESET button would help too, if it were situated on that same page.

Secondly... I could make the smsphp form do a pop-up action (target=blank), showing the form in a separate window/web page, yet I'd still appreciate more control over the look of the "Your Txt Was Sent Successfully" web page.

And, lastly..just out of curiousity... how do you create a link within that same {print;} function?? The text reads "Your Text Was Sent Successfully...etc." How can I place a url link within that text? Example: "Click Here To Go back To Home Page" ...??!? How do you code this as a URL within the PHP so that it displays as a LINK on the user side?

Thank you very much for your time on this matter! :-)

Sincerely,
Keith/ZenMartian

There is another great tutorial about sending custom text messages from your website.
It's at

http://www.easykiss123.com/tutorials/sms_simple/index.html

It is set up so you custom text messages can be sent to users after they put in their phone number. Nice!

Quantumphp

**NOTE: This is written AFTER the previous reply I sent to you :-)
Oh yeah... How can I get rid of the "FRM: ...@secureserve" text that shows at the top of an sms? I just want the sms to mainly show my message (which is something short leading up to the URL of my mobile site). When I sent the sms to my phone, the FRM portion does look bothersome, and also adds unneeded characters to the text. For Eaxample... I sent a txtmsg to HEROES mobile and I got a simple response which looks like this:

HEROES: Use your cell
phone's Internet browser to
visit us at URL:
http://m.nbc.com/hroes
Thank You!
From:62288
4:21pm 10/16/07

Ok?! How can I get that smsphp/contact.php form to display something like that...with no extra filler??!

Thanks!

Keith/ZenMartian.

Hey Keith,
I'm making some changes to the script tonight so I'll take your those ideas into consideration. I should have the updated script online in an hour.

It well be at http://easykiss123.com/?p=7 Just check the download tab on that page for the latest updates.

I'll get back with more details to your questions ASAP but check the script because some of them may be solved.

QuantumPHP

Hi Quantum...
Say... not to trouble you, cheif...but there seems to be something wrong with that 2nd version file which you said was recently posted. It's not working. Corupted, I think. Perhaps you've been looking into it even before I sent this note to you. Well...here on my end, I'm trying to modify the php, using a web form (html/php) that I got from web design class some time ago. It comes in four parts... the web form (html), the php, thankyou.html, and error.html... I think if I swipe/copy/paste some code back and forth, I believe I can fix the problem of making the sms form acknowledge a separate 'thankyou.html' web page, along with separate 'error.html' web page. I'm a tad slow at it (php), yet It seems quite feasable :-) Anyhow... the main goal is to get it working within an iFrame. The way it should work is, a visitor inputs their 10-digit number, selects their carrier, then clicks 'send-to-phone.' Then the 'thank you' page displays itself (their ought to be a RESET link there to get the web/sms form to refresh).

Thanks for any help you can give me on this matter :-)

Keith.

Hey Keith,
I'm making some changes to the script tonight so I'll take your those ideas into consideration. I should have the updated script online in an hour.

It well be at http://easykiss123.com/?p=7 Just check the download tab on that page for the latest updates.

I'll get back with more details to your questions ASAP but check the script because some of them may be solved.

QuantumPHP

Hi Keith,
I've fixed the download and it should work fine now.
I've added a few things to this version.
1. Seperate thankyou and error page
2. External style sheet
3. Changed the look for the better

I'll be making some more changes to the sms web script over the next while so if anyone on here has suggestions let me know.

The script is at http://easykiss123.com/?p=7

Hi Keith,
I've fixed the download and it should work fine now.
I've added a few things to this version.
1. Seperate thankyou and error page
2. External style sheet
3. Changed the look for the better

Hello QuantumPHP :-)
LOL!! Thought I was the only guy awake this time of night! Hey...I just got your reply... Thanks a Bunch! Yes, this time the files have downloaded without a problem. I'm going to give it a go first thing in the morning! I'll get back to ya and let you know the results! So far, this is a tremendous help :-) Thank You!

Keith.

I'll be making some more changes to the sms web script over the next while so if anyone on here has suggestions let me know.

The script is at http://easykiss123.com/?p=7

Hello again, QuantumPHP....
So far, this smsphp is working fine. I'm just wondering if there's any way to get rid of, or hide the 'FRM:' text? This is the text that displays as part of the header text, I think. It displays my phone number (i.e., "phonenumber@p3slh075.shr.phx3.secureserve"). Is there a way to not have this info display so that I could get more room for extra characters of text?

In using this method, I would like for the sms to only show "SUBJ:" and "MSG:" followed by 'From' (which it already does this naturally - i.e., 'From: 1010100078'). Okay... just curious and wondering if there's a way within the PHP to do that.

Thanks!
Keith.

Hey Keith,
I'll work on that next. It seems it might be related to what the cell company includes with sending messages this way.

I'm exploring some other ways of sending so stay tuned. I'll post a comment as soon as I know more. Soon.

http://easykiss123.com/?p=7

QuantumPHP

Hello everyone,

Yes, I was looking for something like this for some time now. Thanks a lot, this really helped me.

WorldGuru,
Admin
<URL SNIPPED>

i love you

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.