Christopher Juckins

SysAdmin Tips, Tricks and other Software Tools

User Tools

Site Tools


gmail_on_linux_with_ssmtp

This is an old revision of the document!


Sending email on linux using SSMTP.

http://www.nixtutor.com/linux/send-mail-with-gmail-and-ssmtp/

http://wiki.debian.org/sSMTP

http://www.terminally-incoherent.com/blog/2006/09/29/mutt-with-ssmtp/

Edit ~/.muttrc for each user as appropriate:

set sendmail="/usr/sbin/ssmtp"
#set from = $USER@$HOSTNAME
#set from = username@HOSTNAME_OR_ALIAS.domain
set realname="juckins@lightning"

If you get an error like "Cannot open mailhub:25" you need to add the problematic user to the "mail" group. See information on setting permissions here:

https://wiki.archlinux.org/index.php/SSMTP

Update 26 January 2014:

Gmail stopped sending, found information at http://serverfault.com/questions/560728/linux-ssmtp-error-cannot-open-smtp-gmail-com587

Add this line to /etc/ssmtp/ssmtp.conf

TLS_CA_File=/etc/pki/tls/certs/ca-bundle.crt

Update 4 April 2015:

Gmail stopped sending, couldn't connect to smtp server per /var/log/maillog errors. It suddenly started working again. Used "swaks" to troubleshoot per http://nekhbet.com/ssmtp_yahoo.shtml and saw this error:

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.

Additional info for CentOS6:

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

Try these links:

https://www.digitalocean.com/community/tutorials/how-to-use-gmail-or-yahoo-with-php-mail-function
http://serverfault.com/questions/194376/how-to-send-email-with-my-centos-server
http://rs20.mine.nu/w/2011/07/gmail-as-relay-host-in-postfix/

These directions based on this page 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 Gmail creds 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. Check mutt configuration for proper "From" settings.

gmail_on_linux_with_ssmtp.1446678399.txt.gz · Last modified: 2015/11/04 18:06 by juckins