<?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>Vishal Kumar &#187; php</title>
	<atom:link href="http://www.vishalkumar.in/tag/php/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.vishalkumar.in</link>
	<description>Think Different. Make a Difference.</description>
	<lastBuildDate>Thu, 24 Nov 2011 15:54:17 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>PHP Mail using Gmail SMTP Tutorial</title>
		<link>http://www.vishalkumar.in/2009/06/php-mail-using-gmail-smtp-tutorial/</link>
		<comments>http://www.vishalkumar.in/2009/06/php-mail-using-gmail-smtp-tutorial/#comments</comments>
		<pubDate>Wed, 10 Jun 2009 13:17:08 +0000</pubDate>
		<dc:creator>Vishal</dc:creator>
				<category><![CDATA[Tutorial]]></category>
		<category><![CDATA[gmail]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://www.vishalkumar.in/?p=135</guid>
		<description><![CDATA[So here is the tutorial for sending PHP Mail using Gmail as your SMTP engine]]></description>
			<content:encoded><![CDATA[<p>Alright, this was one of the queries I got a few days back. I finally got the time to pour some time on it.</p>
<p>So here is the tutorial for sending PHP Mail using Gmail as your SMTP engine.</p>
<p><span id="more-135"></span></p>
<p>First of you all, I&#8217;m going to pretend that you&#8217;re familiar with a few things:</p>
<ul>
<li>PHP (you know, PHP: Hypertext Preprocessor). Its a lovely language for developing webpages. If you already knew that, then good. If not, you might want to read a <a title="W3C Schools PHP Tutorials" href="http://www.w3schools.com/PHP/DEfaULT.asP">good PHP Tutorial</a>.</li>
<li>A local apache+PHP webserver running to test with. I use either <a title="XAMPP Server" href="http://www.apachefriends.org/en/xampp.html">XAMPP</a> or <a title="WAMP Server" href="http://www.wampserver.com/en/">WAMPServer</a>, while on Windows Vista. Or <a title="Forum Post for Installing LAMP via Synaptic" href="http://ubuntuforums.org/archive/index.php/t-510403.html">install LAMP stack in Ubuntu</a>.</li>
<li>Can edit your PHP.ini configuration file. (If you don&#8217;t know what I&#8217;m talking about, get <em>really </em>familiar with the above two.</li>
</ul>
<p>K, here goes.</p>
<ol>
<li>If you haven&#8217;t done so already, get a PHP server running.</li>
<p></p>
<li>Download <a title="PHP Mailer Download" href="http://sourceforge.net/project/showfiles.php?group_id=26031&amp;package_id=252700">PHP-Mailer</a> (they also have other php software for easy form-to-email).</li>
<p></p>
<li>Go to your C:\xampplite\htdocs folder (in XAMPP) or C:\wamp\www folder (in WAMP), and extract the PHP Mailer into it. I&#8217;ll call this folder Root from now on.</li>
<p></p>
<li>Now go to Root\PHP-Mailer\examples\, and open up test_smtp_gmail_basic.php.</li>
<p></p>
<li>Now you shall have to do some minor editing. Don&#8217;t worry, its majorly minor. Just change the Emails to your send and receiver, and type your password. Here&#8217;s what mine almost looks like. Almost. Thats not the password. &#8230; I think.</li>
<p>
</ol>
<p>
<div id="attachment_144" class="wp-caption aligncenter" style="width: 310px"><a href="http://www.vishalkumar.in/wp-content/uploads/2009/06/screenshot-6_10_2009-4_47_08-pm.png"><img class="size-medium wp-image-144" title="screenshot-6_10_2009-4_47_08-pm" src="http://www.vishalkumar.in/wp-content/uploads/2009/06/screenshot-6_10_2009-4_47_08-pm-300x209.png" alt="Open and edit test_smtp_gmail_basic.php" width="300" height="209" /></a><p class="wp-caption-text">Open and edit test_smtp_gmail_basic.php</p></div><br />
</p>
<blockquote><p><code>$mail-&gt;IsSMTP(); // telling the class to use SMTP</code><br />
<br />
<code>$mail-&gt;Host       = "stmp.gmail.com"; // SMTP server</code></p>
<p><code>$mail-&gt;SMTPDebug  = 1;                     // enables SMTP debug information (for testing)</code></p>
<p><code>// 1 = errors and messages</code></p>
<p><code>// 2 = messages only</code></p>
<p><code>$mail-&gt;SMTPAuth   = true;                  // enable SMTP authentication</p>
<p>$mail-&gt;SMTPSecure = "ssl";                 // sets the prefix to the servier</p>
<p>$mail-&gt;Host       = "smtp.gmail.com";      // sets GMAIL as the SMTP server</p>
<p>$mail-&gt;Port       = 465;                   // set the SMTP port for the GMAIL server</p>
<p>$mail-&gt;Username   = "<strong>vishalkumar@gmail.com</strong>";  // GMAIL username</p>
<p>$mail-&gt;Password   = "<strong>topsecretpassword:D</strong>";            // GMAIL password</p>
<p>$mail-&gt;SetFrom('<strong>vishalkumar@gmail.com</strong>', 'Vishal Kumar');</p>
<p>$mail-&gt;AddReplyTo("<strong>vishalkumar@gmail.com</strong>","Vishal Kumar");</p>
<p>$mail-&gt;Subject    = "Hey, check out http://www.vishalkumar.in";</p>
<p>$mail-&gt;AltBody    = "Hey, check out this new post on www.vishalkumar.in"; // optional, comment out and test</p>
<p>$mail-&gt;MsgHTML($body);</p>
<p>$address = "<strong>vishalkumar@gmail.com</strong>";</p>
<p></code><code>$mail-&gt;AddAddress($address, "Vishal Kumar");<br />
</code></p></blockquote>
<p></p>
<ol start="6">
<li>Now, pressing save, you&#8217;ll be half done with this little tutorial. Ok, the actual step is you need to edit your PHP.ini file settings. You can find that C:\xampplite\php if you are into XAMPP. Here you need to open the PHP.ini file, then search for &#8220;openssl&#8221;. Go ahead and take that &#8216;;&#8217; comment symbol from the start of the line. In WAMP, all you need is your mouse. Just click on the speedometer icon of WAMPServer in the taskbar. Go to PHP&gt;PHP Extensions and click on <strong>php_openssl</strong> to turn it on</li>
</ol>
<p><div id="attachment_145" class="wp-caption aligncenter" style="width: 421px"><a href="http://www.vishalkumar.in/wp-content/uploads/2009/06/screenshot-6_10_2009-5_59_21-pm.png"><img class="size-full wp-image-145  " title="screenshotofphpopenssl" src="http://www.vishalkumar.in/wp-content/uploads/2009/06/screenshot-6_10_2009-5_59_21-pm.png" alt="Enable the php_openssl.dll extension by taking off the ';'" width="411" height="293" /></a><p class="wp-caption-text">Enable the php_openssl.dll extension by taking off the &#39;;&#39; in XAMPP</p></div><br />
<br />
<div id="attachment_146" class="wp-caption aligncenter" style="width: 310px"><a href="http://www.vishalkumar.in/wp-content/uploads/2009/06/screenshot-6_10_2009-6_04_00-pm.png"><img class="size-medium wp-image-146" title="wamppphp_openssl" src="http://www.vishalkumar.in/wp-content/uploads/2009/06/screenshot-6_10_2009-6_04_00-pm-300x200.png" alt="Tick to enable php_openssl in WAMP" width="300" height="200" /></a><p class="wp-caption-text">Tick to enable php_openssl in WAMP</p></div><br />
</p>
<ol start="7">
<li>Restart your servers services. This should be fairly simple</li>
<p></p>
<li>Go navigate to http://localhost/PHP-Mailer/examples/test_smtp_gmail_basic.php in your browser. And then check your Receivers Inbox. Hi!!!</li>
</ol>
<p>Thats about it; thats how I managed to send emails using GMail&#8217;s SMTP engine to any mail, through PHP.</p>
<p>Note though, this tutorial is meant to be a specific reply to a certain query I got, but I figured more people would want to read this, so I posted it up.</p>
<p>If you have any doubts, or extensions, or any helpful suggestions, comment up. <img src='http://www.vishalkumar.in/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://www.vishalkumar.in/2009/06/php-mail-using-gmail-smtp-tutorial/feed/</wfw:commentRss>
		<slash:comments>45</slash:comments>
		</item>
	</channel>
</rss>

