Sunday, December 23, 2012

Installing Microsoft SMTP on IIS

If ever there was an "SMTP for Dummies" solution, it would have to be Microsoft's SMTP implementation for the Internet Information Server (IIS) of its flagship Windows server products.  The product comes free with Windows Servers and just needs to be installed and configured, as it does not normally come pre-installed by default.

I recently migrated my servers to the "cloud" and was faced with the prospect of having to run my own SMTP service as the data center does not offer a centralized SMTP service.  Linux is normally a much more robust solution, but my skills in setting up SMTP date back to more than a decade ago. I'm so out of touch already with going down that route so I considered the easier way out -- Microsoft IIS.

Installing the SMTP service only takes about a minute.  One just has to follow these steps.  Setting it up is also just a matter of pointing-and-clicking for the most part as described here.  In no time at all, the SMTP service was up and running!

Thursday, December 20, 2012

Sending Email via GMail SMTP using C#

I recently availed of a cloud server over at Rackspace.  Since the company does not provide a public SMTP server for their clients, I  had two options -- install my own or, as my brother-in-law suggested, use GMail for outgoing SMTP.  The latter sounded a lot more appealing as maintaining an SMTP server is not a simple task.

I searched around the Internet for sample code and it turned out to be much simpler than I expected with .NET because the System.Net.Mail class structure already has all the stuffs needed to implement the security stuffs.  It just looks something like this:

System.Net.Mail.SmtpClient client = new System.Net.Mail.SmtpClient();
client.Host = "";
client.Port = 587;
client.EnableSsl = true;
client.Credentials = new System.Net.NetworkCredential("", "mypassword");

System.Net.Mail.MailAddress from = new System.Net.Mail.MailAddress("", "Dick Chiang");
System.Net.Mail.MailAddress to = new System.Net.Mail.MailAddress("");
System.Net.Mail.MailMessage message = new System.Net.Mail.MailMessage(from, to);
message.Subject = "Sample GMail Message";
message.Body = "Hello world from GMail!";

Wednesday, December 12, 2012

Telnet Client for Windows 7 and 2008 R2

I've been trying to debug something for the past couple of days and I just realized that Windows 7 does not have a telnet client installed by default unlike previous versions of Windows (dating back to version 3.11 as I recall).  Doing a quick Google research, I found out it can be installed by doing the following:
  1. Click Start, and then click Control Panel.
  2. On the Control Panel Home page, click Programs.
  3. In the Programs and Features section, click Turn Windows features on or off.
  4. If the User Account Control dialog box appears, confirm that the action it displays is what you want, and then click Continue.
  5. In the Windows Features list, select Telnet Client, and then click OK.
Windows 2008 R2 also does not have it installed by default.  The following instructions seem to do the trick:

  1. Start Server Manager. Click Start, right-click Computer, and then click Manage.
  2. If the User Account Control dialog box appears, confirm that the action it displays is what you want, and then click Continue.
  3. In the Features Summary section, click Add features.
  4. In the Add Features Wizard, select Telnet Client, and then click Next.
  5. On the Confirm Installation Options page, click Install.
  6. When installation finishes, on the Installation Results page, click Close.