How to redirect mail sent to root to external mailbox?

Mark J. Sommer msommer at
Mon Nov 14 14:41:13 GMT 2005

> -----Original Message-----
> From: owner-freebsd-questions at 
> [mailto:owner-freebsd-questions at] On Behalf Of Hans Nieser
> Sent: Monday, November 14, 2005 6:55 AM
> To: freebsd-questions at
> Subject: How to redirect mail sent to root to external mailbox?
> 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!
> Also, when I ssh to the royen machine and type "periodic 
> daily" on the commandline, the mail it generates DOES get 
> masqueraded correctly... 
> What's going on here? I'm having a real hard time getting my 
> head around this because of all the redirecting and 
> forwarding and perhaps lack of in-depth knowledge of 
> smtp/sendmail... I have my sendmail configuration attached 
> (also mirrored at ).
> I'd rather keep the nieser.local/ domainnames 
> seperate and use masquerading because the whole NAT setup is 
> confusing enough for me as it is, having the same domainname 
> resolve to different adresses for the LAN and the Internet 
> would probably drive me mad.
> Can anyone assist?
> PS: The domainnames used in my problem description above may 
> not actually resolve as I've tried to simplify my problem by 
> using more logical names.

This is really a sendmail question I believe.  Your problem is probably
because root doesn't get masqueraded.  In your, is there a line
like the following:




If so, comment it out and restart sendmail.

More information about the freebsd-questions mailing list