19

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?

3
  • 1
    You don't need mutt to have cron or at send mails to your gmail-account. Any properly configured MTA should be enough for that.
    – JanC
    Oct 17, 2010 at 21:12
  • I need to be able to include attachments with the outgoing mail so I thought I would need mutt for that. Oct 17, 2010 at 21:26
  • 2
    This is an important question. Lots of us set up Linux servers and need some way to mail out events and reports. In many (most!) cases, a full-blown mail server is overkill. I learned that recently setting up Postfix for such a task. I should have set up a send-only tool like one of these, and I will in the future. Oct 17, 2010 at 21:59

3 Answers 3

21

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:

  1. whether it can queue e-mails for later delivery in case of a failure: IIRC, only nullmailer can do this.

  2. whether it will replace the system mail delivery agent (look for a line Provides: mail-transport-agent in the output of apt-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, packages nullmailer, esmtp-run (but not esmtp) and ssmtp fall into this category.

  3. 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).

5
  • OK, so lets say I setup an email address like [email protected] and enable smtp on the gmail account. I could configure a client program on the server to send mail using this gmail account via SMTP and therefore avoid the complexity of a fully fledged mail server setup? Oct 17, 2010 at 21:06
  • @Griffo: Yes, this is exactly what a "send-only" MTA does; just use msmtp (as suggested in ixtmixilix' answer) or choose one from the list at the URL I have posted above. Oct 17, 2010 at 21:42
  • +1 for nullmailer... I use it on my servers, and it's very convenient. Very lightweight, relatively easy to setup. And once it works, you just don't have to bother about it anymore :) Oct 18, 2010 at 6:59
  • Also mda (The DragonFly Mail Agent) is able to queue emails for later delivery. Mar 1, 2011 at 21:47
  • It's dma, not mda (The DragonFly Mail Agent).
    – ajdev8
    Nov 20, 2014 at 22:47
6

I would recommend msmtp. Setting up other mail systems, such as sendmail, is definitely quite a hassle. Once you have msmtp setup, you can use it with mutt, and you can also masquerade it as sendmail so that programs won't know the difference between the two MTAs. Full details available on the website.

3

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:

$ sudo aptitude install mailutils ssmtp
$ sudo dpkg-reconfigure ssmtp
1
  • 1
    According to the ArchLinux wiki, ssmtp is no longer maintained and they recommend msmtp. May 5, 2017 at 14:10

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .