Introduction
In many corporate environments, applications and monitoring tools like ERP, CCTV, or PRTG need to send email alerts. However, directly sending emails through the internet can cause security or delivery issues.
A Mail Relay Server helps solve this by acting as a secure intermediary between your internal systems and the external mail server. In this guide, we’ll walk you through the complete process of setting up a Mail Relay Server on Windows Server 2019 or 2022 using the built-in IIS SMTP Server feature.
What is a Mail Relay Server?
A Mail Relay Server forwards emails from internal devices or applications to your main mail server (such as Microsoft 365, Google Workspace, or your company’s SMTP server).
It’s especially useful when:
- You want to centralize outbound email communication.
- Applications or printers don’t support authentication.
- You need better control over email routing and security.
Step 1: Install the IIS SMTP Server Feature
- Open Server Manager → click Manage → Add Roles and Features.
- Choose Role-based or feature-based installation and click Next.
- Under Server Roles, expand Web Server (IIS).
- Check SMTP Server.
- The wizard will automatically include IIS 6 Management Compatibility.
- Click Install and wait for the installation to complete.
- After installation, open IIS 6.0 Manager from Administrative Tools.
Step 2: Configure the SMTP Virtual Server
- In IIS 6.0 Manager, expand your server → right-click SMTP Virtual Server #1 → Properties.
General Tab
- Click Advanced → specify the IP address of your server (or leave “All Unassigned”).
- Enter your Fully Qualified Domain Name (FQDN) (e.g.,
relay.company.com).
Step 3: Set Relay Permissions
- Go to the Access tab → click Relay.
- Choose Only the list below.
- Click Add → enter the IP addresses of systems that can send mail through this relay (e.g., 172.16.x.x application servers).
- You can also enable Allow all computers which successfully authenticate if needed.
Tip: Never allow “All except the list below” — it opens your server to spam abuse.
Step 4: Configure Authentication
- Under the Access tab → click Authentication.
- Select Anonymous Access if you’re relaying only from trusted internal IPs.
- If you’ll use external SMTP (like Microsoft 365), choose Basic Authentication and enable TLS encryption later.
Step 5: Set Outbound Security (Optional)
If your mail relay will forward emails to an external SMTP service:
- Go to the Delivery tab → click Outbound Security.
- Choose Basic Authentication → enter your external SMTP credentials.
- Check TLS encryption if your mail provider requires it.
Step 6: Configure the Smart Host
- In the Delivery tab, click Advanced.
- Under Smart host, enter your mail provider’s SMTP address, for example:
- Microsoft 365 →
smtp.office365.com - Gmail →
smtp.gmail.com
- Microsoft 365 →
- Keep the default port 25 (or change to 587 if required).
- Set your server’s FQDN (e.g.,
relay.company.local).
Step 7: Restart the SMTP Service
After configuration:
- Open Services (services.msc) → restart Simple Mail Transfer Protocol (SMTP).
Step 8: Test the Mail Relay
Use PowerShell to test the relay:
Send-MailMessage -From "test@company.com" -To "user@external.com" -Subject "Relay Test" -Body "This is a test email." -SmtpServer relay.company.local
Or test manually using Telnet:
telnet relay.company.local 25
Then type SMTP commands manually to simulate a message.
Step 9: Enable Logging
- In IIS 6 Manager → SMTP Virtual Server #1 → Properties → General → Enable Logging.
- Choose W3C Extended Log File Format and select a log directory.
- Logs can help track delivery and detect abuse.
Best Practices
- Restrict relay access to specific IP addresses only.
- Always use TLS when relaying to external SMTP servers.
- Periodically review logs for unusual activity.
- Keep Windows Server and SMTP features updated.