Configuring IIS SMTP Relay with Office 365 Account

19 September 2017

Introduction

For my developer machines, I need a smtp server to test logging, monitoring and notification for the inSyca Suite.
Here I show you the steps to install and configure the IIS SMTP Server with an Office 356 account. I like this approach because I do not have to configure the credentials for the account in a ".config" file. In the local configuration files I can setup everything with the SMTP part pointing to the localhost.

Prerequisites

  • Windows Server 2016 (will work with other Server versions, too)
  • SMTP Server Feature installed

Configure

Check for installed "SMTP Server" Feature

Open IIS 6.0 Manager

Right click on "SMTP Virtual Server #1" and select "Properties"

In "Access" modify "Connection" and "Relay"

Choose "Only the list below" and enter "127.0.0.1" in the list of computers. If you want to use this SMTP Server for other computers in your network, add them too

Same in Relay Restrictions

Remove the limits

Here we have to modify "Outbound Security", "Outbound connections" and "Advanced"

Choose "Basic authentication", "TLS encryption" and enter an Office365 account dedicated for routing the messages.

Uncheck the limits and set "TCP port" to 587

Set a domainname and enter "smtp.office365.com" for the "Smart host"

Press OK to finish the configuration

Right click the "SMTP…" node and start the server

Finished

If you want to automatically start the SMTP Server after a reboot, don't forget to activate automatic starting of the service

 

 

Here is a sample from a .config file configuring log4net to use the local smtp server. In the comment you can see the values needed if you directly configure the Office365 account.