Reader Comments

A Step-By-Step Guide On How To Configure Smtp Server On Linux

by Darell Crist (2021-10-07)

Electronic mail or email is essential to professional communication. A free web-based email service can be used for personal usage. However, if your business is massive, such as an e-commerce website then you'll require an individual mail server.

Setting up an SMTP server on a Linux server comes with many benefits. These are only a few of the many benefits that a Linux mail server offers:

Highly reliable, secure and expandable.
It doesn't require expensive hardware.
Supports POP3, IMAP and web mail access.
To make your PC more secure, add a powerful antispam filter to your system and a reliable antivirus.

There are many ways to set up and manage the server in accordance with your needs. However, I have found Postfix to be among the easiest open source mail transfer agents (MTA) to set up and also the most reliable. It can be set up in one-user and multi-user in a similar environment. It's very versatile and works well in all environments.

Step-by-step guide on how to set up a mailserver in CentOS 7
Before you begin, upgrade the system and install epel release on your server.

# yum update - y.

yum install epel-release you

Mail server Postfix can be installed easily by following these steps:

1) Enter the following command to install postfix packages:

yum install postfix - the y

It's done! The installation will begin automatically the Postfix daemon for you. As soon as the installation is complete you are able to test it out to make sure that you are able to connect to your Postfix server using the command:

# telnet localhost 25

It could look something similar to:

Try : 1...
Connected to the localhost.
'^]'. Escape character ESMTP Exim 4.89_1 #1 Tue, 20 Feb 2018 13:29:17 +0530
220-Unsolicited travel is not allowed.
220 and/or bulk email

Note This is the case: is the hostname of this server.

Configuring SMTP server on Linux
Configuring Postfix

A configuration file is needed for Postfix mail servers: /etc/postfix/ This contains all the information about the service for mail.

Use the vi editor or another text editor, and then look for the section that follows.

vi /etc/postfix/

inet_interfaces = all
inet_protocols = IPv4
alias_maps = hash: /etc/aliases
mydestination =
mynetworks =

These are the sections of the configuration file that you should focus on. In my opinion that there's not much to do. Below are the sections you'll have to set up.

Myhostname: This parameter defines the hostname on the internet for this mail daemon. The default is to use the fully-qualified domain name.

mydestination: This parameter specifies the destinations that this machine will provide locally. You can use the default configuration in the server to configure locally and then change the localhost to point at the domain.

MyNetworks: This line can be more risky. This entry will define authorized destinations that mail can be relayed from. If you are thinking to add your subnet here, Additional Resources there are partial chances of success.

You could choose to use mynetworks entry that looks like:

mynetworks =

The entry above is a safe entry and is only a definition of local machines.

Inet_interfaces defines the network interface addresses where it receives messages. By default, the program will ensure that all active interfaces are active on the system. The parameter also regulates the delivery of the mails to the user@[ip.address[ip.address].

inet_protocols= ipv4

By default, it's assigned to IPv4 to speed up the delivery of mail.

Save and close the vi editor. Then, save and exit the vi editor.

systemctl restart postfix

# systemctl enable postfix

The installation of the mail service is completed. Now is the time to create one user, and then test it.

Creating users

This is an Linux mail server. You must make sure that your user name matches the email addresses you are using. This command is able to create user accounts:

useradd useradd USERNAME (USERNAME is the actual name of the user).

The next step is to provide the username and password, using the command:


Test Your Server

Mail utils is a package that is a tool to set up essential items needed to send mail.

Yum install mail with x-y

If you are not sure you can try any email ID by entering:

Mail (mailid).

It will ask you for the subject. Enter the content you want to send.

After you've finished then exit the email and then close it using a dot (".")

Your server for mail is fully operational and ready to deliver mail according to your preferences.

You can also use SMTP relays to enable a multifunction device, printer or application for sending emails using Office 365 and Exchange Online. ZNetLive lets you select from a variety of Microsoft Office 365 plans that best suit your needs. This lets you operate your business with ease from any location.