A different UNIX Part I: Mail in not-mail-servers
I have been procrastinating about creating my own Linux distro for at least three years. Guess what? I will still procrastinate about it for a few more, but that doesn mean I can't write about how it's supposed to work ;-)
So, here is a first piece of the puzzle...
What do I mean by "Main in not-mail-servers"?
If by mail server we mean a box that has the responsability to handle sending mail for users, non-mail-servers are all the rest.
And what is it they do with mail? They generate it. Both the users and the processes of those boxes generate mail. They do it for cron jobs, they do it for maintenance processes, they do it for alerts, whatever.
And what is it they do with that email? They send it somewhere.
Usually, they send it to themselves. Which is a pretty useless thing.
Go now and check the root mailbox in your computers. I bet most of you have a bunch of mails in them you never checked. Either it's important, in which case you should have placed it in a mailbox you actually read, or it's not, in which case it's useless to store.
In any case, it shouldn't be there.
How does your box send those mails? Using either the sendmail binary, or the mail program (probably mailx), which uses the sendmail binary.
Just because it's called sendmail it doesn't mean it is sendmail, of course. Postfix and qmail provide a sendmail wrapper to inject mail into their queues.
But the main problem is that using those means you need to have a well configured mail server in every box, even if they are not mail servers! Yes, your distro gives you a decent configuration by default which makes things usually work... for local mail delivery at least. Which is probably not really what you want.
Enter nullmailer. A sort of heavily sedated, neutered qmail.
Configuration:
Default domain name of outgoing mail in /etc/nullmailer/me
-
List of SMTP servers in /etc/nullmailer/remotes:
mx1.mydomain.com smtp --user=ralsina --pass=notmyrealpass
You can put several, it will try them in order.
And that's that. A tiny service, which uses no TCP ports. The whole thing is 59KB (or less if you use diet libc), has one SUID binary (but it is not SUID root), two config files (both one-liners), no need for aliasing the system users.... and you can remove postfix/sendmail/qmail from most of your servers.
Sounds like a good idea to me.
OK, but will nullmailer do local delivery for me? :P
Kubuntu and sibling distros no longer ship with a mail server by default.
Another (easier) way would be to use a tool called Nail. It is derived from Berkeley Mail and include out of the box POP and SMTP. So no need for a local mail server whatsoever.
ssmtp - one config file.
Gilles: Nail sends directly to SMTP. That is not useful for apps that call sendmail directly.
And how is it easier?
Jonathan: sure. No mail server. So how do you get cron notifications?
Removing the functionality is not the answer, IMHO.
Andrey: Of course not. You need a real mail server for that. The right tool for the right job. Not every box needs to be a mail server (or have local delivery).
Andy: ssmtp (besides the unfortunate name) may be an alternative... If I could find it ;-)
Oh, sorry.
Current sources can be found at http://packages.debian.org/...
Ok, ssmtp is a bit too simple (although I just read the description, I can be very wrong!).
If it can't deliver the mail immediately, it throws it away?