Technitium DNS server zone high-availability

Gmail SMTP Relay with MSMTP

msmtp is a very simple and easy to use SMTP client with fairly complete sendmail compatibility. 
It can be a ideal solution to send outgoing email with out installing a full email server like Postfix or Exim.
Let install and configure it to send outgoing email via Gmail's SMTP service. 

1. Setup Google's App passwords for SMTP relay access authentication.

2. Install msmtp-mta package. I am using it on my Ubuntu server setup.

sudo apt-get install msmtp-mta

3. Create msmtp configuration file (/etc/msmtprc) with below setting. Replace the username and password using the newly created app passwords.

defaults
tls on
# Syslog logging with facility LOG_MAIL instead of the default LOG_USER
syslog LOG_MAIL

account gmail
auth on
host smtp.gmail.com
port 587
user username
from username@gmail.com
password xxxxx

account default: gmail

4. Let do a test email using msmtp client.

printf "Subject: MSMTP Test\n\nhello there from MSMTP." | msmtp -a default username@domain.com

 

Comments