1

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);
Community
  • 1
  • 1
Coral Doe
  • 1,925
  • 3
  • 19
  • 36
  • 2
    Probably a matter for serverfault. – Alfabravo Oct 29 '12 at 16:58
  • If it's more suited for serverfault, please don't vote to close my question. There are many other questions that were not closed here on SO, related to setting up the IIS SMTP server. Flag this question to be migrated to serverfault, this would be of more help for me ans others. – Coral Doe Oct 30 '12 at 07:25

1 Answers1

0

Can you post your code that sends the emails, or at least confirm that it's not overriding the IIS settings? Are different SMTP properties set at different levels - possibly at the server and at the website?

You can try something like this, which should allow the emails to be sent immediately by the SMTP service instead of being stored in the pickup directory:

var smtpClient =
    new SmtpClient("127.0.0.1", 25)
    {
        UseDefaultCredentials = false
    };
StronglyTyped
  • 2,134
  • 5
  • 28
  • 48
  • I added the code examples. Is your code equivalent with setting `Network` as `SmtpDeliveryMethod`? Because the setting `Network` didn't worked on my examples. – Coral Doe Mar 04 '13 at 07:52