tags:

views:

115

answers:

2

In my web app (ASP.NET MVC), I send an email using the following:

        MailMessage msg = new MailMessage("[email protected]", "somewhere@recipient");
        msg.Body = "Message body";
        msg.IsBodyHtml = false;
        SmtpClient client = new SmtpClient();
        msg.Subject = "Subject";
        client.Send(msg);

My system.net Mail Settings are as follows in web.config:

  <system.net>
    <mailSettings>
      <smtp deliveryMethod="Network" from="[email protected]">
        <network host="mail.domain.com" port="25" defaultCredentials="false" userName="[email protected]" password="mypassword" />
      </smtp>
    </mailSettings>
  </system.net>

This sends out the email fine. The only issue I've experienced is that the email is sent and received within 2-3 minutes of the function call.

I've seen this on two hosts that use SmarterMail, and before I ask the good folks at serverfault.com and then question my host, I wanted to know if theres anything coding-wise that could be causing this 2-3 minute delay.

It may seem negligible, but I as a web surfer, hate it when emails that I'm supposed to get take long, specially if they have crucial information like login information.

+3  A: 

i think this is about your servers network traffic.

Ozan BAYRAM
A: 

There are two simple ways to test if the delivery delay is caused by your program or not:

  1. Send a mail by some other means, e.g., by starting a mail client or using some command-line mail client (using the same SMTP server). If the mail shows the same delay, your software has nothing to do with it.

  2. Alternatively, you could look into the headers of one of the received mails: They should show now much time the mail spends on every mail server along the route. If you have trouble interpreting the headers, add them to your question or have a look at one of the tutorials online.

(BTW, I share Ozan's assumption that the delay is caused by the mail server rather than by your program.)

Heinzi