Configuring mail system on Debian for ordinary user

1's picture

Software: 

echo "I always thought that the most comfortable way to send email is to use 'mail' "|mail -s "Sending/Receiving mail howto suitable for single computer configuration" -a AnAttachment.tar.gz interested@world.org

What follows developed out of my attempt to replicate the usability of "mail" from the office network to my personal computer.

My first idea was to put to use exim4 which already sits somewhere in the background of every freshly installed Debian system. Exim4 is a MTA, which means that it handles email communication to and from the network your computer is part of. Now, my netbook is not a permanent part of any local network so exim4 is, probably, an overkill. In addition, I have multiple email accounts on several different email providers which are used interchangeably. Making this work with exim feels like asking an army general to take the cat off the tree.

It turns out there is a simple and clever tool called msmtp designed precisely to transfer mail from the local machine via SMTP to one or more remote email providers.

To start using it, create .msmtprc in home:
######
# defaults
defaults
tls on
#tls_starttls off
tls_trust_file /etc/ssl/certs/ca-certificates.crt
logfile ~/.msmtp.log

# account1
account account1
host mail.secure.example.net
from one@example.net
auth on
user *****
password ******

# additional accounts
.
.
.

account default : account1
######

Then, edit .mailrc and write: "set sendmail=/usr/bin/msmtp"

With mail and msmtp configured, you can test the setup. For example:
echo "My bones!"|mail -s "Your spine needs stretching" conscience@mind.biz

mail command is able to send mail only from one email account (listed in "account default" line of .msmtp). Mutt, though, works very well with msmtp and will be able to send emails using any of the accounts in the resource file. This is easy to set up, "info msmtp" is a good reference.

EDIT1: consider uncommenting "tls_starttls off" in .msmtprc if you start getting "sendmail: 'the server sent an empty reply'" errors.

The part on getmail and procmail follows ....