0

We built an ASP.NET app that we deployed on the client's server, using their SMTP server.

I'm trying to have Elmah send error emails using the ErrorEmailModule. This uses the SMTP settings as configured in the web.config, but somehow sending emails is not working (nothing is being sent).

The SMTP settings are configured like this:

  <system.net>
    <mailSettings>
      <smtp from="support@xxxxxx.nl">
        <network host="xxxxxxx.management.local" port="25" enableSsl="true" defaultCredentials="true"/>
      </smtp>
    </mailSettings>
  </system.net>

To test if this is a problem with Elmah or with the config I created a little test application that uses the same setting and tries to send an email:

string from = "support@xxxxxxxx.nl";
string to = ConfigurationManager.AppSettings["ErrorReportingEmail"];
var message = new MailMessage(from, to, "Test", "Test");
var smtpClient = new SmtpClient();

smtpClient.Send(message);

This doesn't work either. SmtpClient doesn't throw an error, it just acts like it sent an email, but I'm not receiving anything.

I then tried sending an email using 2 different email testing tools, called MailTester and MultiMail, I entered the same SMTP settings, and they can send emails just fine.

So my question is: why can I send emails from these mail tester apps but not from my ASP.NET app?

Leon Cullens
  • 12,276
  • 10
  • 51
  • 85
  • Try following answer http://stackoverflow.com/a/32336/6170142 – Kamalesh Wankhede Aug 29 '16 at 08:35
  • @user12572 please just read my question. That answer doesn't answer my question at all. – Leon Cullens Aug 29 '16 at 08:37
  • Are the emails in the unsent outbox of the sending email account? Is there an error log on the email server? Is there an event viewer log on the application server from a possible uncaught exception? Does your code have an empty catch block which could be swallowing an exception, so it only appears to complete with no error? If you are debugging, is it possible you have not waited long enough for a timeout period to elapse before an error message is returned? – user1666620 Aug 29 '16 at 08:42
  • @user1666620 how can I check those first 3 things? As for your last question: no, exceptions are not swallowed. There just isn't an exception. – Leon Cullens Aug 29 '16 at 08:47
  • @LeonCullens I added a sentence to my comment : "If you are debugging, is it possible you have not waited long enough for a timeout period to elapse before an error message is returned?" – user1666620 Aug 29 '16 at 08:47

1 Answers1

0

try this set deliveryMethod = network.

   <system.net>
    <mailSettings>
      <smtp from="support@xxxxxx.nl" deliveryMethod="Network">
        <network host="xxxxxxx.management.local" port="25" enableSsl="true" defaultCredentials="true"/>
      </smtp>
    </mailSettings>
  </system.net>
Sim Tsai
  • 33
  • 1
  • 5