The Linux Page

Ubuntu does not install an MTA by default, so CRON errors go to oblivion!

A message in a bottle, you might as well not ever bother...

Today I learned that by default Ubuntu doesn't install an MTA.

I've been installing Postfix on my computers and never noticed that because it's like part of the things I install even before I start doing anything on my computer.

However, a default basic Ubuntu install comes bare and does not offer a sendmail tool.

Looking at a certain number of computers, I noticed that the /var/mail folder was empty. That in itself wasn't really anything to worry about, but I was still wondering, how come?! I run CRON on those 13 computers and it never fails??? Oh yeah because on my computer I get a lot of CRON failures in there. Especially, I see when a new package comes with a CRON script that fails really bad. That means we have to fix the script, obviously, but how do you know that it fails if it gets run by a server and nothing is there to tell you that it failed? (well, there should be some entries in syslog. Those we never check...)

So since I specifically wanted to have a report from any CRON run that returned something, I looked into how CRON determines which MTA to use. The code actually uses the following:

#include </usr/include/paths.h>

#if !defined(_PATH_SENDMAIL)
# define _PATH_SENDMAIL "/usr/lib/sendmail"
#endif /*SENDMAIL*/


if ((statret = stat(MAILCMD, &mcsb)) != 0)

The stat() checks whether the MTA exists. As we can see there is an expected default set to:


However, under Linux the _PATH_SENDMAIL is defined in /usr/include/paths.h and set to:


So that sendmail tool has to exist there (And that's where Postfix places its own instance of sendmail.)

Further, CRON uses the following command line attributes:

#define MAILARGS "%s -i -FCronDaemon -B8BITMIME -oem %s"

So if you need CRON to work 100% on a computer you administer, make sure you get some form of MTA to get the error messages in your mailbox.

At this point, I'm contemplating creating my own sendmail too using libcurl to do the SMTP work and a simple fopen() in append mode to save the message in a file when the SMTP fails to forward the email. This is a very small tool that should be quick to run and be pretty small. It will be part of Snap! I am talking about that because some servers have Postfix installed on them and that sends emails just fine, others have nothing. My new package would resolve the issue by offering a way to forward the emails by SMTP or save them in /var/mail.