SMTP Relay for Office 365

How to configure IIS for relay with Office 365

Applies To: Office 365 Admin

When you set up a multifunction device or application to send email through Office 365, there are some cases where the device or application can’t connect directly to Office 365. In these cases, you need to set up Internet Information Services (IIS) to work as an intermediary.

You might want to do this in the following scenarios:

  • You don’t have an on-premises messaging system any longer
  • You have line-of-business (LOB) programs or devices in an on-premises environment
  • Your LOB programs and devices have to send email messages to remote domains and to your Exchange Online mailboxes

Before proceeding, review How to set up a multifunction device or application to send email using Office 365 as there may be an available option that doesn’t require setting up an additional server to relay.

NOTE: These instructions can be modified for other SMTP relays that you might have in your organization.

What you need to know before you begin

  • Estimated time to complete: 15 minutes
  • Your on-premises domain must be added as an accepted domain in Office 365. For example, if the account you’re relaying from is [email protected], you have to add tailspintoys.com as an accepted domain in Office 365.
  • Your on-premises account must also be either an Exchange Online-licensed user in Office 365 or an alternative email address of an Exchange Online-licensed user. For example, if the account that you’re relaying from is [email protected] and you want to relay through [email protected] (an Office 365 user), you have to add [email protected] as an alternate email address to [email protected].

Use Server Manager to set up Exchange Online as an SMTP relay

The installation steps you’ll use are different for Windows Server 2012 and Windows Server 2008. Install Internet Information Services (IIS) on Windows Server 2012

Set up Exchange Online as an SMTP Relay Using Windows Server 2012

  1. Install Internet Information Services (IIS)
  2. In Server Manager, select Add Roles.
  3. On the Before you begin page in the Add Roles Wizard, select Next.
  4. On the Select Installation Type page, select Role-based or Feature-based installation.
  5. On the Select destination server page, choose Select a server from the server pool, and select the server that will be running SMTP services. Select Next.
  6. On the Select Server Roles page, select Web Server (IIS), and then select Next. If a page that requests additional features is displayed, select Add Features and then select Next.
  7. On the Select Role Services page, make sure that Basic Authentication under Security is selected, and then select Next.
  8. On the Confirm Installation Steps page, select Install.
  9. Install SMTP
  10. Open Server Manager and select Add Roles and Features.
  11. Select Server Selection and make sure that the server that will be running the SMTP server is selected and then select Features.
  12. On the Select Features screen, choose SMTP Server. You may be prompted to install additional components. If that’s the case, select Add Required Features and select Next.
  13. Select Install. After the installation is finished, you may have to start the SMTP service by using the Services snap-in for the Microsoft Management Console (MMC).
  14. Set up SMTP
  15. Open Server Manager, select Tools, and then select Internet Information Services (IIS) 6.0.
  16. Expand the current server, right-click the SMTP Virtual Server, and then select Properties.
  17. On the General tab, select Advanced > Add.
  18. In the IP Address box, specify the address of the server that’s hosting the SMTP server.
  19. In the Port box, enter 587 and select OK.
  20. On the Access tab, do the following:
  21. Select Authentication and make sure that Anonymous Access is selected.
  22. Select Connection > Only the List Below, and then specify the IP addresses of the devices that will be connecting to the SMTP server, such as printers.

iii.          Select Relay > Only the List Below, and then specify the IP address of the devices relaying through this SMTP server

  1. On the Delivery tab, select Outbound Security, and then do the following:
  2. Select Basic Authentication.
  3. Enter the credentials of the Office 365 user who you want to use to relay SMTP mail.

iii.          Select TLS Encryption.

  1. Select Outbound Connections, and in the TCP Port box, enter 587 and select OK.
  2. Select Advanced and specify SMTP.office365.comas the Smart Host.
  3. Restart the IIS service and the SMTP service.

Set up Exchange Online as an SMTP Relay Using Windows Server 2008

  1. Install Internet Information Services (IIS)
  2. In Server Manager, select Add Roles.
  3. On the Before you begin page in the Add Roles Wizard, select Next.
  4. On the Select Server Roles page, select Web Server (IIS) and select Install.
  5. Select Next until you get to the Select Role Services page.
  6. In addition to what is already selected, make sure that ODBC Logging, IIS Metabase Compatibility, and IIS 6 Management Console are selected and then select Next.
  7. When you’re prompted to install IIS, select Install. You may need to restart the server after the installation is finished.
  8. Install SMTP
  9. Open Server Manager and select Add Roles and Features.
  10. On the Select Features screen, choose SMTP Server. You may be prompted to install additional components. If that’s the case, select Add Required Features and select Next.
  11. Select Install. After the installation is finished, you may have to start the SMTP service by using the Services snap-in for the Microsoft Management Console (MMC).
  12. Set up SMTP
  13. Select Start > Administrative Tools > Internet Information Services (IIS) 6.0.
  14. Expand the current server, right-click the SMTP Virtual Server, and then select Properties.
  15. On the General tab, select Advanced > Add.
  16. In the IP Address box, specify the address of the server that’s hosting the SMTP server.
  17. In the Port box, enter 587 and select OK.
  18. On the Access tab, do the following:
  19. Select Authentication and make sure that Anonymous Access is selected.
  20. Select Connection > Only the List Below, and then specify the IP addresses of the devices that will be connecting to the SMTP server, such as printers.

iii.          Select Relay > Only the List Below, and then specify the IP address of the devices relaying through this SMTP server

  1. On the Delivery tab, select Outbound Security, and then do the following:
  2. Select Basic Authentication.
  3. Enter the credentials of the Office 365 user who you want to use to relay SMTP mail.

iii.          Select TLS Encryption.

  1. Select Outbound Connections and in the TCP Port box, enter 587 and select OK.
  2. Select Advanced and specify SMTP.office365.comas the Smart Host.
  3. Restart the IIS service and the SMTP service.

How do you know this worked?

You can test SMTP relay services without using an separate LOB application or device.

To test SMTP relay services, use the following steps.

  1. Create a text file using Notepad or another text editor. The file should contain the following code. Replace the source and destination email addresses with the addresses you will use to relay SMTP.
    FROM: <source email address>
    TO: <destination email address>
    SUBJECT: Test email
    This is a test email sent from my SMTP server
  2. Save the text file as Email.txt.
  3. Copy the Email.txt file into the following folder: C:\InetPub\MailRoot\Pickup.
  4. After a short time, the file should automatically be moved to the C:\InetPub\MailRoot\Queue folder. When the SMTP server delivers the mail, the file is automatically deleted from the local folder.
    WARNING:If the SMTP server can’t deliver the message, a non-delivery report (NDR) is created in the C:\InetPub\MailRoot\BadMail folder. You can use this NDR to diagnose delivery issues.

Comments are closed.