无法为Elmah配置邮件 [英] Unable to configure mail for Elmah

查看:52
本文介绍了无法为Elmah配置邮件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下配置文件片段

<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>
 <mailSettings>
      <smtp deliveryMethod="Network">
        <network host="smtp.gmail.com"
           port="587"
           userName="example@gmail.com"
           password="password" />
        </smtp>
      </mailSettings>
  </system.net>
 <elmah>
    <errorMail
              from="example1@gmail.com"
              to="example2@gmail.com"
              sync="true"
              smtpPort="0"
              useSsl="true"
            />
  </elmah>

我用适当的东西替换了example1等。现在,我遇到以下问题:-
1)为什么不起作用?
2)我该如何调试?
3)我需要一种永久性的方法来调试web.config或至少获取一些代码,当配置文件中出现问题时,这些代码将发出一些错误消息。

I have replaced the example1 etc.. with proper stuff . Now, i have the following issues: - 1) Why is it not working ? 2) How do i debug it ? 3) I need a permanent way to debug the web.config or atleast some code which will emit some error message when there is something wrong in the config file .

推荐答案

尝试一下:

<?xml version="1.0"?>
<configuration>
    <configSections>
        <!--ELMAH-->
        <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"/>   
        <!-- set the smtpPort attribute to "0". Doing so will cause ELMAH to use the port defined per the <system.net> settings -->
        <errorMail from="example1@gmail.com" to="example2@gmail.com" subject="ERROR(test):" async="false" smtpPort="0" useSsl="true" />
    </elmah>
    <!--System.net Mail setup-->
    <system.net>
        <mailSettings>
            <smtp deliveryMethod="network">
                <network host="smtp.gmail.com" port="587" userName="example1@gmail.com" password="..." />
            </smtp>
        </mailSettings>
    </system.net>
    <appSettings>
    ...
 </appSettings>
    <connectionStrings>
        ...     
    </connectionStrings>
    <system.web>
        <compilation debug="true">
            <assemblies>
                ...
        </compilation>
        <customErrors mode="Off"/>
        ...
        <httpHandlers>
            ...
            <!--ELMAH-->
            <add verb="POST,GET,HEAD" path="MyErrorPage/elmah.axd" type="Elmah.ErrorLogPageFactory, Elmah"/>            
        </httpHandlers>
        <httpModules>
            ...
            <!-- ELMAH: Logging module -->
            <add name="ErrorMail" type="Elmah.ErrorMailModule, Elmah"/>
            <!-- <add name="ErrorLog" type="Elmah.ErrorLogModule, Elmah"/> -->
            <!--<add name="ErrorFilter" type="Elmah.ErrorFilterModule, Elmah"/>-->
        </httpModules>
        <httpRuntime maxRequestLength="458292"/>
        <authentication mode="Forms">
            ...
        </authentication>
    ...
    </system.web>
    <location path="MyErrorPage.aspx">
        <system.web>
            <authorization>
                <allow users="?"/>
            </authorization>
        </system.web>
    </location> 
    <!-- 
        The system.webServer section is required for running ASP.NET AJAX under Internet
        Information Services 7.0.  It is not necessary for previous version of IIS.
    -->
    <system.webServer>
        <validation validateIntegratedModeConfiguration="false"/>
        <modules runAllManagedModulesForAllRequests="true">
            ...
            <!-- ELMAH-->
            <add name="ErrorLog" type="Elmah.ErrorLogModule, Elmah"/> 
            <add name="ErrorMail" type="Elmah.ErrorMailModule, Elmah"/>
            <add name="ErrorFilter" type="Elmah.ErrorFilterModule, Elmah"/>
        </modules>
        <handlers>
            ...
            <!--ELMAH-->
            <add name="Elmah" verb="POST,GET,HEAD" path="MyErrorPage/elmah.axd" type="Elmah.ErrorLogPageFactory, Elmah"/>           
        </handlers>
    </system.webServer>
    <runtime>       
        <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
            ...
        </assemblyBinding>
    </runtime>
    <location path="MyErrorPage/elmah.axd">
        <system.web>
      <authorization>
        <deny users="?"/>
        <allow users="?"/>
      </authorization>
        </system.web>
    </location>  
</configuration>

这篇关于无法为Elmah配置邮件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆