Search code examples
gmailsitecore

Sending Sitecore emails through Gmail


I'm trying to make Sitecore send messages through a gmail-account but it wont work. This is my settings in web.config:

  <setting name="MailServer" value="smtp.gmail.com" />
  <!--  MAIL SERVER USER
        If the SMTP server requires login, enter the user name in this setting
  -->
  <setting name="MailServerUserName" value="[email protected]" />
  <!--  MAIL SERVER PASSWORD
        If the SMTP server requires login, enter the password in this setting
  -->
  <setting name="MailServerPassword" value="secret" />
  <!--  MAIL SERVER PORT
        If the SMTP server requires a custom port number, enter the value in this setting.
        The default value is: 25
  -->
  <setting name="MailServerPort" value="587" />

And this is the error from the log:

6068 09:14:57 ERROR Failed to send analytics report
Exception: System.Net.Mail.SmtpException
Message: The SMTP server requires a secure connection or the client was not authenticated. The server response was: 5.7.0 Must issue a STARTTLS command first.     u9sm3416817eeh.17
Source: System
at System.Net.Mail.MailCommand.CheckResponse(SmtpStatusCode statusCode, String response)
at System.Net.Mail.MailCommand.Send(SmtpConnection conn, Byte[] command, String from)
at System.Net.Mail.SmtpTransport.SendMail(MailAddress sender, MailAddressCollection recipients, String deliveryNotify, SmtpFailedRecipientException& exception)
at System.Net.Mail.SmtpClient.Send(MailMessage message)
at Sitecore.MainUtil.SendMail(MailMessage message)
at Sitecore.Analytics.Reports.ReportMailer.Mail(String exportedReportFileName, IEnumerable`1 recipients, String reportTitle, Boolean embedFile, Boolean deleteFile)

I know that it has something to do with gmail requiring some kind of secure connection but how do I make Sitecore provide this?


Solution

  • Message: The SMTP server requires a secure connection or the client was not authenticated. The server response was: 5.7.0 Must issue a STARTTLS command first.

    gmail requires TLS connection. Can try looking into stunnel.

    Anyways, serverfault or superuser.com is probably more appropriate.