I’m trying to setup emails for a WordPress site on a Linux server but I’m having difficulties getting Postfix to work.
I have Google G suite (now Google Workspace) so I will be relaying my outgoing emails through Google’s SMTP servers. My Apache and PHP services run under the
www-data user account so when checking my mail log at
/var/log/mail.log I can see the email is trying to go out as
firstname.lastname@example.org. Obviously this email doesn’t exist in Google G Suite so Google’s SMPT server’s refuse it and no email is sent/received.
The reason I’m using Postfix is because I have some cron jobs that I would like to email myself once they have completed. I also want to keep my WordPress plugin count to a minimum so I don’t want to install any plugins to handle SMTP as lots of guides recommend on the internet.
Postfix is currently working, sending emails out properly and I am able to send emails using the
echo "Cron job has finished on $(date +'%d/%m/%Y') at $(date +'(%H:%M:%S)')" | mail --subject="WordPress Backup Complete" --append="From:Root <email@example.com>" --append="Reply-To:firstname.lastname@example.org"email@example.com
I would like to re-write the
www-data account so that it is sending as
webmaster instead. I would additionally like to re-write the header for
www-data so that I can overwrite the
subject headers WordPress uses.
I have enabled
sender canonical maps in the
... sender_canonical_maps = regexp:/etc/postfix/sender_canonical
and it’s contents with the following