Images in this post missing? We recently lost them in a site migration. We're working to restore these as you read this. Should you need an image in an emergency, please contact us at imagehelp@codebetter.com
Configuring IIS 6.0 to send mail via SMTP for asp.net applications

Enabling smtp services for IIS is well documented, but configuring in my environment was more difficult than I would have thought it would be... So this post is partly a note for me as we will be changing out gear soon.

Our environment is not very exotic...a box acting as an web server, and another box acting as an exchange server. Both are running Win2003.

First, smtp services must obviously be enabled/running. Here is how.

Next, in IIS, select the new SMTP Virtual server node and right-click/Properties/Access/Relay. Be sure 'Only the list below' is selected and add '127.0.0.1' (localhost) to your Computers Access list . Finally, deselect 'Allow all computers which successfully authenticate...'. Be very careful not to turn your server into a relay server unless you like being blacklisted .

Now, at this point I was able to get my mail sent to domains outside my own. So if my webserver was webbox.mydomain.com and it sent mail to mygmail@gmail.com then all worked just fine. But I was unable to send mail internally to other mail accounts (mydomain.com).

What I failed to do was set up a SMART HOST to route mail to my exchange box.

To do that, right-click the smtp node in iis/Properties/Delivery/Advanced. Enter the name of the server hosting exchange and deselect 'attempt direct delivery before sending to smart host'.


Posted 05-07-2008 10:29 PM by Michael Nichols
Filed under: , ,

[Advertisement]

Comments

Vaclav Elias wrote re: Configuring IIS 6.0 to send mail via SMTP for asp.net applications
on 05-08-2008 5:07 AM

Hi Mike,

I was able doing this without installing (SMTP services) and setting  SMTP Virtual Server. We have got also the same boxes.

I have only set this in my web.config:

   <system.net>

       <mailSettings>

           <smtp deliveryMethod="Network">

               <network password="passoword" userName="username" host="exchangeServerIP"/>

           </smtp>

       </mailSettings>

   </system.net>

This works both for external and internal email sending. Not sure which way is recommended. Obviously your solution works globally. I have to set this for all websites unless I would put it into machine.config.

We have set also the relay IP address of the web server on the exchange server and some configuration on firewall as the web server is in DMZ.

Maybe this info will be also handy for someone..

Cheers

Vaso.

Stephan wrote re: Configuring IIS 6.0 to send mail via SMTP for asp.net applications
on 02-12-2009 10:25 PM

Hi Mike

I was having the same issue as you, and followed your step and it solved my problem perfectly.  Thank you.

Cheers,

- Stephan

george wrote re: Configuring IIS 6.0 to send mail via SMTP for asp.net applications
on 06-22-2009 6:23 PM

Vaso, this method works better than your web.config method when the mail server is physically located on a different server.

Sending mail to an external mail server directly from asp.net will not queue the message if the mail server is down, instead it will fail.

About The CodeBetter.Com Blog Network
CodeBetter.Com FAQ

Our Mission

Advertisers should contact Brendan

Subscribe
Google Reader or Homepage

del.icio.us CodeBetter.com Latest Items
Add to My Yahoo!
Subscribe with Bloglines
Subscribe in NewsGator Online
Subscribe with myFeedster
Add to My AOL
Furl CodeBetter.com Latest Items
Subscribe in Rojo

Member Projects
DimeCasts.Net - Derik Whittaker

Friends of Devlicio.us
Red-Gate Tools For SQL and .NET

NDepend

SlickEdit
 
SmartInspect .NET Logging
NGEDIT: ViEmu and Codekana
LiteAccounting.Com
DevExpress
Fixx
NHibernate Profiler
Unfuddle
Balsamiq Mockups
Scrumy
JetBrains - ReSharper
Umbraco
NServiceBus
RavenDb
Web Sequence Diagrams
Ducksboard<-- NEW Friend!

 



Site Copyright © 2007 CodeBetter.Com
Content Copyright Individual Bloggers

 

Community Server (Commercial Edition)