asp.net-mvc-3 - Elmah 不发送电子邮件

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

我已经在我的 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 来查看错误。但是我没有收到邮件。请帮助

最佳答案

试试 async="false" :

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

关于asp.net-mvc-3 - Elmah 不发送电子邮件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15968099/

相关文章:

asp.net-mvc-4 - Chrome 中的捆绑和缩小问题,但在 Mozilla 中运行良好

c# - ELMAH - 传递变量和其他文本?

c# - 带有 Razor 的 ASP.NET MVC 3 可重用表显示模板

c# - MVC3 应用程序中的通用 "back"按钮

forms - 如何在 MVC Razor 表单中显示计算字段?

c# - ASP.NET MVC 4 捆绑 - Debug模式下的单个文件 URL

asp.net-mvc - Elmah,转换为 .Net4 vs2010,在服务器 2008 上运行,不起作用

ajax - 对 azure 云服务的 ajax 调用的异常处理

asp.net-mvc-3 - 模型中的 MVC 3 和 Xml 属性数据

c# - 使用固定装置测试 Entity Framework