Tags: Episerver DXP

Optimizely SendGrid SMTP host is deprecated

SendGrid is a services for sending email that is included in Optimizely DXP. Previously smtp.episerver.net was the recommended SMTP server to use. Right after upgrading to CMS 12, sending email stopped working, and I found this is the logs.

---> MailKit.Security.SslHandshakeException: An error occurred while attempting to establish an SSL or TLS connection.
       The host name did not match the name given in the server's SSL certificate.
---> System.Security.Authentication.AuthenticationException: The remote certificate was rejected by the provided RemoteCertificateValidationCallback.
  at System.Net.Security.SslStream.SendAuthResetSignal(ProtocolToken message, ExceptionDispatchInfo exception)
  at System.Net.Security.SslStream.CompleteHandshake(SslAuthenticationOptions sslAuthenticationOptions)
  at System.Net.Security.SslStream.ForceAuthenticationAsync[TIOAdapter](TIOAdapter adapter, Boolean receiveFirst, Byte[] reAuthenticationData, Boolean isApm)
  at MailKit.Net.Smtp.SmtpClient.ConnectAsync(String host, Int32 port, SecureSocketOptions options, Boolean doAsync, CancellationToken cancellationToken)
  --- End of inner exception stack trace ---
  at MailKit.Net.Smtp.SmtpClient.ConnectAsync(String host, Int32 port, SecureSocketOptions options, Boolean doAsync, CancellationToken cancellationToken)
  at EPiServer.Notification.Internal.SmtpClientImplementation.SendAsync(MimeMessage message)
  --- End of inner exception stack trace ---
  at System.Threading.Tasks.Task.ThrowIfExceptional(Boolean includeTaskCanceledExceptions)
  at System.Threading.Tasks.Task.Wait(Int32 millisecondsTimeout, CancellationToken cancellationToken)
  at System.Threading.Tasks.Task.Wait()
  at EPiServer.Forms.Implementation.Actors.SendEmailAfterSubmissionActor.<>c__DisplayClass13_0.b__2()

According to Optimizely support,  smtp.episerver.net were deprecated a while ago, and it's  smtp.sendgrid.net that should be used from now on.

Update, December 8, 2022: I have been informed that smtp.episerver.net is just a CNAME for smtp.sendgrid.net and that has not changed. It is probably the default TLS settings in CMS 12 that caused the behaviour, as the SSL certificate returned by smtp.sendgrid.net does not match smtp.episerver.net

Even if you are using CMS 11, and everything works fine, I think it will be a good idea to change to smtp.sendgrid.net