How to Relay Emails to Gmail
Jump to navigation
Jump to search
Introduction
This tutorial applies to RHEL 8 based operating systems (CentOS, Rocky Linux)
Two machines that send emails are:
- vav.combpio.ucsf.edu
- bksmailman.compbio.ucsf.edu
Relaying emails through gmail will make it more secure and trustworthy.
Instructions
- Create a gmail account OR Ask Khanh for docking.email@gmail.com for credentials.
- Disable pre-installed 'sendmail' package
rpm -q sendmail (Check for package) systemctl disbale sendmail --now (Disable package)
- Enable smtp in firewall
firewall-cmd --permanent --add-service=smtp
- Install Postfix and other dependencies
yum install postfix mailx cyrus-sasl cyrus-sasl-plain -y
- Configure Postfix
vim /etc/postfix/main.cf //Copy these lines and paste it at the bottom of the main.cf file relayhost = [smtp.gmail.com]:587 smtp_use_tls = yes smtp_sasl_auth_enable = yes smtp_sasl_security_options = noanonymous smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd smtp_tls_security_level = encrypt smtp_tls_CAfile = /etc/ssl/certs/ca-bundle.crt
- Set up authentication file for gmail
vim /etc/postfix/sasl_passwd //Paste this line and replace [smtp.gmail.com]:587 docking.email@gmail.com:<gmail_app_password>
- Create Gmail App Password For Authentication
- Log in to gmail account
- Click top right account button
- Click 'Manage Google Account'
- On the left, click the 'Security' tab
- Enable '2-step Verification'
- Now back to security tab and click 'App Passwords'
- Generate App Password
- Click 'Other' for the category input
- Copy the generated token and save somewhere