GMail as a Relay on Linux CENTOS7

You can remove Postfix and use SSMTP as it has easier configuration.

yum install ssmtp ca-certificates mutt

Follow instructions at https://golb.hplar.ch/2018/06/send-only-email.html

To get desired sender (username@hostname) when using mutt to send, add this line to /etc/ssmtp/ssmtp.conf:

FromLineOverride=YES

Add these lines to the global /etc/Muttrc.local (easier than adding it to each user's $HOME/.muttrc):

set from = "`whoami`@`hostname`"
set realname = "`whoami`@`hostname`"

Successful test via manual send:

mutt -s "Test4" [email protected] </dev/null

Successful test via crontab:

\* * * * * /path/to/bin/mutt_test.bash > /path/to/logs/mutt_test.log

The mutt_test.bash test script has this for content:

#!/bin/bash
date=`date`
mutt -s "$date bash mutt test" [email protected] </dev/null