Christopher Juckins

SysAdmin Tips, Tricks and other Software Tools

User Tools

Site Tools


gmail_on_linux_with_ssmtp

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_on_linux_with_ssmtp [2015/04/04 15:41] juckinsgmail_on_linux_with_ssmtp [2015/11/04 18:12] juckins
Line 33: Line 33:
  
 IO::Socket::INET6: connect: Network is unreachable IO::Socket::INET6: connect: Network is unreachable
 +
 +Test was:  $ swaks -tls -f [email protected] -t [email protected] -s smtp.mail.yahoo.com:587 -a LOGIN 
  
 Seemed to be an IPv6 problem.  Seemed to be an IPv6 problem. 
 +
 +Additional info for CentOS6:
  
 [[https://voidtech.wordpress.com/2014/03/11/configuring-send-emails-using-gmail-account-in-centos-6-with-ssmtp/]] [[https://voidtech.wordpress.com/2014/03/11/configuring-send-emails-using-gmail-account-in-centos-6-with-ssmtp/]]
 +
 +
 +----
 +
 +4 November 2015
 +
 +Gmail stopped working.  Try a PHP or Perl solution?  Does it require SSMTP or MSMTP?
 +
 +This did not work: https://productforums.google.com/forum/?hl=en#!topic/gmail/2tK2fR7yW-k;context-place=forum/gmail
 +
 +
 +Directions [[http://mhawthorne.net/posts/postfix-configuring-gmail-as-relay.html|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:
 +
 +<code>
 +# 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
 +</code>
 +
 +2. Add your own Gmail credentials to /etc/postfix/sasl_passwd \\
 +<code>
 +[smtp.gmail.com]:587  username:password
 +</code>
 +
 +3. Run the following as root: \\
 +<code>
 +# postmap /etc/postfix/sasl_passwd
 +</code>
 +
 +4. Make sure the /etc/sasl_passwd* files are owned by the postfix user: \\
 +<code>
 +# chown postfix sasl_passwd*
 +</code>
 +
 +5. Tighten permissions: \\
 +<code>
 +# chmod 600 sasl_passwd sasl_passwd.db
 +</code>
 +
 +6. Restart postfix: \\
 +<code>
 +# /etc/init.d/postfix reload
 +</code>
 +or
 +<code>
 +# service postfix restart
 +</code>
 +
 +7. Send a test message: \\
 +<code>
 +echo 'It works' | mailx -s 'Test message' [email protected]
 +</code>
 +
 +8. Check mutt configuration for proper "From" settings.  
 +
 +Other links:\\
 +
 +[[http://serverfault.com/questions/194376/how-to-send-email-with-my-centos-server|How to send email with my CentOS server]] \\
 +[[http://rs20.mine.nu/w/2011/07/gmail-as-relay-host-in-postfix/|Setting up gmail as a relay host in postfix (without creating certificates)]] \\
 +[[https://www.digitalocean.com/community/tutorials/how-to-use-gmail-or-yahoo-with-php-mail-function|How To Use Gmail or Yahoo with PHP mail() Function]] \\
 +[[https://techjourney.net/update-add-ca-certificates-bundle-in-redhat-centos/|Updating certificates]] (not needed at this point)
gmail_on_linux_with_ssmtp.txt · Last modified: 2016/10/22 08:29 by juckins