Devlico.Us
CodeBetter.Com
RSS 2.0 via Feedburner
           Do you Twitter? Follow us @devlicious

Mike Nichols - Son Of Nun Technology



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'.


Published May 07 2008, 10:29 PM by Michael Nichols
Filed under: , ,

Comments

Vaclav Elias said:

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.

# May 8, 2008 5:07 AM

Leave a Comment

(required)  
(optional)
(required)  

Enter the numbers above:
Add

About Michael Nichols

I live in Phoenix, AZ and I like long walks on the beach and snuggling...er...wait....wrong text box. I have a wonderful wife and two beautiful children . Jesus has been so gracious to me. I have my master's in music performance-percussion and had a good career playing a wide variety of musics before setting out on software dev. Check out Devlicio.us!

Our Sponsors

Red-Gate!

Proudly Partnered With