【问题标题】:Elmah not sending EmailElmah 不发送电子邮件
【发布时间】:2013-04-04 18:55:13
【问题描述】:

我已经在我的 Mvc4 应用程序中实现了 Elmah。我的 web.config 如下:-

<configuration>
  <configSections>
      <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>

    <elmah>
        <security allowRemoteAccess="1" />
        <errorLog type="Elmah.XmlFileErrorLog, Elmah" logPath="~/App_Data"/>
        <errorMail from="test@test.in" to="test1@test.in" subject="Elmah Report" async="true" smtpServer="mail.test.in" />            
    </elmah>

  <connectionStrings>
    <add name="DefaultConnection" providerName="System.Data.SqlClient" connectionString="Data Source=.\SQLEXPRESS;Initial Catalog=aspnet-Mvcjquery-20130225111502;Integrated Security=SSPI" />
  </connectionStrings>   

    <system.web>
      <httpHandlers>
          <add verb="POST,GET,HEAD" path="elmah.axd" type="Elmah.ErrorLogPageFactory, Elmah" />         
      </httpHandlers>

      <httpModules>
          <add name="ErrorLog" type="Elmah.ErrorLogModule, Elmah"/>
          <add name="ErrorMail" type="Elmah.ErrorMailModule, Elmah"/>

     </httpModules>        
  </system.web>

  <system.webServer>
      <validation validateIntegratedModeConfiguration="false"/>
      <modules>
          <add name="Elmah.ErrorLog" type="Elmah.ErrorLogModule, Elmah" preCondition="managedHandler" />
          <add name="Elmah.ErrorMail" type="Elmah.ErrorMailModule" preCondition="managedHandler" />
      </modules>

      <handlers>
          <add name="Elmah" path="elmah.axd" verb="POST,GET,HEAD" type="Elmah.ErrorLogPageFactory, Elmah" preCondition="integratedMode" />         
      </handlers>
  </system.webServer>    

</configuration>

我添加了通过 elmah 发送电子邮件的代码。我可以通过输入 url localhost://elmah.axd 来查看错误。但是我没有收到邮件。请帮助

【问题讨论】:

    标签: asp.net-mvc-3 asp.net-mvc-4 elmah


    【解决方案1】:

    试试async="false":

    <errorMail 
        from="join@assert.in" 
        to="twinkle@assert.in" 
        subject="Elmah Report" 
        async="false" 
        smtpServer="mail.assert.in" />
    

    【讨论】:

    • 我得到一个异常“SmtpException 未被用户代码处理”。发送邮件失败。
    • 好的,看一下 InnerException。可能你配置的 SMTP 服务器有问题。
    • ya..这是我的 SMTP 服务器的问题。谢谢您的回答。
    • 将 async 设置为 false 是否会改变用户关注的网站操作?也就是说,Elmah 还会默默地失败吗?
    猜你喜欢
    • 2010-09-07
    • 2013-02-10
    • 1970-01-01
    • 1970-01-01
    • 2016-12-12
    • 2012-03-30
    • 1970-01-01
    • 1970-01-01
    • 2011-01-01
    相关资源
    最近更新 更多