Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 14 Nov 2005 09:00:08 -0600
From:      Greg Barniskis <nalists@scls.lib.wi.us>
To:        Hans Nieser <hans@nieser.net>
Cc:        freebsd-questions@freebsd.org
Subject:   Re: How to redirect mail sent to root to external mailbox?
Message-ID:  <4378A678.8040400@scls.lib.wi.us>
In-Reply-To: <43789742.4070804@nieser.net>
References:  <43789742.4070804@nieser.net>

next in thread | previous in thread | raw e-mail | index | archive | help
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 "royen.nieser.net" 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 
> "royen.nieser.net").
> 
> 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@xs4all.nl" 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 sendmail.cf 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 scls.lib.wi.us>, (608) 266-6348



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?4378A678.8040400>