Skip to content

Latest commit

 

History

History
49 lines (32 loc) · 914 Bytes

gmail-smtp-command-line.md

File metadata and controls

49 lines (32 loc) · 914 Bytes

Using Gmail SMTP from command line

Install msmtp

emerge mail-mta/msmtp

Configure

Create file /etc/msmtprc

# Set default values for all following accounts.
defaults
auth on
tls on
tls_certcheck off
tls_starttls off
logfile /var/log/mail.log

# Gmail account
account gmail
host smtp.gmail.com
port 465
from [email protected]
user someuser
password mySecretPassword

# Set a default account
account default : gmail

Make it defaul (only required for Debian, Gentoo already does it)

ln -s /usr/bin/msmtp /usr/bin/sendmail

Test

One liner

(echo "Subject: SUBJECT"; echo; echo "MESSAGE") | msmtp [email protected]

With a non default account

(echo "Subject: SUBJECT"; echo; echo "MESSAGE") | msmtp -a anotherAccount [email protected]

Multiple lines (Press Ctrl+D to send)

sendmail [email protected]
Subject: SUBJECT

MESSAGE