Enable SSL for sending emails on Sitecore 9


In my current implementation I was asked to use SMTP settings which only supports connections over TLS or SSL. I am using Sitecore 9 in my current project.

By default, Sitecore does not use SSL for sending emails, and this is something that you need to adjust yourself by adding enableSSL in your web.config file.

This configuration only effects the emails that Sitecore send for there internal use like forgot Sitecore password and also If you are using Sitecore OOTB or default function for sending emails for example Sitecore.MainUtil.SendEmail method.

In previous versions, we configured the SSL-setting in a standard ASP.NET fashion, by adding the below setting into web.config file:

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

But in Sitecore 9 it doesn’t work anymore. I didn’t find any post about that there is some changes in configration for not to use settings given in web.config file. I thought there is some issue with my set up so made many changes in that. After almost wasting 4-5 hours and trying many things I started looking into different direction.

Now I was pretty sure that there is some changes on Sitecore side. So I started digging into the dll’s. And finally after digging into Sitecore.Kernel I found that Sitecore has introduced a new setting for this, which I am not sure in which version of Sitecore this was changed, but I do know that this is with Sitecore9.x.

Adding <setting name=”MailServerUseSsl” value=”true”/> will work in Sitecore 9 for SSL

Below is the new configuration settings for Sitecore9 – 

<sitecore>     
       <settings>
           <setting name="MailServer" value="[enter value]"/>
           <setting name="MailServerUserName" value="[enter value]"/>
            <setting name="MailServerPassword" value="[enter value]"/>
            <setting name="MailServerPort" value="[enter value]"/>
	     <setting name="MailServerUseSsl" value="true"/>
        </settings>
    </sitecore>

I am sure if you are going to start with Sitecore 9 and planing to use Sitecore forms for sending emails or simple .net forms and specially if your smtp settings are working over SSL then it can save your some time if you are not aware about this change.

Advertisements
This entry was posted in Sitecore, Uncategorized and tagged , , . Bookmark the permalink.

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 )

Google+ photo

You are commenting using your Google+ 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 )

Connecting to %s