ELMAH - 在生产环境中未收到电子邮件

ELMAH - Email not received in production environment

我已经集成了用于记录错误的 ELMAH 库。我已经集成了用于获取错误列表但无法获取这些错误的电子邮件代码。谁能帮助我。下面是我在web.config

中的配置代码

Web.config 文件

<?xml version="1.0" encoding="utf-8"?>
<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>

  <system.web>
    <compilation debug="true" targetFramework="4.5.2" />
    <httpRuntime targetFramework="4.5.2" />
    <httpModules>
      <add name="ErrorLog" type="Elmah.ErrorLogModule, Elmah" />
      <add name="ErrorMail" type="Elmah.ErrorMailModule, Elmah" />
      <add name="ErrorFilter" type="Elmah.ErrorFilterModule, Elmah" />
    </httpModules>
  </system.web>

  <system.webServer>
    <validation validateIntegratedModeConfiguration="false" />
    <modules>
      <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.webServer>

  <elmah>

    <errorLog type="Elmah.XmlFileErrorLog, Elmah" logPath="~/ElmahLog" />
    <errorMail from="error@devtracker.com"
     to="ankitkanojia.rs@gmail.com"
     subject="Devtracker - Error occurs"
     async="true" />

    <security allowRemoteAccess="false" />
  </elmah>


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

</configuration>

在查看您的问题后,我发现您只是忘记添加电子邮件设置。在您的 web.config 中添加以下行。确保更改主机名、端口、用户名和密码。

<system.net>
    <mailSettings>
      <smtp deliveryMethod="Network">
        <network host="host address" port="12345" userName="username here" password="password here"/>
      </smtp>
    </mailSettings>
</system.net>