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.