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
Next revisionBoth sides next revision
gmail_as_a_relay_on_linux [2015/11/04 18:24] juckinsgmail_as_a_relay_on_linux [2023/06/23 10:29] juckins
Line 1: Line 1:
-Directions [[http://mhawthorne.net/posts/postfix-configuring-gmail-as-relay.html|based on this page by Matthew Hawthorne]] worked: \\+===== Using Gmail as a Relay on CentOS Linux =====
  
-1. Make a backup copy of /etc/postfix/main.cf+Required packages if CentOS7 7.2.1511: \\ 
 +  * postfix (tested version 2.10.1-6.el7 ) 
 +  * ca-certificates.noarch (tested version 2015.2.4-70.0.el7_1) 
 +  * cyrus-sasl-plain (tested version 2015.2.6-70.1.el7_2) 
 +    * Got hint that this is needed from [[http://www.postfix.org/SASL_README.html#client_sasl_policy|Postfix config]] 
 +  * cyrus-sasl-lib (tested version 2.1.26-20.el7_2)
  
-2. Edit /etc/postfix/main.cf to have these settings:+Other CentOS 7 Notes: 
 +  * Best to use this version of mutt: mutt-1.6.2-1.fc22.x86_64.rpm 
 +    * Otherwise, you may get errors like: Bad IDN in "from": 'tidewater.�' 
 +  * /etc/resolv.conf may need the 'search' pattern, ex: search attlocal.net 
 +    * As root, run 'nmtui' to set network parameters 
 +  * If trouble sending after install, may need to consult [[http://unix.stackexchange.com/questions/109473/after-updating-ssmtp-to-version-2-61-i-cannot-send-mail-via-gmail|this link]] 
 + 
 +CentOS 8 Notes: 
 +  * (Nothing special noted) 
 + 
 +RockyLinux 9 Notes: 
 +  * ? 
 + 
 +Directions [[http://mhawthorne.net/posts/postfix-configuring-gmail-as-relay.html|based on this page by Matthew Hawthorne]]: \\ 
 + 
 +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 
 + 
 +3. Edit /etc/postfix/main.cf to have these settings:
  
 <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 23: 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
 debug_peer_list=smtp.gmail.com debug_peer_list=smtp.gmail.com
 debug_peer_level=3 debug_peer_level=3
 </code> </code>
  
-2. Add your own Gmail credentials to /etc/postfix/sasl_passwd \\+4. Add your own Gmail credentials to /etc/postfix/sasl_passwd \\
 <code> <code>
 [smtp.gmail.com]:587  username:password [smtp.gmail.com]:587  username:password
 </code> </code>
  
-3. Run the following as root: \\+5. Run the following as root: \\
 <code> <code>
 # postmap /etc/postfix/sasl_passwd # postmap /etc/postfix/sasl_passwd
 </code> </code>
  
-4. Make sure the /etc/sasl_passwd* files are owned by the postfix user: \\+6. Make sure the /etc/sasl_passwd* files are owned by the postfix user: \\
 <code> <code>
 # chown postfix sasl_passwd* # chown postfix sasl_passwd*
 </code> </code>
  
-5. Tighten permissions: \\+7. Tighten permissions: \\
 <code> <code>
 # chmod 600 sasl_passwd sasl_passwd.db # chmod 600 sasl_passwd sasl_passwd.db
 </code> </code>
  
-6. Restart postfix: \\+8. Restart postfix: \\ 
 +<code> 
 +# /bin/systemctl restart postfix.service 
 +</code> 
 +or
 <code> <code>
 # /etc/init.d/postfix reload # /etc/init.d/postfix reload
Line 60: Line 89:
 </code> </code>
  
-7Send a test message: \\+9Add these lines to the global /etc/Muttrc.local (easier than adding it to each user's $HOME/.muttrc): \\ 
 <code> <code>
-echo 'It works' | mailx -s 'Test message' recipient@domain.com+set from = "`whoami`@`hostname`" 
 +set realname = "`whoami`@`hostname`"
 </code> </code>
  
-8Edit ~/.muttrc for each user as appropriate\\ +10Send a test message: \\ 
 +<code> 
 +mutt -s "Test1" [email protected] </dev/null 
 +</code> 
 +or to send a message without using a separate file but note mailx is probably not looking at .muttrc: 
 +<code> 
 +echo 'It works' | mailx -s 'Test message' [email protected] 
 +</code> 
 +or 
 <code> <code>
-#set from = $USER@$HOSTNAME +mailx -a test.txt -s "test subjectuser@domain < /dev/null
-#set from = username@HOSTNAME_OR_ALIAS.domain +
-#set realname="juckins@lightning" +
-set realname=$USER@$HOSTNAME+
 </code> </code>
  
gmail_as_a_relay_on_linux.txt · Last modified: 2024/01/01 12:40 by juckins