2. March 2011 03:42
aspNetEmail can easily send email through Gmail. To do this, you must do the following:
a) Download the AdvancedIntellect.Ssl.dll from http://www.advancedintellect.com/download.aspx
b) Use aspNetEmail over SSL at port 587 to connect and send.
Lets discuss this below.
Download the AdvancedIntellect.Ssl.dll
To send email through Gmail, you need to do this over SSL. The AdvancedIntellect.Ssl.dll provides this functionality. It is a plugin that can be used with aspNetEmail.
You can download the dll from http://www.advancedintellect.com/download.aspx
Use aspNetEmail over SSL at port 587 to connect.
Once you've downloaded the dll, you can integrate it into your project.
If you are using VS.NET, import the dll into your application, and set a reference to it.
If you are not using VS.NET, you should be able to just copy the dll to your /bin directory.
Below is a simple code example that demonstrates sending the email through gmail.
EmailMessage msg = new EmailMessage();
string userAccount = "MyAccount@gmail.com";
string password = "MyPassword";
//some basic properties
msg.Server = "smtp.gmail.com";
msg.Port = 587;
msg.Username = userAccount;
msg.Password = password;
msg.FromAddress = userAccount;
msg.Subject = "This is my test email through gmail.";
msg.Body = "Put the body contents here...";
//any logging (not reqired) for troubleshooting
msg.LogPath = "c:\\temp\\email.log";
msg.Logging = true;
//create the ssl socket
AdvancedIntellect.Ssl.SslSocket ssl = new AdvancedIntellect.Ssl.SslSocket();
msg.LoadSslSocket( ssl, false);
//logging on the ssl socket
ssl.Logging = true;
ssl.LogPath = "c:\\ssl.log";
Dim msg As New EmailMessage()
Dim userAccount As String = "MyAccount@gmail.com"
Dim password As String = "MyPassword"
'some basic properties
msg.Server = "smtp.gmail.com"
msg.Port = 587
msg.Username = userAccount
msg.Password = password
msg.FromAddress = userAccount
msg.To = "You@yourcompany.com"
msg.Subject = "This is my test email through gmail."
msg.Body = "Put the body contents here..."
'any logging (not reqired) for troubleshooting
msg.LogPath = "c:\temp\email.log"
msg.Logging = True
'create the ssl socket
Dim ssl As New AdvancedIntellect.Ssl.SslSocket()
'logging on the ssl socket
ssl.Logging = True
ssl.LogPath = "c:\ssl.log"
As always, if anyone has any questions, feel free to contact me over at the Contact Us web page.
13. October 2010 15:05
Today I received a request (Thanks Suraj!) about using a different email address during the SMTP process than what is seen in the email. Is this possible?
The short answer is "yes"!
aspNetEmail exposes a property called the ReversePath property. By default, this value is the FromAddress value. The ReversePath value will be used during the SMTP process. Specifically is the value of the "MAIL FROM" command.
This is useful, because some mail servers will only allow a specific email address to be used, but you may want a different FROM value in the email seen by the end user.
Here is a specific example. Suppose you have a CRM application hosted by a provider that has a locked down mail server. The hosting provider may only allow email to be relayed through their mail server using a single MAIL FROM address. However, the CRM application needs to send out email from different users. Using the ReversePath property allows this to happen. The ReversePath property will be using as the MAIL FROM value, while the FromAddress value will be the actual value seen in the mail client. An added bonus to doing this is that all human replies can go back to the FromAddress mailbox, while NDR bounces can go back to the ReversePath mailbox. You can then use something like ListNanny to process all of the bounces found in the ReversePath mailbox, without cluttering up someone's (FromAddress) personal mailbox.
As always, if you have any more questions about the ReversePath property, and how it works, please let me know.