June 7, 2011
ssmtp and aliasing the TO-address
I ran into a rather annoying problem today, Gentoo had pulled in ssmtp and it had started to send out mails, but since root@localhost didn’t really go anywhere everything got sent to my host’s support address, which they weren’t very happy about (sorry).
My setup up to then had been using nailx (portage: mail-client/nail) as a mailx replacement since it supports sending mails straight to an SMTP server but since I already had ssmtp now (which I didn’t know about when I set this up) I figured I’d try setting that up correctly so I could finally be rid of the dead.letter files in my homedirectories. Setting up ssmtp to send mail to an smtp server proved fairly trivial, however aliasing “root” to something more useful proved a bit harder, or rather, the information on how excatly to go about it proved to be fairly hard to find at least if you don’t know what you’re looking for.
My first intuition was to use ssmtp’s revaliases, unfortunatley that doesn’t quite work as it aliases the from-address, not the to-address. A bit of Googling later I found out about /etc/mail/aliases but that file isn’t supported by ssmtp at all (although it oddly is present on my system).
In the end it turned out I needed to use mailx (portage: mail-client/mailx) instead of nailx to provide the mail program so I then could edit /etc/mail.rc like this:
alias root root<email@example.com>
This of course also works for accounts other than root and it seems to work just fine. I’m sure the nice folks at Benesol will be able to appreciate it.