I'm trying to configure ELMAH to send emails but I'm getting the following error:
Server Error in '/' Application.
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. 59sm11486886otw.9 - gsmtp
I've seen several posts for this same error but none of the suggestions have worked.
ELMAH is logging errors to SQL Server.
Additionally, I am able to send SMTP mail using the same credentials that ELMAH uses so I don't think I have an authentication error:
MailMessage mailx = new MailMessage();
mailx.To.Add("mySendTo");
mailx.From = new MailAddress("mySendFrom");
mailx.Subject = "My Subject";
mailx.Body = string.Format("My email body");
mailx.IsBodyHtml = true;
SmtpClient smtpx = new SmtpClient();
smtpx.Host = "smtp.gmail.com";
smtpx.Port = 587;
smtpx.UseDefaultCredentials = false;
smtpx.Credentials = new System.Net.NetworkCredential("MyLoginUser", "MyLoginPwd");
smtpx.EnableSsl = true;
smtpx.Send(mailx);
Web.Config contains the folowing ELMAH information:
<configuration>
<configSections>
<section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
<sectionGroup name="elmah">
<section name="security" requirePermission="false" type="Elmah.SecuritySectionHandler, Elmah" />
<section name="errorLog" requirePermission="false" type="Elmah.ErrorLogSectionHandler, Elmah" />
<section name="errorMail" requirePermission="false" type="Elmah.ErrorMailSectionHandler, Elmah" />
<section name="errorFilter" requirePermission="false" type="Elmah.ErrorFilterSectionHandler, Elmah" />
</sectionGroup>
</configSections>
<appSettings>
<add key="elmah.mvc.disableHandler" value="false" />
<add key="elmah.mvc.disableHandleErrorFilter" value="false" />
<add key="elmah.mvc.requiresAuthentication" value="true" />
<add key="elmah.mvc.IgnoreDefaultRoute" value="false" />
<add key="elmah.mvc.allowedRoles" value="*" />
<add key="elmah.mvc.allowedUsers" value="developer1@aaa.com, developer2@aaa.com" />
<add key="elmah.mvc.route" value="elmah" />
<add key="elmah.mvc.UserAuthCaseSensitive" value="true" />
</appSettings>
<httpModules>
<add name="ErrorLog" type="Elmah.ErrorLogModule, Elmah" />
<add name="ErrorMail" type="Elmah.ErrorMailModule, Elmah" />
<add name="ErrorFilter" type="Elmah.ErrorFilterModule, Elmah" />
</httpModules>
<modules>
<remove name="FormsAuthentication" />
<add name="ErrorLog" type="Elmah.ErrorLogModule, Elmah" preCondition="managedHandler" />
<add name="ErrorMail" type="Elmah.ErrorMailModule, Elmah" preCondition="managedHandler" />
<add name="ErrorFilter" type="Elmah.ErrorFilterModule, Elmah" preCondition="managedHandler" />
</modules>
<system.net>
<mailSettings>
<smtp deliveryMethod="Network">
<network host="smtp.gmail.com" port="587" userName="MyUserName" password="MyUserPwd" defaultCredentials="false"/>
</smtp>
</mailSettings>
</system.net>
<elmah>
<errorLog type="Elmah.SqlErrorLog, Elmah" connectionStringName="DefaultConnection" />
<security allowRemoteAccess="yes" />
<errorMail
from="mySendFrom@gmail.com" to="mySendTo" subject="MySubject" async="false" smtpPort="587" useSSL="true"/>
</elmah>
</configuration>
The ELMAH version in use is 1.2.13605.0
I have tried it in the Dev Environment, which does not utilize SSL and in the in the Test Environment, which has an SSL cert. Both having same error.
I have tried many of the recommendations found in SO posts but none have worked. Here are some of them:
Unable to configure mail for Elmah
Send email from Elmah?
Elmah not sending Email
elmah - cannot email exceptions