Skip to content

Instantly share code, notes, and snippets.

@ahgood
Forked from mikesmullin/msmtp.sh
Created March 11, 2019 21:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ahgood/243572f3ef13f9c1047c31b68fdfacd0 to your computer and use it in GitHub Desktop.
Save ahgood/243572f3ef13f9c1047c31b68fdfacd0 to your computer and use it in GitHub Desktop.
install msmtp gmail, a localhost sendmail alternative
# setup msmtp for sending out email
# as an alternative to sendmail
# i prefer this because it is easier to install and configure than sendmail
# especially when using Gmail smtp servers
sudo -i
apt-get install msmtp
ln -s /usr/bin/msmtp /usr/sbin/sendmail
touch /var/log/msmtprc && chmod 666 /var/log/msmtprc
vim /etc/msmtprc
# config options: http://msmtp.sourceforge.net/doc/msmtp.html#A-user-configuration-file
defaults
logfile /tmp/msmtp.log
# gmail account
account gmail
auth on
host smtp.gmail.com
port 587
user your.account@gmail.com
password yourpassword
from your.account@gmail.com
tls on
tls_trust_file /usr/share/ca-certificates/mozilla/Equifax_Secure_CA.crt
# set default account to use
account default : gmail
:wq
# now test msmtp
sendmail me@example.com # use your own email address
Subject: testing
hello
# Ctrl+D to send
# check email to ensure it arrived
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment