Skip to content

Using POSTFIX to send Email in Linux

Postfix is a popular open-source mail transfer agent (MTA) used on Linux and Unix-based systems. It is a powerful and flexible alternative to the widely used sendmail MTA.

Postfix uses a simple, file-based configuration system, which makes it easy to set up and manage. The main configuration file, main.cf, contains a set of parameters that control the behavior of the Postfix daemon. These parameters can be modified to suit the needs of the system administrator.

To install Postfix on a Linux system, the package can be obtained from the official repository of the distribution being used. Once the package is installed, the postfix service can be started and configured using the main.cf file and the command line utilities provided.

We use postfix for email services. Below are some of the very basic config you need to do to get emails using postfix

Login to server and switch to root user:

CHECK CURRENT VALUES

Below two parameters need to be changed. Check the current values

cat /etc/postfix/main.cf |grep -i mydomain
cat /etc/postfix/main.cf |grep -i relayhost

 

TAKE BACKUP

cd /etc/postfix/
cp main.cf main.cf_bkp

UPDATE VALUES

vi /etc/postfix/main.cf

mydomain = <PUT_YOUR_DOMAIN_NAME> 
relayhost = <PUT_YOUR_HOST_NAME>


RESTART POSTFIX SERVICES

# service postfix restart

CHECK POSTFIX SERVICES

# service postfix status

SEND TEST EMAIL

echo $(hostname) $(date) | mail -s "TEST_MAIL" test@test.com

 

Few benefits of Postfix:

  • Uses a simple, file-based configuration system, which makes it easy to set up and manage.
  • Uses modular design, which allows for easy modification and customization.
  • It also supports a wide range of authentication methods, making it a secure option for sending and receiving email.
  • Postfix supports virtual domains, which allows for multiple domains to be handled by a single server. This feature is particularly useful for hosting providers and organizations with multiple domains.
  • It supports content filtering. This allows for the filtering of email based on various criteria, such as subject, sender, and recipient. This feature is useful for blocking spam and other unwanted emails.
  • Postfix also includes a number of add-on tools and utilities, such as the postfix-tls package, which provides support for Transport Layer Security (TLS) encryption.
Brijesh Gogia
Leave a Reply