June 7, 2011

ssmtp and aliasing the TO-address

Posted in Gentoo, Linux, Techie stuff at 21:40 by theBlackDragon

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<root@myremoteaddress.be>
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.

Advertisements

3 Comments »

  1. john said,

    finally a post related to this issue! thanks so much! its really frustrating. I have a question, i still cant get this to work. the To: is still being sent from my ubuntu host name name@ubuntu for example. How do you get the mail.rc file? do you just create it yourself in the /etc folder? and what else do you need in there? are just the alias commands enough? I still couldnt get ssmtp to work with what you said 😦

    • Apologies for the (very) late reply.

      You need the mailx package, on Debian this package is named bsd-mailx. I have no idea about Ubuntu though. It should provide a default configuration file to which you can just add the alias.

  2. Anonymous said,

    In ssmtp.conf file add a row

    root=myname@where.you.want

    to which will be forwarded all email for user with uid < 1000


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s