Pages

Monday, 25 November 2013

Sending emails with msmtp

Install msmtp:

sudo apt-get install msmtp

then:
create a file ~/.msmtprc
then chmod 0600 ./msmtprc

Edit .msmtprc:
- - - - - - - - - - - - - - - - - 
account accountName
host smtp.gmail.com
tls on
tls_certcheck off
port 587
auth login
from user@domain.com
user user@domain.com
password  PASSWORD
account default: accountName
- - - - - - - - - - - - - - - - - 

To send e-mail, first create e-mail template, e.g:
- - - - - - - - - - - - - - - - - 
To: someone@domain.com
From: user@domain.com
Subject: TOPIC

CONTENT OF THE EMAIL
- - - - - - - - - - - - - - - - - 

and finally:

cat myscripts/sendmail.txt | msmtp -a accountName recipient@domain.com

where parameters are: "-a ACCOUNT" -> profile from .msmtprc and recipient.

Reference: http://code.google.com/p/google-gadgets-for-linux/wiki/MSMPTQuickStart

To send automatic emails about torrent completion from transmission one has to:
- set up transmission
- set up msmtp
- as my transmission runs as root as per the config in /etc/transmission-daemon, I had to place .msmtprc to root's home directory (in my case /root)