nullmailer recipe for LXC containers and non-critical machines on the local network

By on 23 mai 2012, in Boulot, Debian, Informatique, Journal, Libre Software, Licorn®, LXC, System administration, Ubuntu, Work

This recipe takes place on Ubuntu 12.04 LTS, but it works also on Ubuntu 10.04.x LTS. Just install the nullmailer package, and bsd-mailx too (see later why). Apt-get will ask you some questions; you can answer whatever you want, here are what they do, with the real underlying files:

  • In case you want some local daemons to send you mail, edit /etc/nullmailer/adminaddr and fill it with a real address, eg., but not root@dev.licorn.local: this domain name is not registered, thus not considered valid. This file will be used only when a daemon sends mail with no sender at all (eg. the «  » (empty) address).
  • edit /etc/nullmailer/remotes and fill it with the IP address or FQDN of you relay. On my LXCs, this is just (the lxcbr0 address on the host). On this machine, postfix is listening and will forward mail to the outside.
  • the best part for the end: edit /etc/mailname and be sure there is a valid FQDN inside. localhost will NOT work at all, and nullmailer will produce strange errors (even if adminaddr is correctly set). In my LXC, this is simply and so on. If it’s not valid, nullmailer will complain:

    Subject: test5
    nullmailer-queue: Envelope sender address is invalid.
    nullmailer-inject: nullmailer-queue failed.
    Can’t send mail: sendmail process failed with error code 1

And the « why bsd-mailx? » answer: if you install the mailutils package (the default Debian/Ubuntu suggestion), not only will it install guile, mysql-common and other totally useless dependancies on your system, but also will it never display the nullmailer-queue error to you. As no error is reported in /var/log/mail.*, you won’t notice it and will search forever (google is not my friend at all when searching « nullmailer-queue: Envelope sender address is invalid. » ). mailutils, you are definitely banned from my machines!