2013-04-12 54 views
4

我在Mvc4 application.My的web.config實現ELMAH如下: -ELMAH不發送電子郵件

<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="[email protected]" to="[email protected]" 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.I可以通過鍵入URL看到錯誤本地主機://elmah.axd.But我沒有得到mail.Pls幫助

回答

3

嘗試用async="false"

<errorMail 
    from="[email protected]" 
    to="[email protected]" 
    subject="Elmah Report" 
    async="false" 
    smtpServer="mail.assert.in" /> 
+0

我得到了一個異常 「SmtpException是由用戶代碼未處理的」。郵件發送失敗。 – Mizbella

+1

好的,所以看看InnerException。也許你在配置的SMTP服務器時遇到問題。 –

+1

你..這是我的SMTP服務器的問題。謝謝你的答案。 – Mizbella

相關問題