Profile photo
Submitted by Sam Buchana
on July 30th, 2012 at 08:31:46 EST

Can not send email using SMTP server in IIS 7.5 and Windows 2008

We are using ASP.NET 4.0 and use SMTP server to send email. We recently upgraded our server from Windows 2003 with IIS 6 to Windows 2008 server with IIS 7.5. Everything seems to be working fine with the server upgrade but whenever ASP.NET application try to send email, there is exception as "System.UnauthorizedAccessException: Access is denied". I am not sure what Access is denied while sending email.

I would appreciate a solution if anyone had come across this issue.

Profile photo
Replied by Bikram Shrestha
on July 30th, 2012 at 08:36:16 EST
Did you try this to configure SMTP in IIS 7?

Profile photo
Replied by SBajra
on July 30th, 2012 at 08:38:25 EST
We had similar issue and what resolved the issue was by granting read/write permission to IIS_IUSRS group to "MailRoot" folder which is normally under (c:\inetpub). By assigning read/write permission to MailRoot folder, all the child folder like Pickup will have inherited read/write access as well. For some reason, we need to explicitly grant read/write access to MailRoot/Pickup folder for ASP.NET to send email.
I hope this helps. IIS_IUSRS is new user group introduced in IIS 7.
Accepted Answer

Profile photo
Replied by Sam Buchana
on July 30th, 2012 at 13:20:28 EST
Granting read/write file level permission to MailRoot folder resolved my issue. Now I can send email in Windows 2008 using ASP.NET 4.0.
Thanks for the tip.