Enable SSL for sending emails on Sitecore

I was asked to use a GMail server to send emails from Sitecore with. This is actually a pretty reasonable request – but GMail only supports connections over TLS or SSL. Configuring Web Forms for Marketers to use this was proving … interesting, until I found this excellent article by Mark Cassidy

As he’s not posting to that blog much anymore, and it was pretty useful, I might plagiarize a bit.

The problem that I hit was that Sitecore doesn’t, by default, support SSL in it’s standard mail function ( Sitecore.MainUtil.SendEmail() ). However, it does internally use System.Net.Mail.SmtpClient.Send() to actually send the email. So if we configure our application to allow the SmtpClient to use SSL, that should work (and it does). Add the following to the web.config file (it’s not under the <sitecore> node, so you can’t patch it in).

<system.net>
<mailSettings>
<smtp deliveryMethod="Network">
<network enableSsl="true" />
</smtp>
</mailSettings>
</system.net>

Interestingly – and annoyingly – web forms for marketers works differently, and the ‘parameters’ field in Sitecore needs to be set with a string defining the connection settings – and using a poorly documented option to enableSSL. E.g.:

<Host>smtp.gmail.com</Host><Port>587</Port><Login>example@example.com</Login><Password>xxxxx</Password><From>example@example.com</From><IsBodyHtml>true</IsBodyHtml><enableSSL>true</enableSSL>

I’m not sure about Email Campaign Manager yet, but I would assume that it should play nicely with SSL.

 

Advertisements
Enable SSL for sending emails on Sitecore

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s