2011-10-28 12 views
5

Mam następujący plik konfiguracyjny snippetNie można skonfigurować pocztę 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="[email protected]" 
      password="password" /> 
     </smtp> 
     </mailSettings> 
    </system.net> 
<elmah> 
    <errorMail 
       from="[email protected]" 
       to="[email protected]" 
       sync="true" 
       smtpPort="0" 
       useSsl="true" 
      /> 
    </elmah> 

jakie otrzymuje example1 etc .. z właściwego materiału. Teraz mam następujące problemy: - 1) Dlaczego to nie działa? 2) Jak mogę to debugować? 3) Potrzebuję stałego sposobu debugowania web.config lub przynajmniej niektóre kod, który będzie emitować komunikat o błędzie, gdy coś jest nie tak w pliku konfiguracyjnym.

Odpowiedz

10

Spróbuj tego:

<?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="[email protected]" to="[email protected]" 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="[email protected]" 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> 
+1

useSSL = "true" wprowadził mnie w dobrym kierunku, dzięki! – Francisco

2

Spróbuj ten sposób

<system.net> 
    <mailSettings> 
     <smtp deliveryMethod="Network"> 
     <network host="smtp.gmail.com" defaultCredentials="false" 
     port="587" userName ="[email protected]" password="yourMailPassword" /> 
     </smtp> 
    </mailSettings> 
    </system.net> 
+1

próbowałem, ale to nie działa .. –

Powiązane problemy