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/adminaddrand fill it with a real address, eg.
email@example.com, but not
firstname.lastname@example.org: 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).
/etc/nullmailer/remotesand fill it with the IP address or FQDN of you relay. On my LXCs, this is just
lxcbr0address on the host). On this machine,
postfixis listening and will forward mail to the outside.
the best part for the end: edit
/etc/mailnameand be sure there is a valid FQDN inside.
localhostwill NOT work at all, and
nullmailerwill produce strange errors (even if
adminaddris correctly set). In my LXC, this is simply
dev.licorn.organd so on. If it’s not valid, nullmailer will complain:
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
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!