2016-08-06 7 views
2

私は電子メールを送信するELMAHを設定しようとしているが、私は次のエラーを取得しています:ELMAHからメールを送る方法は?

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

私はこの同じエラーにはいくつかの記事を見てきましたが、のいずれの方法でも働いていません。

ELMAHはSQL Serverにエラーを記録しています。

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はfolowing ELMAHの情報が含まれています:

また、私はELMAHはそう使用するのと同じ資格情報を使用してSMTPメールを送信することができる午前私は認証エラーを持っていないと思います私はテスト環境でSSLを利用しないのDev環境にし、それを試してみました1.2.13605.0

<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="[email protected], [email protected]" /> 
    <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="[email protected]" to="mySendTo" subject="MySubject" async="false" smtpPort="587" useSSL="true"/> 
    </elmah> 

</configuration> 

使用中のELMAHのバージョンがありますSSL証明書を持っています。どちらも同じエラーがあります。

私はSOの投稿にある多くの推奨事項を試しましたが、どれもうまくいきませんでした。
Unable to configure mail for Elmah
Send email from Elmah?
Elmah not sending Email
elmah - cannot email exceptions

答えて

1

私はそれはあなたの問題を修正するかどうかわからないんだけど、私はELMAH Configuration Validatorを使用して、あなたのweb.configファイルを検証してみました。ここではそれらのいくつかはあります。値が「はい」とそのデータ型「http://www.w3.org/2001/XMLSchema:boolean」に応じて、無効である - - 文字列「yes」に有効なブール値ではありません

  • 「allowRemoteAccess」属性が無効である:それは次のような結果になります。
  • 'useSSL'属性が宣言されていません。

allowRemoteAccessを 'true'に変更することを検討できますが、 'yes'もおそらく動作します。私が結果で見ているのは、 'useSSL'属性です。その名前を 'useSsl'に変更して、それが機能するかどうか確認してください。バリデーターは 'useSSL'を受け取りますが、 'useSSL'は受け入れません。

+0

私はuseSSLを使用してSSLを使用していました。助けてくれてありがとう。 – John

関連する問題