<?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; Tutorial</title>
	<atom:link href="http://www.vishalkumar.in/tag/tutorial/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>Asp.NET Mail using Gmail SMTP Tutorial</title>
		<link>http://www.vishalkumar.in/2009/06/aspnet-mail-using-gmail-smtp-tutorial/</link>
		<comments>http://www.vishalkumar.in/2009/06/aspnet-mail-using-gmail-smtp-tutorial/#comments</comments>
		<pubDate>Wed, 10 Jun 2009 20:17:22 +0000</pubDate>
		<dc:creator>Vishal</dc:creator>
				<category><![CDATA[Tutorial]]></category>
		<category><![CDATA[asp]]></category>
		<category><![CDATA[gmail]]></category>

		<guid isPermaLink="false">http://www.vishalkumar.in/?p=157</guid>
		<description><![CDATA[A tutorial on sending Asp.NET email using GMail's SMTP.]]></description>
			<content:encoded><![CDATA[<p>It&#8217;s very useful to learn how to set up to send mail using Asp.NET, both GMail and Asp.NET are widely used and trusted. One advantage is flexibility: If you&#8217;re a setting up a large email system for mass mail-outs to <a href="http://www.foxybingo.com/" target="_blank">Foxy Bingo</a> customers and other gaming fans, or if you&#8217;re a smaller, family business who is just mailing your local clientele, this system is up to the job. Enjoy the tutorial.</p>
<p>So here is another, even briefer, tutorial on sending mail in Asp.NET using GMail SMTP (means using a GMail Account doh!).<br />
<span id="more-157"></span></p>
<p>Alright, this is what you do:</p>
<ol>
<li>If you haven&#8217;t done so already, download a .NET development tool like <a href="http://www.microsoft.com/exPress/download/#webInstall">Visual Web Developer 2008 Express Edition</a>.</li>
<li>Go to File&gt;New Web Site, select new ASP.NET Web Site, and choose Visual C# for your language. (Ok, You&#8217;ve mostly probably already come up to this stage, but I&#8217;m just being complete. <img src='http://www.vishalkumar.in/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </li>
</ol>
<div id="attachment_158" class="wp-caption aligncenter" style="width: 310px"><a href="http://www.vishalkumar.in/wp-content/uploads/2009/06/screenshot-6_10_2009-11_49_11-pm.png"><img class="size-medium wp-image-158" title="Screenshot of New Web Site" src="http://www.vishalkumar.in/wp-content/uploads/2009/06/screenshot-6_10_2009-11_49_11-pm-300x193.png" alt="Step 2 in action. If you are not seeing this, try harder." width="300" height="193" /></a><p class="wp-caption-text">Step 2 in action. If you are not seeing this, try harder.</p></div>
<ol>
<li>Now, by default you&#8217;ll see your Default.aspx file, where you can use the visual tools to drag and drop in your files. But you actually want the Default.aspx.cs file to edit. On the right you&#8217;ll see your Solution Explorer. Click on the plus and double click on Default.aspx.cs</li>
</ol>
<div id="attachment_159" class="wp-caption aligncenter" style="width: 310px"><a href="http://www.vishalkumar.in/wp-content/uploads/2009/06/screenshot-6_10_2009-11_54_01-pm.png"><img class="size-medium wp-image-159" title="Screenshot of Visual Web Developer 2008 Express" src="http://www.vishalkumar.in/wp-content/uploads/2009/06/screenshot-6_10_2009-11_54_01-pm-300x187.png" alt="Top right, Solution Explorer. Code in the middle." width="300" height="187" /></a><p class="wp-caption-text">Top right, Solution Explorer. Code in the middle.</p></div>
<ol>
<li>Here you&#8217;ll have the actual C# code that runs to generate your HTML output for the browser. So this is where you shall put in your C# Mail code. Be sure to edit out like the username (your entire GMail gmail), and password (you know, that one).</li>
</ol>
<pre>using System;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Net.Mail;

public partial class _Default : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        sendMail();
    }
    public void sendMail()
    {
        string from="vishalkumar@gmail.com";
        string to = "vishalkumar@gmail.com";
        string subject = "Hi there";
        string body = "Hey there &lt;br /&gt; Check out http://www.vishalkumar.in";
        sendMailall(from, to, subject, body);
    }
    public void sendMailall(string from, string to, string subject, string body)
    {
        MailMessage mail = new MailMessage();
        mail.To.Add(to);
        mail.From = new MailAddress(from);
        mail.Subject = subject;
        mail.Body = body;
        mail.IsBodyHtml = true;
        SmtpClient smtp = new SmtpClient();
        smtp.Host = "smtp.gmail.com";
        smtp.Credentials =
             new System.Net.NetworkCredential("vishalkumar@gmail.com",
                                                                "thisisnotmypassword");
        smtp.EnableSsl = true;
        smtp.Send(mail);
     }
}</pre>
<ol>
<li>Now just press F5 to debug, which basically means run the page. By simply running the above page, you&#8217;ll trigger the code to send an email to the address specified.</li>
<li>And you&#8217;re done for now. You can now add extra features like creating a form, or sending automated emails, etc, for all you like. Enjoy.</li>
</ol>
<p>And thats it. Alright I admit, you didn&#8217;t really need that many steps. Frankly, just copy the code and play with it.</p>
<p>If you get stuck (and you tried really really hard yes please), gmail me later. Or comment up.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.vishalkumar.in/2009/06/aspnet-mail-using-gmail-smtp-tutorial/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<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>

