I'm trying to set up SendGrid in Azure and use it to facilitate emailing in Sitecore by populating the MailServer (MailServer, MailServerUserName, MailServerPassword, MailServerPort) values in the config to the values specific to the SendGrid service I set up. I've tested that I can authenticate and email from this service using some telnet command line commands, but when it comes to Sitecore, it appears that proper communication is not occuring.

When I try to test by going through the "Forgot My Password" flow, I get a silent error that's logged in the logs reading:

10404 18:01:39 ERROR SMTP client email sending failed. Exception: System.Net.Mail.SmtpException Message: The server committed a protocol violation The server response was: Source: System at System.Net.Mail.SendMailAsyncResult.End(IAsyncResult result) at System.Net.Mail.SmtpClient.SendMailCallback(IAsyncResult result)

My suspicion is that my credentials aren't getting passed properly. If I put in bogus values for username / password, the outcome isn't any different errorwise. If anyone has set this up before, I'd appreciate any perspective you might have on troubleshooting this or otherwise general advice about how to set this up properly.

  • 1
    have you tried using a different port on the smtp/azure side? – Andrey Bobrov Dec 4 '17 at 22:49
  • You likely need to enable SSL. See towards the bottom of this post: jondjones.com/learn-sitecore-cms/sitecore-developers-guide/… Do so in the system.net settings – jrap Dec 5 '17 at 1:11
  • Are your forms etc using WFFM, or is this strictly related to other mechanisms in Sitecore sending e-mails (Workflow emails etc.)? – Dylan Young Dec 5 '17 at 2:44
  • I am currently just testing email capability in Sitecore itself (forgot password, workflow emails, etc). – David Hake Dec 5 '17 at 14:33
  • The SSL idea was a good one. I tried configuring for SSL using port 465 in my local environment using a self signed certificate. It appears to be timing out now when attempting to email. – David Hake Dec 5 '17 at 14:35

We are using SendGrid successfully in both WFFM and with default Sitecore MailServer settings. All relevant Sitecore settings are defined below (WFFM intentionally not included).

Sitecore Settings

<setting name="MailServer">
  <patch:attribute name="value">smtp.sendgrid.net</patch:attribute>
<setting name="MailServerUserName">
  <patch:attribute name="value">apikey</patch:attribute>
<setting name="MailServerPassword">
  <patch:attribute name="value">PASSWORD</patch:attribute>
<setting name="MailServerPort">
  <patch:attribute name="value">587</patch:attribute>


    <smtp deliveryMethod="Network">
      <network enableSsl="true"/>

I can confirm our Forgot Password functionality is working properly with these settings.

  • Thanks for this detail. I want to confirm that you have the literal username as apikey and the password as the api key you generated in SendGrid. Is this currently working in an environment with a legit SSL certificate (I'm currently troubleshooting this in my local environment using a self signed certificate, which I am thinking may be part of my issue). Also, it's my understanding that if you are using SSL with SendGrid that you are supposed to use port 465. I want to confirm that the config values you sent for me are for a site where there is an SSL binding. Thanks! – David Hake Dec 5 '17 at 21:51
  • Yes the only obfuscated field is password above. The rest are as-is. SSL is a bit tricky. Per the server it’s running on- no it doesn’t think it has an SSL. There is a app gateway above it where the SSL is installed. I didn’t think the SSL for the website factored in to an SMTP call but perhaps? – jrap Dec 5 '17 at 22:01
  • And yes the password field is the API Key generated from SendGrid. All other fields are exactly from our instance. Also- I had tested this locally and on many other servers. If you can send emails via telnet from the server, then it is most likely a configuration issue with your setup. Thinking about it more- the SSL for the website should have no bearing on your ability to send mail. – jrap Dec 6 '17 at 14:14
  • Figuring there was something very obvious that was wrong in my setup, my hunches were confirmed. I had my patch file for the MailServer config values indented, which was rendering out like <MailServer> value </MailServer>. Otherwise your solution gave me the direction I needed. I didn't need to add in the web.config change you referenced however. Thank you very much! – David Hake Dec 6 '17 at 17:47

Do you have a CA and CD Server? If so then you need to do the following:

On a Content Delivery (CD) instance

  1. On the Content Delivery (CD) instance, in a text editor, open the Sitecore.config file.
  2. Configure the following SMTP settings: MailServer, MailServerUserName, MailServerPassword.

On a Content Management (CM) instance

  1. In the content tree, navigate to the Save Actions folder
    (sitecore/System/Modules/Web Forms for
    Marketers/Settings/Actions/Save Actions) and click the Send Email
    Message item.

  2. In the right pane, in the Submit tab, in the Parameters field, delete the , and
    parameters, if you have any. Click Save, and
    republish your website.

More info here:



I've also used this approach to use a pipeline to configure this for various environments too and it works quite well:


    <!-- Custom E-Mail Processor for Web Forms -->
    <processor type="MyProject.Forms.EMail.ApplySendingSettings, MyProject" method="Process" patch:before="processor[@method='SendEmail']"/>


<!-- Mail Server Host Name / Port -->
<setting name="WFM.Custom.Email.Host" value=""/>
<setting name="WFM.Custom.Email.Port" value="25"/>

<!-- Mail Server login credentials -->
<setting name="WFM.Custom.Email.User" value=""/>
<setting name="WFM.Custom.Email.Password" value=""/>

<setting name="WFM.Custom.Email.EnableSSL" value="false"/>
<setting name="WFM.Custom.Email.SendAsHtml" value="true"/>

<!-- From address to use unless specified otherwise in save action -->
<setting name="WFM.Custom.Email.From" value=""/>

<!-- Global BCC address added to every message -->
<setting name="WFM.Custom.Email.Bcc" value=""/>

  • OP mentions the "Forgot my password" link, so not testing it using WFFM, although likely to run into this issue :) – jammykam Dec 5 '17 at 3:53
  • Ahr right I made assumptions that this was forms built with WFFM but re-reading it as you say it's probably the 'Forgot your password?' link on the login to Sitecore he was testing with. – Adam Seabridge Dec 5 '17 at 11:26
  • Yeah, right now I am starting with basic email capability, so not getting WFFM involved. My issue seems to be a fundamental one relating to integrating with SendGrid – David Hake Dec 5 '17 at 14:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.