{"id":7342,"date":"2020-12-02T22:39:45","date_gmt":"2020-12-02T19:39:45","guid":{"rendered":"https:\/\/kifarunix.com\/?p=7342"},"modified":"2024-03-15T09:15:00","modified_gmt":"2024-03-15T06:15:00","slug":"configure-postfix-to-use-gmail-smtp-on-centos-8","status":"publish","type":"post","link":"https:\/\/kifarunix.com\/configure-postfix-to-use-gmail-smtp-on-centos-8\/","title":{"rendered":"Configure Postfix to Use Gmail SMTP on CentOS 8"},"content":{"rendered":"\n

Welcome to our tutorial on how to configure Postfix to use Gmail SMTP on CentOS 8 to relay mails. Postfix<\/a> is a free and open-source mail transfer agent that routes and delivers electronic mail. Postfix MTA can be configured to relay mails through an external SMTP servers such as Gmail SMTP server for a reliable mail delivery.<\/p>\n\n\n

\n
\"Configure<\/figure><\/div>\n\n\n

Configuring Postfix to Use Gmail SMTP on CentOS 8<\/h2>\n\n\n\n

Install Postfix on CentOS 8<\/h3>\n\n\n\n

You can install Postfix by installing the postfix<\/code> package itself or via the mailutils<\/code> package which installs along with it.<\/p>\n\n\n\n

dnf install postfix<\/code><\/pre>\n\n\n\n

Install SASL on CentOS 8 <\/h3>\n\n\n\n

SASL (Simple Authentication and Security Layer) provides a mechanism of authenticating users using their username and password<\/em>. The implementation of SASL is provided Cyrus SASL library which can be installed on a CentOS 8 system by running the command below;<\/p>\n\n\n\n

dnf install cyrus-sasl-plain <\/code><\/pre>\n\n\n\n

Install Mail Command on CentOS 8<\/h3>\n\n\n\n

Mail command on CentOS 8 is provided by mailx package. <\/p>\n\n\n\n

dnf install mailx<\/code><\/pre>\n\n\n\n

Configuring Postfix to Use Gmail SMTP Relay<\/h3>\n\n\n\n

Postfix is now installed with the default configuration. You can view Postfix configuration values using the postconf command;<\/p>\n\n\n\n

postconf<\/code><\/pre>\n\n\n\n

To make further configuration changes, edit the main Postfix configuration file, \/etc\/postfix\/main.cf<\/code> and make any necessary changes as needed.<\/p>\n\n\n\n

Set the Postfix Relay server<\/h4>\n\n\n\n

Postfix can be configured to deliver mails indirectly via a relay host. A relay host can be defined on a Postfix configuration file using the relayhost<\/strong><\/code> parameter.<\/p>\n\n\n\n

By default, the value of the relayhost<\/strong><\/code> parameter is empty<\/strong>. This configures Postfix is to try to deliver mail directly to the Internet, which is usually not desirable.<\/p>\n\n\n\n

According to Postfix configuration<\/a>, different values can be set for the relayhost parameter;<\/p>\n\n\n\n