Msmtp

From James's Wiki
Revision as of 20:37, 30 January 2021 by Ractive (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

sudo nano /etc/msmtprc

After you've on nano edit's interface you can add this configuration file and save the configuration

account default
host smtp.gmail.com
port 587
logfile /tmp/msmtp.log
tls on
tls_starttls on
tls_trust_file /etc/ssl/certs/ca-certificates.crt

auth login
user username@gmail.com
password thepassword
from First Last Name

account account2

echo -e "Subject: Test Mail\r\n\r\nThis is a test mail" |msmtp --debug --from=default -t username@gmail.com

We will create a local configuration for Mutt on ~/.muttrc. This file might not exist yet, you can create this file with the content below

set sendmail="/usr/bin/msmtp" set use_from=yes set realname="" set from=@gmail.com set envelope_from=yes

You need to change realname and from above. realname is shown as sender on recipient, while from is the email address that you'll use to send the email.


Of course you don't have to put your email directly on command line. Another way to create complete email like what we just did earlier is to create a file with the contents below. Give the file name email.txt

To: @gmail.com From: @gmail.com Subject: Email Test using MSMTP from File

Hi, This is an email test from file.

To send this email you can use command :

$ cat email.txt | msmtp -a default recipient@domain.com