Christopher Juckins

SysAdmin Tips, Tricks and other Software Tools

User Tools

Site Tools


gmail_as_a_relay_on_linux

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
gmail_as_a_relay_on_linux [2020/09/30 16:07] juckinsgmail_as_a_relay_on_linux [2024/01/01 12:40] (current) juckins
Line 1: Line 1:
-===== Using Gmail as a Relay on CentOS Linux =====+===== Using Gmail as a Relay on RedHat Distro Linux =====
  
-Required packages if CentOS6 6.7\\ +RockyLinux 9 Notes
-  * postfix (tested version 2:2.6.6-6.el6_5+  * (Nothing special noted) 
-  * ca-certificates.noarch (tested version 2015.2.4-65.0.1.el6_6)+ 
 +CentOS 8 Notes: 
 +  * (Nothing special noted)
  
 Required packages if CentOS7 7.2.1511: \\ Required packages if CentOS7 7.2.1511: \\
Line 21: Line 23:
 Directions [[http://mhawthorne.net/posts/postfix-configuring-gmail-as-relay.html|based on this page by Matthew Hawthorne]]: \\ Directions [[http://mhawthorne.net/posts/postfix-configuring-gmail-as-relay.html|based on this page by Matthew Hawthorne]]: \\
  
-1. If installed, make sure /etc/ssmtp/ssmtp.conf is the distro version (no changes, is not needed on CentOS 7 and not existent on CentOS8)+1. If it exists, make sure /etc/ssmtp/ssmtp.conf is the distro version with no changes
  
 2. Make a backup copy of /etc/postfix/main.cf 2. Make a backup copy of /etc/postfix/main.cf
Line 28: Line 30:
  
 <code> <code>
-sets gmail as relay+Sets gmail as relay
 relayhost = [smtp.gmail.com]:587 relayhost = [smtp.gmail.com]:587
  
-use tls+Use tls
 smtp_use_tls=yes smtp_use_tls=yes
  
-use sasl when authenticating to foreign SMTP servers+Use sasl when authenticating to foreign SMTP servers
 smtp_sasl_auth_enable = yes  smtp_sasl_auth_enable = yes 
  
-path to password map file+Path to password map file
 smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd
  
 +# NOTE: This section *should* be configured properly in CentOS8 and RockyLinux9 by default
 # list of CAs to trust when verifying server certificate # list of CAs to trust when verifying server certificate
 #smtp_tls_CAfile = /etc/ssl/certs/ca-certificates.crt #smtp_tls_CAfile = /etc/ssl/certs/ca-certificates.crt
Line 45: Line 48:
 smtp_tls_CAfile = /etc/pki/tls/certs/ca-bundle.crt smtp_tls_CAfile = /etc/pki/tls/certs/ca-bundle.crt
  
-eliminates default security options which are incompatible with Gmail+Eliminates default security options which are incompatible with Gmail
 smtp_sasl_security_options = smtp_sasl_security_options =
  
-add debugging+Modify debugging (make sure to comment pre-existing entries)
 debug_peer_list=smtp.gmail.com debug_peer_list=smtp.gmail.com
 debug_peer_level=3 debug_peer_level=3
 </code> </code>
  
-4. Add your own Gmail credentials to /etc/postfix/sasl_passwd \\+4. Add your own Gmail credentials to /etc/postfix/sasl_passwd (the password needs to be a Google App-Specific password to get around the 2FA requirement \\
 <code> <code>
-[smtp.gmail.com]:587  username:password+[smtp.gmail.com]:587  [email protected]:GMAIL_APP_PASSWORD
 </code> </code>
  
Line 86: Line 89:
 </code> </code>
  
-9. Edit ~/.muttrc for each user as appropriate: \\+9. Add these lines to the global /etc/Muttrc.local (easier than adding it to each user's $HOME/.muttrc): \\
  
 <code> <code>
-#set from = $USER@$HOSTNAME +set from = "`whoami`@`hostname`
-#set from = username@HOSTNAME_OR_ALIAS.domain +set realname = "`whoami`@`hostname`"
-#set realname="juckins@lightning+
-set realname="$USER@$HOSTNAME(works in CENTOS7, mutt-1.5.21-26.el7.x86_64 but *not* via cron sending) +
 </code> </code>
  
Line 100: Line 100:
 mutt -s "Test1" [email protected] </dev/null mutt -s "Test1" [email protected] </dev/null
 </code> </code>
-or to send a message without using a separate file:+or to send a message without using a separate file but note mailx is probably not looking at .muttrc:
 <code> <code>
 echo 'It works' | mailx -s 'Test message' [email protected] echo 'It works' | mailx -s 'Test message' [email protected]
 +</code>
 +or 
 +<code>
 +mailx -a test.txt -s "test subject" user@domain < /dev/null
 </code> </code>
  
gmail_as_a_relay_on_linux.1601496462.txt.gz · Last modified: 2020/09/30 16:07 by juckins