Our requirement is to set up an SMTP relay on a Windows machine that will send notification emails to one or more customers through the Office365 connector. This Windows machine as an Application server will notify any application errors or any job failures. SMTP relay is mostly used for sending outgoing mail.


  1. You have taken the office 365 license
  2. The public domain is setup and ready to use
  3. Mail server records have been added to the DNS hosting server
  4. SMTP servers need public IP or else need internet access via a proxy
  5. Outgoing traffic on port 25 should be opened
  6. email account to test email functionality

High-level steps:

A. Setup connector
B. SMTP server setup in Windows
C. Test outgoing mail via SMTP and Application server

A. Setup Connector

1. First thing I will take static public IP for the SMTP relay server.

2. Login into the domain registrar website where you have added your Mail related records

3. Go to the domain setting of your domain

4. Modify the value of spf record as shown below. I have added the static public IP of the SMTP server. This addition for your outgoing mail does not go into the spam mailbox of customers.

v=spf1 ipv4: include:spf.protection.outlook.com -all

Imp Note: You can add the public IP of that server or Proxy or firewall IP in the value of the TXT record through which it is going to the Internet

5. Login into the M365 admin center and expand all options, you will find the exchange admin center over there, click on it. A new window will open.

6. Go to Mail Flow -> connector

7. Create a new connector.

o365 connector

8. Provide metadata

Connector Details

9. Authentication to send mail.

Allowed specific IP to send a mail

10. Review the summary page and create the connector.

B. SMTP server setup in Windows

  1. Spin-up windows machine with server 2016

2. Install SMTP server and Telnet Client. Telnet client will help in SMTP port testing.

Add SMTP features

3. Open Server manager –> tools –> IIS 6.0 manager

4. Right-click on the SMTP server and open properties. Under the general tab, click on advance, and set port 25 if not there. The remaining setting keep as it is

General setting under SMTP

5. Under the Access tab, click on connection, keep the “all except the list below “ option

Connection Tab

6. Next click on the relay on Access tab, keep all except the list below option. You can also limit relay to limited servers as well.

Relay Restriction

7. Keep the message tab as it is

8. Under the Delivery tab, keep anonymous access under outbound security. You can also use basic authentication with user credentials who has sent as right.

Outbound Security

9. Under the Delivery tab, no change in outbound connection, click on Advanced tab, set smart host as MX record value (available with office365 admin)

Smart Host Setting

10. Before starting testing, it is good practice to restart the SMTP service through the console.

Stop/Start SMTP service

C. Test outgoing mail via SMTP and Application server.

C.1 Testing From SMTP Relay Server

  1. Download SMTP client from the internet. To install it, need .net framework 3.5.

2. After installing it, open it

3. Add local host, port, from, to, subject and body. Click on send

SMTP Client Tool for Testing
SMTP Client Tool for Testing

4. Check whether mail with the subject Test mail 5 is received.

Test mailbox

C.2. Testing from Application machine

  1. Download SMTP client from the internet. To install it, need .net framework 3.5.

2. After installing it, open it

3. Add either SMTP relay server public IP or public A record, then the port number

4. Further add value in From, To, Subject and Body

SMTP Client on Application Server

5. Check mail with the subject Client mail 1 received.

Test mailbox

This is how we can set up an SMTP relay on a windows machine and test it in a simple way.