Windows OS Hub
  • Windows Server
    • Windows Server 2022
    • Windows Server 2019
    • Windows Server 2016
    • Windows Server 2012 R2
    • Windows Server 2008 R2
    • SCCM
  • Active Directory
    • Active Directory Domain Services (AD DS)
    • Group Policies
  • Windows Clients
    • Windows 11
    • Windows 10
    • Windows 8
    • Windows 7
    • Windows XP
    • MS Office
    • Outlook
  • Virtualization
    • VMWare
    • Hyper-V
    • KVM
  • PowerShell
  • Exchange
  • Cloud
    • Azure
    • Microsoft 365
    • Office 365
  • Linux
    • CentOS
    • RHEL
    • Ubuntu
  • Home
  • About

Windows OS Hub

  • Windows Server
    • Windows Server 2022
    • Windows Server 2019
    • Windows Server 2016
    • Windows Server 2012 R2
    • Windows Server 2008 R2
    • SCCM
  • Active Directory
    • Active Directory Domain Services (AD DS)
    • Group Policies
  • Windows Clients
    • Windows 11
    • Windows 10
    • Windows 8
    • Windows 7
    • Windows XP
    • MS Office
    • Outlook
  • Virtualization
    • VMWare
    • Hyper-V
    • KVM
  • PowerShell
  • Exchange
  • Cloud
    • Azure
    • Microsoft 365
    • Office 365
  • Linux
    • CentOS
    • RHEL
    • Ubuntu

 Windows OS Hub / Windows Server 2012 R2 / How to Install and Configure SMTP Server on Windows Server 2016/2012 R2?

May 14, 2021 Windows Server 2012 R2Windows Server 2016Windows Server 2019

How to Install and Configure SMTP Server on Windows Server 2016/2012 R2?

You can install an SMTP server using built-in tools in all versions of Windows Server. This SMTP server can work as a mail relay service that should receive and send SMTP emails from various devices in the organization (for example, senders, scanners, access control devices, etc.) and applications (web apps, SQL Reporting Services, SharePoint), which should be able to send mail using the SMTP protocol. Such a relay can send messages to your Exchange servers or to public email services such as Gmail, Yahoo, Office 365 (outlook.com), etc. (since it is not always advisable to deploy a full-featured internal email infrastructure based on Microsoft Exchange Server or other email services).

In this article we’ll show how to install, configure and test the SMTP server on Windows Server 2012 R2, 2016 and 2019 serving as a mail relay. This SMTP server can only send or forward emails, and there are no user mailboxes on it.

Contents:
  • How to Install SMTP Service on Windows Server 2016 / 2012 R2?
  • Configuring SMTP Server on Windows Server
  • SMTPSVC Service Auto-Start
  • Testing the SMTP Server on Windows

How to Install SMTP Service on Windows Server 2016 / 2012 R2?

SMTP service is one of the built-in features of Windows Server that can be installed through Server Manager. To do it, open the Server Manager Dashboard (servermanager.exe), go to Add roles and features and check SMTP Server when selecting the features to install. To manage the SMTP service, install the management consoles, being a part of Web Server (IIS) role, so you will be prompted to install some IIS components.

SMTP server feature on Windows Server 2012 R2

Leave all the suggested options of the Web Server (IIS) role and run installation.

IIS 6 Managment Tools

You can also install the SMTP server role using the PowerShell command:

Install-WindowsFeature smtp-server

After the components are installed, you may need to restart your server.

Configuring SMTP Server on Windows Server

The SMTP server is still managed using the old school management console Internet Information Services (IIS) Manager 6. You can open this console from the Server Manager: Tools-> Internet Information Services (IIS) 6.0 Manager or with the command inetmgr6.exe.

console Internet Information Services (IIS) Manager 6 console

Expand the branch with your server name in the IIS 6 Manager, right-click SMTP Virtual Server and open its properties.

SMTP Server properties

On the General tab, if necessary, select the IP address on which the SMTP server should respond (if the server has multiple IP addresses), and check the option Enable logging (in order to save information about all received emails to text log files).

SMTP Virtual Server Settings

Then go to the Access tab.

smtp access tab

Here click the Authentication button and make sure that the Anonymous access is enabled.

SMTP Authentication Settings: Anonymous access

Go back to the Access tab and click the Connection button. Here you can specify the IP addresses of devices that are allowed to send emails through your SMTP relay. To do it, check the Only the list below and specify the list of IP addresses (subnets), don’t forget about yourself (127.0.0.1).

Configure the same way the list of allowed IPs in the Relay settings (click the corresponding button). This section indicates which IP addresses (or subnets) can relay email through your SMTP server.

smtp allow ip list

Note. As a general rule, it’s worth to check this options and limit the list of accepted devices with the range of IP addresses. Otherwise, your SMTP server may be used by spammers and other attackers as an open relay for mass mailings.

Go to the Messages tab. Here the administrative e-mail address is specified, to which the copies of all NDR messages will be send (Send copy of Non-Delivery Report to:). Also here you can specify the restrictions on the maximum message size (Limit message size KB) and the maximum number of recipients (Limit number of recipients per message).

messages limits

Go to the Delivery tab.

delivery options

Then click Outbound Security. Here you specify the way of authentication on the external mail server to which your SMTP server will send (relay) all email messages. For example, if all emails will be forward to Gmail mail server and then sent to the recipients, you need to check the Basic authentication and specify your Gmail mailbox credentials (you must allow to send email via Gmail SMTP in the Google account settings).

Outbound security: anonymous access

Then click Advanced.

Advanced delivery options

Here you specify the FQDN name of your SMTP server. Click the Check DNS button to make sure that the DNS record is valid.

the domain name is valid

If your server sends mail to an external SMTP server, specify its name in the Smart host field (for example, smtp.gmail.com or smtp.office365.com).

Some public mail servers accept email only when using a secure SMTP connection using TLS Encryption (TCP port 587). You can configure this setting in the section Delivery -> Outbound Security and Outbound Connections. Read the documentation of your email provider.

Save the SMTP server settings and restart your SMTP virtual service to apply the changes.

Note.

  1. The DNS settings are critical from the point of view of email system health. If your SMTP server cannot correctly resolve DNS names of domains to which it is trying to send email, the delivery will fail.
  2. If your server sends mail to other domains, it is important that the correct PTR record is created for your IP address in order to resolve reverse DNS lookups. The PTR record for your public IP address should point to your server FQDN name. Otherwise, most external SMTP servers won’t accept email from you, considering your server a spammer one.

SMTPSVC Service Auto-Start

It remains to configure the automatic startup of SMTP service on your Windows Server. You can do it quickly using the PowerShell command prompt:

set-service smtpsvc -StartupType Automatic

Start the service:

start-service smtpsvc

Make sure that the SMTPSVC service is running:

get-service smtpsvc

Status   Name               DisplayName
——   —-               ————
Running smtpsvc           Simple Mail Transfer Protocol (SMTP)

Start smtpsvc service

Testing the SMTP Server on Windows

The last thing you have to do is to make sure that your SMTP server is working. It is easier to do it by creating a plain-text file smtp-test-email.txt on your desktop and copying the following text to it. Don’t forget to change the sender and recipient names to yours.

From: [email protected]
To: [email protected]
Subject: Email test
This is the test email

smtp test email

Copy the file smtp-test-email.txt to the C:\inetpub\mailroot\Pickup folder. The Windows SMTP server monitors new files appearing in this folder, and if a file is found it will read it contents and try to send an email with the given subject and body to the recipient specified in the To: line.

Check the recipient mailbox, and you will see this e-mail.

test email in outlook

Tip. You can test your SMTP server using the telnet command, VBS script or PowerShell:

Send-MailMessage -SMTPServer localhost -To [email protected] -From [email protected] -Subject "Email test" -Body "This is the test email from PowerShell"

If you have enabled Basic Authentication to authenticate all your SMTP clients (instead of anonymous authentication), you can send an email with the smtp authentication via telnet as follows.

Also, make sure that TCP 25 port is not blocked on your SMTP server by the local firewall or anti-virus software. The easiest way to do this is from a Windows-based computer whose IP address has been added to the allowed connection list. Check availability of port 25 using the Test-NetConnection cmdlet:

Test-NetConnection smtprelay.woshub.com –port 25

If port 25 is blocked, check the settings of Windows Firewall, antivirus and hardware firewalls.

So, you have configured your own SMTP mail relay on Windows Server 2016 / 2012 R2 and tested sending emails through it.

5 comments
1
Facebook Twitter Google + Pinterest
previous post
Windows Server Licensing for Virtual Environments
next post
Configuring Anti-Spam Protection on Exchange 2013, 2016 – RBL Providers

Related Reading

Using WPAD (Web Proxy Auto-Discovery Protocol) on Windows

November 7, 2023

Zabbix: How to Get Data from PowerShell Scripts

October 27, 2023

Tracking Printer Usage with Windows Event Viewer Logs

October 19, 2023

How to Use Ansible to Manage Windows Machines

September 25, 2023

How to View and Change BIOS (UEFI) Settings...

September 13, 2023

5 comments

Alex June 28, 2017 - 10:20 pm

Hi,

Great tutorial. I already had it configured. It was nice to doublecheck by reading yours.

I do have a simple question:

I did add those external ip addresses. It means now that if i give my ip and port number to the external party, correct? They now can send through my relay. My issue is, is it possible that I can see in a program which emails are being sent?

Reply
mohamed August 15, 2017 - 12:48 pm

Hello ,
I would like to ask can I receive email on the drop folder or I only can send and if I can receive how to do that?
thx

Reply
admin August 30, 2017 - 5:06 am

You can manually copy emails from Drop folder or use some third party POP3 /IMAP server software to access mail items from client aka Outlook.

Reply
kawaguchi April 11, 2018 - 12:59 pm

After installing the SMTP server it’s also important to setup DNS mx/spf settings for out-bound emails to go properly.

Reply
Mike Y. April 27, 2021 - 6:16 pm

Gotta give credit where credit is due. This was a FANTASTIC tutorial. Clear, concise and complete. Thanks!

Reply

Leave a Comment Cancel Reply

Categories

  • Active Directory
  • Group Policies
  • Exchange Server
  • Microsoft 365
  • Azure
  • Windows 11
  • Windows 10
  • Windows Server 2022
  • Windows Server 2019
  • Windows Server 2016
  • PowerShell
  • VMWare
  • Hyper-V
  • Linux
  • MS Office

Recent Posts

  • How to Connect VPN Before Windows Logon

    November 14, 2023
  • Removing Azure Arc Setup Feature on Windows Server 2022

    November 9, 2023
  • Using WPAD (Web Proxy Auto-Discovery Protocol) on Windows

    November 7, 2023
  • Send Emails with Microsoft Graph API and PowerShell

    November 6, 2023
  • Zabbix: How to Get Data from PowerShell Scripts

    October 27, 2023
  • Tracking Printer Usage with Windows Event Viewer Logs

    October 19, 2023
  • PowerShell: Configure Certificate-Based Authentication for Exchange Online (Azure)

    October 15, 2023
  • Reset Root Password in VMware ESXi

    October 12, 2023
  • How to Query and Change Teams User Presence Status with PowerShell

    October 8, 2023
  • How to Increase Size of Disk Partition in Ubuntu

    October 5, 2023

Follow us

  • Facebook
  • Twitter
  • Telegram
Popular Posts
  • Managing Printers and Drivers with PowerShell in Windows 10 / Server 2016
  • Managing Printers from the Command Prompt in Windows 10 / 8.1
  • Fix: RDP Authentication Error Has Occurred – The Function Requested Is Not Supported
  • How to Reduce Windows.edb Huge File Size?
  • Windows Server Licensing for Virtual Environments
  • How to Restore Active Directory from a Backup?
  • Installing a Free Let’s Encrypt TLS/SSL Certificate on IIS Web Server / RDS
Footer Logo

@2014 - 2023 - Windows OS Hub. All about operating systems for sysadmins


Back To Top