I read all my email via IMAP, and send all email via external SMTP servers, but at times it’s really useful to be able to run something like
/usr/sbin/sendmail to send an email. Many tools depend on it, for me I want reports on
cron jobs and I like using
darcs send straight to an email address. For this a full-fledged SMTP server like exim/postfix/sendmail clearly is overkill. First I had a quick look at ssmtp but it only allows for a system-wide configuration file. Ideally I’d like “system-mails” (like
cron) to be sent via my ISP while more personal emails should be sent via my Google account. After a suggestion on the Arch mailing list I checked out msmtp and it was exactly what I was looking for.
/etc/msmtprc with the following contents:
defaults logfile ~/.msmtp.log # MyISP account myisp host smtp.myisp.com from firstname.lastname@example.org account default : myisp
I then found out that [dcron] is severely limited; it doesn’t honour
crontabs and it’s not possibly to use anything but
/usr/sbin/sendmail to send emails. The lack of support for
MAILTO is the deal breaker in this case.
Rather than create a symbolic link I modified
fcron‘s configuration file,
/etc/fcron/fcron.conf, to use
sendmail = /usr/bin/msmtp
I also made sure to stick
MAILTOemail@example.com in the system
fcrontab -u systab -e.
Then I created the file
defaults logfile ~/.msmtp.log # MyISP account mysisp host smtp.myisp.com from firstname.lastname@example.org # google account google host smtp.gmail.com from email@example.com tls on tls_certcheck off auth on user firstname.lastname@example.org password MySecretPassword account default : google
Finally I put
MAILTOemail@example.com in my user’s