Home   Buy Now   Products   Downloads   Support   Resellers   Contact   Site Map  
Home   Buy Now   Download   Support  
Email Component, SMTP Component, POP3 Component, IMAP Component, bulk mail

Home
Purchase
Upgrade
 
Products
Downloads
 
Support
 Samples
 KB
 Forum
 
Newsletter
 
Customers
 Current List
 Comments
 
Resellers
Jobs
Contact Us
 October 29, 2003  

Volume 1, Issue 4 

Page Navigator: << Back, 1, 2, 3

SSL Support for Your App

Adding SSL capabilities to your email application is very simple provided that you have the right set of components to handle the low level details such as certificate exchange, certificate authentication and encryption.  The following samples use EasyMail .Net Edition with the optional SSL plug-in.  The SSL plug-in component enables applications which use EasyMail .Net Edition to send and receive SSL protected email with only a few lines of code.  EasyMail .Net Edition, the SSL plug-in and all the sample code in this issue can be downloaded here.

Sending Mail Over an SSL Connection

The following sample code demonstrates how to send Internet email over a secure connection to an SSL enabled SMTP server.

VB.Net Sample
Dim objSMTP As New SMTP
objSMTP.SMTPServers.Add("mail.domain.com", 465)
Dim objSSL As New SSL
objSMTP.Connect(objSSL.GetInterface())
Dim objMessage As New EmailMessage( _
    "recipient@domain.com", "sender@domain.com", _
    "Subject", "Body text", BodyPartFormat.Plain)
objSMTP.Send(objMessage)
objSMTP.Disconnect()
C# Sample
SMTP objSMTP = new SMTP();
objSMTP.SMTPServers.Add("mail.domain.com", 465);
SSL objSSL = new SSL();
objSMTP.Connect(objSSL.GetInterface());
EmailMessage objMessage = new EmailMessage(
	"recipient@quiksoft.com", "sender@domain.com", 
	"Subject", "Body text", BodyPartFormat.Plain);
objSMTP.Send(objMessage);
objSMTP.Disconnect();   

Yeah, that's it, pretty easy huh?  Communications with the mail server will take place on port 465 which is the standard port for SMTP data traveling over SSL connections.  The SSL plug-in is interfaced with the SMTP component during the call to Connect(), and the email components take over from there. 

Retrieving Mail with POP3 Over an SSL Connection

Retrieving mail over a secure connection is just as easy.  The following example uses the EasyMail .Net Edition POP3 component and Parse component with the SSL plug-in.

VB.Net Sample
Dim objPOP3 As New POP3
Dim objSSL As New SSL
objPOP3.Connect("mail.domain.com",
                995, objSSL.GetInterface())
objPOP3.Login("account", "password", AuthMode.Plain)
Dim memoryStream As New MemoryStream
objPOP3.DownloadMessage(1, memoryStream)
memoryStream.Position = 0
Dim msg As New EmailMessage(memoryStream)
Console.WriteLine(msg.Subject)
Console.ReadLine()
C# Sample
POP3 objPOP3 = new POP3();
SSL objSSL = new SSL();
objPOP3.Connect("mail.domain.com",
                995, objSSL.GetInterface());
objPOP3.Login("account", "password", AuthMode.Plain);
MemoryStream memoryStream = new MemoryStream(); 
objPOP3.DownloadMessage(1,memoryStream);
memoryStream.Position=0; 
EmailMessage msg = new EmailMessage(memoryStream);
Console.WriteLine(msg.Subject);
Console.ReadLine();

As you can see securely retrieving email from a POP3 server is very easy too.  It is a very simple sample, but the amount of work going on beneath the hood is extreme.  It demonstrates perfectly how EasyMail .Net Edition shields you from the complexities of SSL, POP3, MIME, parsing and much more.  The sample uses the POP3 component to download the first message in the POP account to a memory stream, then parses it and displays the subject.  Communications with the mail server will take place on port 995 which is the standard port for POP3 data traveling over SSL connections.  The SSL plug-in is interfaced with the POP3 component during the call to Connect().  Even I am wondering "Is that it?".  Yeah that's it.  It is amazing how much EasyMail .Net Edition does for you while at the same time EasyMail .Net Edition will enable experienced developers to control and access virtually every aspect of SSL, POP3 and the parsed message.

Retrieving Mail with IMAP4 Over an SSL Connection

VB.Net Sample
Dim objIMAP4 As New IMAP4
Dim objSSL As New SSL
objIMAP4.Connect("mail.domain.com",
                 993, objSSL.GetInterface())
objIMAP4.Login("account, "password")
objIMAP4.SelectMailbox("Inbox")
Dim env As Envelope
Dim envelopes As EnvelopeCollection
envelopes = objIMAP4.GetEnvelopes()
For Each env In envelopes
   Console.WriteLine(env.Subject)
Next
objIMAP4.Logout()
Console.ReadLine()


C# Sample
IMAP4 objIMAP4 = new IMAP4();
SSL objSSL = new SSL();
objIMAP4.Connect("mail.domain.com",
                 993, objSSL.GetInterface());
objIMAP4.Login("account","password");
objIMAP4.SelectMailbox("Inbox");
EnvelopeCollection envelopes = objIMAP4.GetEnvelopes();
foreach (Envelope env in envelopes)
   Console.WriteLine(env.Subject);
objIMAP4.Logout();
Console.ReadLine();
This example uses the IMAP4 component to make a connection on port 993, the standard port for IMAP communications over SSL.  The example displays the subject of every message found in the "Inbox" without parsing the message, by using the "envelopes" feature of the IMAP component.

Conclusion

SSL is an easy way to secure email messages.  It is most powerful when used to secure intraorganizational email.  With EasyMail .Net Edition and the SSL plug-in, you can quickly and easily build robust .Net email apps that take advantage of all the security SSL has to offer.  The EasyMail .Net Edition SSL plug-in goes far beyond what is demonstrated here and includes support for SSL2, SSL3, TLS1, PCT1, certificate management, client certificates, STARTTLS and much more... 

EasyMail .Net Edition makes sending and retrieving email easy, with or without support for SSL.  If you have not downloaded EasyMail .Net Edition and tried it for yourself, click here and get started now.

I hope you found this article informative and useful.  If you have any questions, comments or suggestions, please let me know. My contact information is below.

 


John Alessi has specialized in email development for the past 7 years and has helped many large companies such as Microsoft, Boeing and EarthLink with their e-mail needs. He can be reached at john@quiksoftcorp.com.  Quiksoft, founded in 1994, helps companies design and build email systems by providing reliable tools, consulting and programming services.

Page Navigator: << Back, 1, 2, 3


In This Issue:

Learn the secrets of sending and retrieving email securely with SSL. 

Plus:
Downloadable code to get you started right away


This Issue's Poll:

When do you plan to implement secure email apps?

Right Away
Within 3 monthss
Within 6 months
Within 1 Year
Never
Unsure


Signup for this Newsletter:

CRITICAL tips and tricks for e-mail developers


Quiksoft News:

EasyMail .Net Edition 2.1 includes support for the new SSL Plug-in plus many other exciting new features and enhancements.



Customer Comments

"Quiksoft's technical support is excellent. I wish all of our vendors were as responsive and helpful with technical support requests. "

"It paid for itself just after this project."

"I think your product is fantastic. The documentation is clear and consise."

Read More...


E-mail this newsletter to a friend or to yourself:

Unsubscribe...

Printer Friendly Version...

©2003 Quiksoft Corporation. All rights reserved. Unauthorized duplication or distribution prohibited. Quiksoft, EasyMail, EasyMail Objects, EasyMail .Net Edition, EasyMail Advanced API, EasyMail SMTP Express, and MailStore are trademarks of Quiksoft Corporation. Other trademarks mentioned are the property of their legal owner.
©2010 Quiksoft Corporation. All rights reserved. Terms of Use, Privacy Statement, Trademarks