elmah / Elmah

Error Logging Modules & Handlers for ASP.NET
https://elmah.github.io/
Apache License 2.0
310 stars 63 forks source link

Using "SpecifiedPickupDirectory" in web.config will not save emails to specified folder #358

Open atifaziz opened 9 years ago

atifaziz commented 9 years ago

Steps that will reproduce the problem:

1. Add the following section to your web.config in place of any other similar section:

<system.net>
    <mailSettings>
        <smtp deliveryMethod="SpecifiedPickupDirectory" from="error@domain.co.uk">
            <specifiedPickupDirectory pickupDirectoryLocation="C:\{Path}\App_Data\"/>
        </smtp>
    </mailSettings>
</system.net>

2. Trigger an exception that was previously being emailed by Elmah.

I would expect the email that I would have received to be saved in the location specified in the web.config. Instead, the error is logged but no email is saved. I have tried the App_Data path as well as a new directory in the root of my C:\ drive, both with no success. I have set up a simple email method separate from ELMAH and this does save a copy of the email message to the specified directory.


Originally reported on Google Code with ID 358

Reported by me@marcpell.com on 2014-04-08 08:23:55

atifaziz commented 9 years ago

Is the {Path} replaced at runtime? I don't think .NET Framework recognises and replaces the {Path} token. Does the account under which the web site with ELMAH running have permissions to write to C:\ and App_Data of the web site? I'm assuming that the separate test your ran was under a different identity that did have permissions?


Reported by @atifaziz on 2014-04-08 20:01:00

atifaziz commented 9 years ago

{path} is just a manual replacement to hide my local path in my description here rather than the actual path which I am confident is correct as sending normal emails works just fine. The manual test was performed using them same account into the app_data folder of the app and works as expected but then triggering an exception doesn't result in an email being saved. Reverting the emails back to actually sending and triggering the same exception results in ELMAH sending an email successfully so it is just the saving of an email to the path via ELMAH that isn't working for me.


Reported by me@marcpell.com on 2014-04-08 20:05:53

atifaziz commented 9 years ago

Have you tried downloading and running the demo app that also writes error mails to a local directory? Try the following:

Do you see error mail (EML) files being produced by the demo web?


Reported by @atifaziz on 2014-04-08 20:40:13

atifaziz commented 9 years ago

I'm sure that pickupDirectory works, i have it configured so and there's no problem. I prefer to keep setting in system.net, cause so i do not need to configure my mail client + elmah - i do not like duplicities :D

<elmah>
    <security allowRemoteAccess="true" />
    <errorLog type="Elmah.SqlErrorLog, Elmah" connectionStringName="FinIS" />
    <!--
      NOTE: additional errorMail settings if we want to have other values than in system.net/mailSettings/smtp/host
      smtpServer="mySmtp" smtpPort="25" userName="errors@email.com" password="password"
useSsl="true" 
      -->
    <errorMail
      from="sender@mail.sk"
      to="recipient@mail.sk"
      subject="ELMAH Error from my system"
      async="true" />

 <system.net>
    <mailSettings>
      <!-- NOTE: set delivery method to: Network to begin send mails -->
      <smtp deliveryMethod="SpecifiedPickupDirectory"
            from=""Your name" <from@mail.sk>"
            >
        <specifiedPickupDirectory pickupDirectoryLocation="c:\temp\mail\" />
        <network
          host="mail.hostmaster.sk" port="465"
          userName="sender@mail.sk" password="pwd"
          enableSsl="true"
          />
      </smtp>
    </mailSettings>
  </system.net>

Reported by balazs.hideghety on 2014-08-07 15:40:50

AdalyatNazirov commented 7 years ago

It works for me as well