Ir al contenido principal

Ralsina.Me — El sitio web de Roberto Alsina

A different UNIX Part I: Mail in not-mail-servers

I have been pro­cras­ti­nat­ing about cre­at­ing my own Lin­ux dis­tro for at least three years. Guess what? I will still pro­cras­ti­nate about it for a few more, but that doesn mean I can't write about how it's sup­posed to work ;-)

So, here is a first piece of the puz­zle...

What do I mean by "Main in not-­mail-server­s"?

If by mail serv­er we mean a box that has the re­spon­s­abil­i­ty to han­dle send­ing mail for user­s, non-­mail-servers are all the rest.

And what is it they do with mail? They gen­er­ate it. Both the users and the pro­cess­es of those box­es gen­er­ate mail. They do it for cron job­s, they do it for main­te­nance pro­cess­es, they do it for alert­s, what­ev­er.

And what is it they do with that email? They send it some­where.

Usu­al­ly, they send it to them­selves. Which is a pret­ty use­less thing.

Go now and check the root mail­box in your com­put­er­s. I bet most of you have a bunch of mails in them you nev­er checked. Ei­ther it's im­por­tan­t, in which case you should have placed it in a mail­box you ac­tu­al­ly read, or it's not, in which case it's use­less to store.

In any case, it should­n't be there.

How does your box send those mail­s? Us­ing ei­ther the send­mail bi­na­ry, or the mail pro­gram (prob­a­bly mailx), which us­es the send­mail bi­na­ry.

Just be­cause it's called send­mail it does­n't mean it is send­mail, of course. Post­fix and qmail pro­vide a send­mail wrap­per to in­ject mail in­to their queues.

But the main prob­lem is that us­ing those means you need to have a well con­fig­ured mail serv­er in ev­ery box, even if they are not mail servers! Yes, your dis­tro gives you a de­cent con­fig­u­ra­tion by de­fault which makes things usu­al­ly work... for lo­cal mail de­liv­ery at least. Which is prob­a­bly not re­al­ly what you wan­t.

En­ter null­mail­er. A sort of heav­i­ly se­dat­ed, neutered qmail.

Con­fig­u­ra­tion:

  • De­­fault do­­main name of out­­­go­ing mail in /etc/nul­l­­mail­er/me

  • List of SMTP servers in /etc/null­mail­er/re­motes:

    mx1.mydomain.com smtp --user=ralsina --pass=notmyrealpass

You can put sev­er­al, it will try them in or­der.

And that's that. A tiny ser­vice, which us­es no TCP port­s. The whole thing is 59KB (or less if you use di­et libc), has one SUID bi­na­ry (but it is not SUID root), two con­fig files (both one-­lin­er­s), no need for alias­ing the sys­tem user­s.... and you can re­move post­fix/send­mail/q­mail from most of your server­s.

Sounds like a good idea to me.

Andrey / 2006-10-02 14:30:

OK, but will nullmailer do local delivery for me? :P

Jonathan Riddell / 2006-10-02 14:31:

Kubuntu and sibling distros no longer ship with a mail server by default.

Gilles / 2006-10-02 14:52:

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.

Andy / 2006-10-02 16:06:

ssmtp - one config file.

Roberto Alsina / 2006-10-02 17:28:

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 ;-)

Andy / 2006-10-04 13:57:

Oh, sorry.

Current sources can be found at http://packages.debian.org/...

Roberto Alsina / 2006-10-04 14:34:

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?


Contents © 2000-2023 Roberto Alsina