Christopher Juckins

SysAdmin Tips, Tricks and other Software Tools

User Tools

Site Tools


gmail_as_a_relay_on_linux

This is an old revision of the document!


Directions based on this page by Matthew Hawthorne worked:

1. Make a backup copy of /etc/postfix/main.cf

2. Edit /etc/postfix/main.cf to have these settings:

# sets gmail as relay
relayhost = [smtp.gmail.com]:587

#  use tls
smtp_use_tls=yes

# use sasl when authenticating to foreign SMTP servers
smtp_sasl_auth_enable = yes 

# path to password map file
smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd

# list of CAs to trust when verifying server certificate
#smtp_tls_CAfile = /etc/ssl/certs/ca-certificates.crt
# Below is provided by ca-certificates package (Mozilla CA root certificate bundle)
smtp_tls_CAfile = /etc/pki/tls/certs/ca-bundle.crt

# eliminates default security options which are incompatible with Gmail
smtp_sasl_security_options =

# add debugging
debug_peer_list=smtp.gmail.com
debug_peer_level=3

2. Add your own Gmail credentials to /etc/postfix/sasl_passwd

[smtp.gmail.com]:587  username:password

3. Run the following as root:

# postmap /etc/postfix/sasl_passwd

4. Make sure the /etc/sasl_passwd* files are owned by the postfix user:

# chown postfix sasl_passwd*

5. Tighten permissions:

# chmod 600 sasl_passwd sasl_passwd.db

6. Restart postfix:

# /etc/init.d/postfix reload

or

# service postfix restart

7. Send a test message:

echo 'It works' | mailx -s 'Test message' [email protected]

8. Edit ~/.muttrc for each user as appropriate:

#set from = $USER@$HOSTNAME
#set from = username@HOSTNAME_OR_ALIAS.domain
#set realname="juckins@lightning"
set realname=$USER@$HOSTNAME

Other links:

How to send email with my CentOS server
Setting up gmail as a relay host in postfix (without creating certificates)
How To Use Gmail or Yahoo with PHP mail() Function
Updating certificates (not needed at this point)

gmail_as_a_relay_on_linux.1446679478.txt.gz · Last modified: 2015/11/04 18:24 by juckins