tags:

views:

82

answers:

3

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?

+1  A: 

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.

fseto
Thank you, Stunnel worked as a charm!
Zooking
+1  A: 

The SendMail function in Sitecore.MainUtil does not have an option to set SmtpClient.EnableSsl to True. For now, it looks like you will need to find another SMTP server to use.

You may want to log this as a feature request with Sitecore.

Sean Kearney
A: 

I am successfully connect to GMAIL using Email Campaign module which has the STARTTLS feature. Here are my settings:

     <!--Set it to "true" if you want use the SMTP settings below. You should purchase the right of using the "UseLocalMTA" setting first.-->
     <setting name="UseLocalMTA" value="true" />
     <setting name="SMTP.Server" value="smtp.gmail.com" />
     <setting name="SMTP.Port" value="587" />
     <setting name="SMTP.LoginDomain" value="" />
     <setting name="SMTP.UserName" value="[email protected]" />
     <setting name="SMTP.Password" value="12345" />
     <setting name="SMTP.AuthMethod" value="PLAIN" />
     <setting name="SMTP.StartTLS" value="true" />
Alex Shyba
Can you use the ECM to send out scheduled emails from OMS?
Zooking
only via a customization. I see analytics:emailreport command in Analytics.Config. You can override it and send an email from ECM programmatically using the following code: var message = Sitecore.Modules.EmailCampaign.HtmlMail.FromItem(messageItem);message.CollectRelativeFiles();message.Body = ReplaceTokens(message.GetMessageBody(), fields); message.To = to; message.Subject = ReplaceTokens(message.Subject, fields); var manager = new AsyncSendingManager(message); manager.SendQuickTestMessage();
Alex Shyba