How to redirect mail sent to root to external mailbox?

Greg Barniskis nalists at
Mon Nov 14 15:00:28 GMT 2005

Hans Nieser wrote:
> Hi list,
> I operate several servers, one of which is at home, behind NAT. The 
> local network is configured to use the domainname "nieser.local.", which 
> obviously only exists on the local (forwarding) nameserver.
> To be able to send e-mail from this machine (which would normally be 
> rejected by any MTA because of the non-existent 'from' domainname ) I 
> have configured sendmail to masquerade e-mail sent from the 
> "royen.nieser.local" machine as "" which resolves to the 
> external IP adress of the DSL gateway device (which has smtp forwarded 
> to the royen.nieser.local machine).
> The above setup *mostly* (see below) works, e-mail that I send from the 
> server has it's "royen.nieser.local" hostname properly substituted with 
> "").
> Now, to make monitoring all the servers I operate easier, I wanted to 
> forward all mail sent to root (including the periodic output), by 
> putting "root: h.nieser at" in the /etc/mail/aliases file, as the 
> comments in this file suggested:
> # Pretty much everything else in this file points to "root", so
> # you would do well in either reading root's mailbox or forwarding
> # root's email from here.
> But here's the weird thing, the periodic mail doesn't get masqueraded 
> and   therefore gets rejected by the remote MTA. The "rejected" message 
> which  gets sent back to the root account, however, *does* get 
> masqueraded properly and subsequently forwarded to the e-mail I 
> specified in the /etc/mail/aliases file!

Mail originating from the root account is usually not masqueraded. 
In sendmailese, root is "Class E", so your probably 
shows "CE root". You can probably override this by putting an 
appropriate entry in your .mc file and then making a new config file 
from it, but offhand I don't know what mc syntax you'd use.

Your bounces get masqueraded because the outside envelope is not 
"From root" anymore, it is From your mailer daemon.

Greg Barniskis, Computer Systems Integrator
South Central Library System (SCLS)
Library Interchange Network (LINK)
<gregb at>, (608) 266-6348

More information about the freebsd-questions mailing list