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.