Table of Contents


Simple Mail Transfer Protocol (SMTP) comes from the application layer of the TCP/IP protocol. TCP/IP (Transmission Control Protocol/Internet Protocol,) is the foundational knowledge of Internet communication protocols used to interconnect various network devices. The Internet uses various protocols in conjunction with each other to send bits packets of data that is encapsulated and decapsulated from the sender source service or device, to its destination address.

SMTP Is the mail protocol that governs data transmission from a source and destination IP Address. SMTP works with Mail Transfer Agent (MTA) to send emails to the destination mailbox.

Knowing how SMTP works will allow system administrators to send test email packets to a destination to determine various analytics such as;

SMTP Servers

There are 2 types of SMTP servers hosted throughout the internet. On-premise SMTP servers which are services and packages that Either come bundled with Operating systems or On Cloud SMTP servers which are online versions either free or paid available to the public. The most popular on-premise SMTP servers are listed below;

With free SMTP services usually a mail client will need to be used to access the mailboxes contents such as Outlook. Otherwise each SMTP either provides their own method of administering mailboxes or relies on the user to find or develop a third party mail client software to access these records.

There are a few common on cloud SMTP servers used that make up for the majority of mail traffic through the Internet. For paid SMTP services Gmail via Google's Gsuite and Exchange via Office 365 take up the largest share on online paid SMTP servers. Yahoo and Hotmail are the 2 largest free on cloud SMTP servers used via public and business consumers used throughout the Internet.

There are benefits to using either service but its ultimately up to the business case for the requirement of SMTP to be the primary determining factor of choosing that particular server over others. It's best to research the right SMTP service available for the correct task.

Installing SMTP service

SMTP service can be installed on Windows or many popular common Linux distributions. The benefits of installing a SMTP service on a personal server vs a third party service like Gmail (from Gsuite) or Exchange (Through Office 365) whether on-premise or in the cloud, is the freedom of controlling the up time of mail services and not dependent on third party support, the free cost in running an SMTP service with the only thing necessary to install would be IIS for Windows, or have Sendmail package setup in Linux which is by default packaged with RHEL OS or available for free download with many other linux distributions and support their own third party in built applications into the SMTP service.

Once the SMTP service is installed locally on the host server administrators will have full control over administering and creating email accounts which can be accessed through a Mail Client such as Outlook. The full functionality of having an inbox, viewing event logs, able to navigate mailboxes, check drafts, see sent emails etc. Will all be available to administrators. The reverse of accessing these through a third-party SMTP service such as Office 365 and G-suite require a considerable amount of wasted time navigating reporting functionality which although is present with both services and their customer service team, does take time to retrieve, although these processes are improving with age.

Installation of SMTP Service – Windows Server 2016 + IIS

1) Open the Server Manager Dashboard. Click on ‘Manage’, then ‘Add Role & Features’.
2) Click on ‘Next’ after this.
3) Select ‘Role-based or feature-based installation’, then click ‘Next’.
4) Select a server from Pool.
5) Click on ‘Next’ after selecting the role the server would play.
6) Select ‘Features’. Next scroll down the list and select the ‘SMTP Server’ feature. Then click on next.
7) A new window appears to inform you that some other services can also be installed. Click “Add Features" to confirm and continue.
8) Click on ‘Next’ to continue.
9) Click on ‘Install’ to complete the installation.
10) Once the installation has been completed, click on ‘Close’. Close button will appear after complete installation.

Configuration of SMTP Services

1) Launch the Internet Information Services (IIS) 6.0 Manager.
2) Right-click on ‘SMTP Virtual Server #1’ and select ‘Properties’.
3) Tap the General tab and change the IP Address to the server’s IP address.
4) Then tap the ‘Access’ tab and click on the ‘Connection’ button.
5) In the Connection window, select ‘Only the list below’ and click on the ‘Add’ button.
6) Select the ‘Single computer’ option. To use the internal SMTP, type the IP address, add ‘Group of computers’ or ‘Domain’ of the devices permitted, and then click on the ‘OK’ button.
7) In the ‘Access’ tab of the Connection window, click on the ‘Relay’ button to add the same permitted devices to the Relay restrictions’ list.
8) In the ‘Delivery’ tab of the Connection window, set an external domain.
9) Go to ‘Run’ and type wf.msc. This will launch the Windows Firewall with Advanced Security console.
10) To begin the wizard, right-click on ‘Inbound Rules’ and select ‘New Rule’.
11) Select ‘Port’ and click on ‘Next’.Set the local port to 25 and click on ‘Next’.
12) Select ‘Allow the connection’ and click on ‘Next’.
13) Uncheck ‘Public’ (Ignore if you want to access the services from outside) to prevent external access to the server. Click on ‘Next’.
14) Give the rule a name, and click on ‘Finish’.
15) You can now see a new rule enabled in the firewall management console.
16) Go to ‘Run’ and type wf.msc.
17) Here you can see that SMTP services are running.
18) Now you can deliver the mails with your windows server 2016 email server as per your convenience.

Installing SMTP in CentOS 7

Before starting, update the system and install epel release in your server.

# yum update – y.
# yum install epel-release – y


Postfix mail server can be simply installed by following these steps:
1) Install postfix packages by typing the command:

# yum install postfix – y

That’s it! The installation will spontaneously start the Postfix daemon for you. As soon as the installation is complete, you can try it out to make sure that you can link to your Postfix server with the command:

# telnet localhost 25

It will produce something on the screen like:

Trying ::1…
Connected to localhost.
Escape character is ‘^]’.
220-mail.znettest.tk ESMTP Exim 4.89_1 #1 Tue, 20 Feb 2018 13:29:17 +0530
220-We do not authorize the use of this system to transport unsolicited,
220 and/or bulk e-mail.

Note: Here, mail.znettest.tk is the hostname of this server.

Configuring Postfix

The Postfix mail server has one important configuration file /etc/postfix/main.cf where all the details are stored for the mail service.
Open the file in the vi or any other text editor and look for the following section:

# vi /etc/postfix/main.cf
inet_interfaces= all
inet_protocols= ipv4
alias_maps = hash: /etc/aliases
mydestination =
mynetworks =

These are the sections of the configuration file you must emphasize on. And, I must say, there isn’t much to do. Underneath are the sections you need to configure:
myhostname: This parameter specifies the internet hostname of this mail daemon. The default is to use the fully-qualified domain name.
mydestination: This parameter specifies which destinations this machine will deliver locally. Use the configuration locally which has been provided by default in the server and change the localhost to the domain name.
mynetworks: This line is a bit riskier. This entry will define authorized destinations that mail can be relayed from. If you are thinking to add your subnet here, there are partial chances of its success.
You can go with mynetworks entry that looks like:

mynetworks =

The above entry is a safe entry and defines local machines only.
The inet_interfaces parameter specifies the network interface addresses on which it receives mails. By default, the software ensures all active interfaces on the machine. The parameter also controls the delivery of the mails to the user@[ip.address].

inet_protocols= ipv4

By default, it is set to IPv4 to ensure faster delivery of mails.
Now, save and exit the vi editor. Then start/enable the mail service with the command so that it will be Active after server reboot.

# systemctl restart postfix

# systemctl enable postfix

Installation of mail service has been completed. Now it is time to create one user and test it.

Creating users

Since this is a Linux mail server, you have to make sure that you have a user name that resembles every email address you need. You can create users with the command:

# useradd -m USERNAME (USERNAME is the real name of the user).

The next step is to give the username, a password with the command:

# passwd USERNAME

Testing Your Server

You can use mail utils package to install necessary things to send the mails by using the command:

Yum install mail x – y

After this, try any mail Id by typing:

Mail (mailid)

It will ask the subject. Enter the content you want to send.
After completing, exit and end the mail by using a dot

Now your mail server is ready to deliver mails as per your needs.

SMTP with PowerShell

PowerShell can leverage a simple command
and insert the parameters for Sender Address, Destination Address, Attachments to imitate a test email. This is particularly helpful in automation/reporting when a service saves a txt report on a location where a PowerShell job can run a script to attach this txt report to send to a mail distribution list.


A SMTP server must exist on the domain that the PowerShell command is run from, such as the domain network. Then the bellow command can be run

Send-MailMessage -SmtpServer "smtp.poshpython.com" -From "reporting@poshpython.com" -To "newsletter@poshpython.com" -Bcc "admin@poshpython.com" -Subject "Here is the weekly page views" -Body "Hey PoshPythoner's please see this weeks attached report on the most viewed webpages on PoshPython" -Attachments ("C:\test.pdf")

For more information on the capabilities of
see the following Microsoft Knowledge base Article.