I want to send a simple email from my ubuntu terminal to my GMail account (in the event that mdadm fails, or a python script generates a fatal exception). On this machine I have Thunderbird installed and working. I have installed mailutils. My ~/.msmtprc
file is as follows:
logfile ~/msmtp.log
account gmail
auth login
host smtp.gmail.com
from [email protected]
tls off
user [email protected]
password ********
port 587
account default : gmail
When I run mail -s "My Subject" "[email protected]"
from the terminal, I press return at the Cc: prompt, enter some text for the body, then press Ctrl-D, I get the following errors:
msmtp: no recipients found
Sending data to /usr/bin/msmtp failed: Process exited with a non-zero status
cannot send message: Process exited with a non-zero status
If I use msmtp "[email protected]"
at the terminal (it doesn’t seem to allow me to enter a subject), enter some body text, press Ctrl-D, I get the error: msmtp: /data/stuart/.msmtprc: line 13: account default was already defined
. If I remove the Account default entry from ~/.msmtprc
I get the error msmtp: account default from /data/stuart/.msmtprc: host not set
.
I believe that sending emails to a Gmail address is slightly more complicated, but I am not sure what I need to do about it. I have seen many different versions of the ~/.msmtprc
file but I don’t know which is correct.
Can anybody tell me what I am doing wrong please?