I have a Windows Server 8 machine with IIS7.
I have configured a SMTP server on IIS7, to be used by a .NET Web Application sending some notifications to the users of a system.
The SMTP server is configured to Deliver emails to SMTP server
, on port 25
, using localhost
, no authentication
.
My problem is that the emails are sent correctly, but not until after a day or even longer. I see the emails in the pick-up directory from wwwroot, but they just stay there. For the system it is quite important that the emails are sent immediately.
How can I ensure the emails are sent imediatelly?
I found a question which addressed a similar problem (in that case the emails didn't came off pick-up directory, in my case they are send after a day or so) Need help setup windows server 2008 SMTP server But the answer given is quite incomplete so I could not check if it will also solve my problem.
This is the code I use:
MailMessage mailMessage = new MailMessage();
mailMessage.To.Add(toEmail);
mailMessage.From = new MailAddress(fromEmail);
mailMessage.Subject = emailSubject;
mailMessage.Body = emailBody;
mailMessage.IsBodyHtml = true;
SmtpClient smtpClient = new SmtpClient();
smtpClient.DeliveryMethod = SmtpDeliveryMethod.PickupDirectoryFromIis;
smtpClient.Send(mailMessage);