Blogs:

Configuring Windows SMTP Server on Windows 2008 for Relay

Mark

October 23, 2010 / 9 Comments

My SMTP mail server requires that email be sent with TLS encryption and on port 587.  This makes it problematic for Team Foundation Server (TFS) to send emails directly.  To work around the problem, I installed the Windows 2008 SMTP Server service and configured it for relaying to my real SMTP mail server. 

Install SMTP Server

To begin, launch Server Manager and add the SMTP Server feature.

image

This includes a dialog to add some additional items.

image

Click Add Required Features and, after the dialog closes, click Next > followed by Install.

The same can be done from the command line using:

Configuring the SMTP Service to Auto-Start

Unfortunately, the service is not configured to auto-start by default so you need to go into the services to change this:

image

To perform the same action from the command line use the following PowerShell commands:

From DOS you could use sc.exe.

Configuring the SMTP Service for Routing to Alternate SMTP Server

Finally, you need to configure the SMTP Server to redirect to an alternate SMTP server (assuming it is not sending email directly).  This involves settings in both IIS 7.0 and IIS 6.  Open Internet Information Server (IIS 7.0) and select the server node

Internet Information Services (IIS) Manager (IIS 7.0)

  1. From inside Internet Information Services (IIS) Manager, browse to the server’s SMTP E-mail feature and open it.
    image
  2. Inside the SMTP E-mail windows, enter in the “send from” email address, the remote SMTP server DNS name (or IP address) and the remote server port.  In addition, select Specify credentials and enter the credentials required to connect to the remote SMTP server.
    image

To perform the same action from the command line use the following commands (Powershell is optional):

Internet Information Services (IIS) 6.0 Manager

  1. Launch Internet Information Services (IIS) 6.0 Manager locate the [SMTP Virtual Server #] node and open up the Properties dialog.
    image
    As shows, I just added 127.0.0.1 so that I was only enabling the current box to send via this SMTP Server but you can also add a group of computers by subnet or an entire domain.
  2. Next, navigate to the Delivery tab and modify the settings for all three buttons, Outbound Security…, Outbound connections…, and Advanced….
    image
  3. For Outbound Security, switch to Basic Authentication and enter the remote SMTP Server credentials in addition to checking TLS encryption.
    image
  4. On the Outbound Connections tab, switch the TCP port to 587 (or whatever port you need).
    image
  5. Finally, on the Advanced Delivery tab, identify the Smart host as the DNS (or IP address) of the remote SMTP server.
    image
    For the Fully-qualified domain name refers to the server you are configuring, the one the SMTP-Service is being configure on.

Unfortunately, I didn’t come up with the command line for this particular action.  I did find two leads as to where there may be a command line solution, however:

  1. The first is the smtpsetup.exe program (located in %windir%\system32\inetsrv\).  This program takes an INF file with the configuration information. 
  2. Secondly, the configuration information itself is stored in %windir%\System32\Inetsvr\Metabase.xml

Even though figuring out the final command line seemed within reach, I had no information as to how the password was encrypted and stored into the file and without much to go on, I decided to move on.

 

Command Line

Combining all the command lines together (except for the IIS 6.0 configuration) yields the following:

AUTHOR: CATEGORY: .Net, TFS

9 Responses to “Configuring Windows SMTP Server on Windows 2008 for Relay”

  1. Robert says:

    Thanks Mark! You’re instructions were very helpful, especially with the command line for each step.

  2. Dirk says:

    Hi Mark,

    thanks a lot !
    Greetings from Germany.

    Dirk

  3. Mohammed says:

    Hi Mark,

    Hope you are doing good.

    I have installed the feature in Windows 7 with SP1. I am getting the following message but I am not receiving in my mailbox.

    Applied configuration changes to section “system.net/mailsettings/smtp” for “Machine/webroot/Apphost” at configuration path “machine/webroot”

    Regards n greetings from Saudi Arabia

  4. Jon says:

    Thank you very much Mark! Had a bit of a devil of a time before your article, but the UI step-through instructions provided the “ah-hah!” moment. Thank you also for the command line instructions; would love to try those out when time allows.

    [namaste’]

  5. John Athan says:

    This is the best and most thorough walkthrough on the web. Thanks for the help!

  6. Lolonga Lukaso says:

    Thank you so much this solved my problem with my reporting server.

  7. John Matteson says:

    Is there a way of loading a list of relay servers via PowerShell or VB script? I didn’t see it shown in the tutorial. I have approx. 280 hosts (mostly digital senders) that need to be added to a new SMTP relay host.

    • Mark Mark says:

      Hi John,
      You could place the script into a PowerShell Script Block and then execute it using Invoke-Command. That’s exactly what Invoke-Command is designed for.
      Mark

  8. Matt Linxwiler says:

    Nice article. I assume this would work if you just want to forward mail to another SMTP server but cannot change the MX record? I wouldn’t need all the auth stuff.

    MX points to Server A. Need to have SMTP on Server B. Have SMTP on A forward mail directly to B.

    Would that prevent SMTP on Server A from dropping any mail in the Drop folder? I wouldn’t want an app to even pick up the mail on that server.

    Thanks.

Leave a Reply


Contact Us
Email: info@IntelliTect.com
Phone: (509) 315-3400




Testimonials

“Mark recognizes that the Business is a key stake holder in the entire .NET conversion. He has helped to create a cooperative environment between the Business and Intellitect as we’ve partnered to make this a successful project.  Mark has a top-notch team that has supported both the technical and Business needs.”
- Shana, Liz and Tanya, Avista Utilities, Spokane, WA
CONTACT US: (509) 315-3400 | Info@IntelliTect.com | Jobs | Site Map