CentOS uses Postfix as the default MTA. Even if you install it with the minimal configuration, Postfix is installed and started, which is a waste, so relay it to another place with GMail. For example, all emails sent from the host ozyrys.local are sent from the same GMail user as shown below. This makes it basically unusable in a multi-user environment. I feel that it may be good for my local development environment.
From: root <firstname.lastname@example.org>
X-Google-Original-From: email@example.com (root)
Environment and Setup
- CentOS 7
⚠️ Note that you can not authenticate with GMail without cyrus-sasl-plain
We need edit /etc/postfix/main.cf And add the following settings to the end, set GMail as a relay destination and use TLS for SMTP authentication (PLAIN).
Setup authentication user settings
Edit file /etc/postfix/sasl_passwd add the following settings
Now we can change permissions and create db
chmod 600 /etc/postfix/sasl_passwd
At the end, we only have to restart the website with the command.
systemctl restart postfix
If you have the mailx package installed, send an email to your own address (other than GMail is also possible) as shown below, and you should receive the email from the GMail address registered as a relay.
$ mail firstname.lastname@example.org