SMTP Relay Setup on Windows for Organization
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.
Pre-requisite:
- You have taken the office 365 license
- The public domain is setup and ready to use
- Mail server records have been added to the DNS hosting server
- SMTP servers need public IP or else need internet access via a proxy
- Outgoing traffic on port 25 should be opened
- 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:1.186.10.10 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.
8. Provide metadata
9. Authentication to send mail.
10. Review the summary page and create the connector.
B. SMTP server setup in Windows
- Spin-up windows machine with server 2016
2. Install SMTP server and Telnet Client. Telnet client will help in SMTP port testing.
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
5. Under the Access tab, click on connection, keep the “all except the list below “ option
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.
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.
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)
10. Before starting testing, it is good practice to restart the SMTP service through the console.
C. Test outgoing mail via SMTP and Application server.
C.1 Testing From SMTP Relay Server
- 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
4. Check whether mail with the subject Test mail 5 is received.
C.2. Testing from Application machine
- 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
5. Check mail with the subject Client mail 1 received.
This is how we can set up an SMTP relay on a windows machine and test it in a simple way.
Leave a Reply