<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>fengcool.com &#187; GMail</title>
	<atom:link href="http://www.fengcool.com/tag/gmail/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.fengcool.com</link>
	<description>Just another WordPress weblog</description>
	<lastBuildDate>Wed, 25 Jan 2012 19:09:58 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.1</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Sending text message (SMS) to your mobile phone from your server via GMail SMTP using PHP</title>
		<link>http://www.fengcool.com/2008/12/sending-text-message-sms-to-your-moblie-phone-from-your-server-via-gmail-smtp/</link>
		<comments>http://www.fengcool.com/2008/12/sending-text-message-sms-to-your-moblie-phone-from-your-server-via-gmail-smtp/#comments</comments>
		<pubDate>Thu, 04 Dec 2008 04:05:20 +0000</pubDate>
		<dc:creator>rick</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[GMail]]></category>
		<category><![CDATA[phpmailer]]></category>
		<category><![CDATA[sms]]></category>
		<category><![CDATA[smtp]]></category>
		<category><![CDATA[text message]]></category>

		<guid isPermaLink="false">http://www.fengcool.com/?p=60</guid>
		<description><![CDATA[php example code tell you how to use phpmailer class to send your email using google's smtp server. also teach you how to send text message directly to your mobile phone via email. ]]></description>
			<content:encoded><![CDATA[<p>In some cases I need to send a warning message or a notice to my cell phone when certain tasks are done or caught some unexpected errors by server cronjob. This is a quite exciting feature, I don&#8217;t need to sit in front of my computer to do the boring monitoring job.</p>
<p>With some googling, there is something called Email to SMS Gateway (here is the <a href="http://en.wikipedia.org/wiki/SMS_gateways#Email_to_SMS" target="_blank">gateway list</a>) that allow you to send an Email to phone company, and phone company automatically delivery the Email content as text message to the cell phone owner. In my case, for example, I need to send SMS to cell phone number 416-999-9999 and phone carrier is Rogers. Regarding to the gateway list, means I should send Email to 4169999999@pcs.rogers.com</p>
<p>My first thought about sending out Email is using simple PHP mail() function. Unluckily, the Email sent out couldn&#8217;t pass phone carrier&#8217;s spam filter (Not exactly know what happened, my guess is my domain can&#8217;t pass Reverse DNS checking).</p>
<p>With some googling again for sloving send out Email issue, I found out GMail accounts can actually be used as an SMTP server. If this is working, that means phone carrier directly receive email from GMail.</p>
<p>Here&#8217;s a code snippet on how to do it. In the code, I used <a href="http://phpmailer.codeworxtech.com/" target="_blank">PHPMailer</a> class.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
</pre></td><td class="code"><pre class="php" style="font-family:monospace;">&nbsp;
<span style="color: #b1b100;">require</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;class.phpmailer.php&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000088;">$mail</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> PHPMailer<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$mail</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">IsSMTP</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// send via SMTP</span>
<span style="color: #000088;">$mail</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">SMTPAuth</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// turn on SMTP authentication</span>
<span style="color: #000088;">$mail</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">Host</span>		<span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;ssl://smtp.gmail.com&quot;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$mail</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">Port</span>		<span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;465&quot;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$mail</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">SMTPDebug</span>  <span style="color: #339933;">=</span> <span style="color: #cc66cc;">2</span><span style="color: #339933;">;</span> 
&nbsp;
<span style="color: #000088;">$mail</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">Username</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;YOUR_GMAIL_ACCOUNT@gmail.com&quot;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// SMTP username</span>
<span style="color: #000088;">$mail</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">Password</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;YOUR_GMAIL_LOGIN_PASSWORD&quot;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// SMTP password</span>
&nbsp;
<span style="color: #000088;">$from_email</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;example@example.com&quot;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">//Reply to this email ID</span>
<span style="color: #000088;">$to_email</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;4169999999@pcs.rogers.com&quot;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// Recipients email ID</span>
<span style="color: #000088;">$to_name</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;to_this_name&quot;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// Recipient's name</span>
&nbsp;
<span style="color: #000088;">$mail</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">From</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$from_email</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$mail</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">FromName</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;from_this_name&quot;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$mail</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">AddAddress</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$to_email</span><span style="color: #339933;">,</span><span style="color: #000088;">$to_name</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$mail</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">AddReplyTo</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$from_email</span><span style="color: #339933;">,</span><span style="color: #0000ff;">&quot;Webmaster&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$mail</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">WordWrap</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">50</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// set word wrap</span>
&nbsp;
<span style="color: #000088;">$mail</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">Subject</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;TEXT_MESSAGE_SUBJECT&quot;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$mail</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">Body</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;TEXT_MESSAGE_CONTENT&quot;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">//HTML Body</span>
<span style="color: #000088;">$mail</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">AltBody</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;TEXT_MESSAGE_CONTENT&quot;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">//Text Body</span>
&nbsp;
<span style="color: #000088;">$mail</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">Send</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>Have fun!</p>
<p>Thanks for devsoft to point out this. You must configure PHP to enable php_openssl extension.</p>
<a rel="external nofollow" class="a2a_dd addtoany_share_save" href="http://www.addtoany.com/share_save?linkurl=http%3A%2F%2Fwww.fengcool.com%2F2008%2F12%2Fsending-text-message-sms-to-your-moblie-phone-from-your-server-via-gmail-smtp%2F&amp;linkname=Sending%20text%20message%20%28SMS%29%20to%20your%20mobile%20phone%20from%20your%20server%20via%20GMail%20SMTP%20using%20PHP"><img src="http://www.fengcool.com/wp-content/plugins/add-to-any/share_save_120_16.png" width="120" height="16" alt="Share/Save/Bookmark"/></a>]]></content:encoded>
			<wfw:commentRss>http://www.fengcool.com/2008/12/sending-text-message-sms-to-your-moblie-phone-from-your-server-via-gmail-smtp/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>

