I intend to use mutt
to send automated emails via cron
or at
with attachments to my gmail address when particular events happen on my Ubuntu server. Currently, mutt
cannot send email to external email addresses, I believe this is because I need to setup a Mail Transfer Agent. How do I go about selecting a suitable MTA and how do I set it up to perform what I need it to do?
There are a few choices to be made when selecting an MTA to install; the first one is whether you want a send-only MTA or you need a fully-fledged mail server.
This Unix.SE post provides a comprehensive list of send-only MTAs available; all of them are already packaged for Ubuntu 10.10. There are a few things you might want to consider when choosing a send-only MTA:
whether it can queue e-mails for later delivery in case of a failure: IIRC, only
nullmailer
can do this.whether it will replace the system mail delivery agent (look for a line
Provides: mail-transport-agent
in the output ofapt-cache show package
). If it does, then all mail originating from the system (including reports from cron jobs, popularity statistics, etc.) will be handled by the MTA you install: if you do not set up correct mail aliases for root and other users, the email might end up delivered at the wrong address (typically, some sysadmin at your ISP). Currently, packagesnullmailer
,esmtp-run
(but notesmtp
) andssmtp
fall into this category.All send-only MTAs will just forward your email to another server (called "relay host" or "smarthost"; typically it's your ISP's SMTP server) and then let it handle all the details of real Internet mail delivery. You need to figure out whether there are any special requirements for connecting to the ISP server (e.g., some kind of authentication or TLS) and choose an MTA that supports the required features (for instance,
ssmtp
does not support any kind of authentication or SSL/TLS).Fully-fledged mail servers include exim, postfix, and sendmail. The post-installation installation script for Debian/Ubuntu will do a great job of producing a working configuration for some common setup (delivery of mail to the local system only; sending email through a "smarthost" -- i.e., a mail server you funnel all your emails through, typically your ISP's SMTP host; internet site with full inbound and outbound connectivity). IMHO, postfix is the easiest to run and configure, but since it's so capable, its configuration manual is way longer than any of the send-only MTAs.
In addition, the real risk with setting up a mail server is that, if you make a mistake in the local configuration, you end up with mail delivered to the wrong place (read: lost) or -worse- with an open-relay system that can be used by spammers (and, trust me, they can find an open relay before you realize your server is one).
My advice would be then to start with a send-only MTA and then upgrade to a full mail server only if you see the need for it (which is not the case if you just want to send emails to your GMail address).
I would recommend
msmtp
. Setting up other mail systems, such assendmail
, is definitely quite a hassle. Once you havemsmtp
setup, you can use it withmutt
, and you can also masquerade it assendmail
so that programs won't know the difference between the two MTAs. Full details available on the website.The links below provides all the MTA choices you can choose, according to your Ubuntu version:
http://packages.ubuntu.com/precise/mail-transport-agent (for 12.04)
http://packages.ubuntu.com/trusty/mail-transport-agent (for 14.04)
Personally, I found that
ssmtp
is very easy to setup and run, just 2 commands will do: