Summary : Redirect all mail sent from box to a single address (sendmail)

From: Alex Dyas <alex.dyas_at_psineteurope.com>
Date: Wed Aug 03 2005 - 03:52:47 EDT
All,

Thanks to those who responded.  Bertrand Hutin's suggestion of looking 
at the SEnvToSMTP Sendmail rule set lead me to do something I've been 
putting off for years, namely delve into the world of Sendmail rewrite 
rules.  After a bit of trial and error (sendmail -bt is your friend 
here) I found that the following hard wired rule added to the default 
Solaris sendmail.cf file seems to do the trick :

<snip>
############################################
###  Ruleset 3 -- Name Canonicalization  ###
############################################
Scanonify=3

# handle null input (translate to <@> special case)
R$@                     $@ <@>

# <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< Redirect all mail
DRrecipient@yourdomain.com
R$+                     $: $R # Hard coded recipient, see R macro above
# >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

# strip group: syntax (not inside angle brackets!) and trailing semicolon
R$*                     $: $1 <@>                       mark addresses
R$* < $* > $* <@>       $: $1 < $2 > $3                 unmark <addr>
R@ $* <@>               $: @ $1                         unmark @host:...
</snip>

In this case recipient@yourodmain.com is the hard coded recipient.

The 'R' macro definition is shown here just above the actual rewrite 
rule to make it easier to understand what it going on, but moving it to 
the top of the file is probably neater and more maintainable.

The O'Reilly 'Bat' book "Sendmail" is a wise investment for anyone who 
is interested in this.

--//--

Hutin Bertrand wrote:
 > not easy, because you can't set aliases for external addresses.
 > you have to fix /etc/mail/sendmail.cf
 > around this
 >
 > you have to customize recipient address rewriting rule to replace the 
real
 > address
 > by the one you want.
 > May be fixing this rule or one of the called ones.
 > #
 > #  envelope recipient rewriting --
 > #  also header recipient if not masquerading recipients
 > #
 > SEnvToSMTP
 > R$+                     $: $>PseudoToReal $1            sender/recipient
 > common
 > R$+                     $: $>MasqSMTP $1                qualify unqual'ed
 > names
 > R$* < @ *LOCAL* > $*    $: $1 < @ $j . > $2

--//--

Dyas, Alex wrote:
> Hi,
> 
> (Solaris 9)
> 
> We have two machines, production and development.  The production system
> as one of its tasks sends mail to various external addresses.  To keep
> the development system as close to production as possible we would like
> to retain this functionality, BUT, we would like all mail generated on
> the machine to be redirected to a single external address.
> 
> In other words, we would like this mail redirection to happen at the OS
> level, not the application level.
> 
> We are using the default Solaris sendmail installation as the MTA.
> 
> How best to achieve this?
> 
> Thanks,
> 
> Alex.
> -- 
> Alex Dyas , UNIX , PSINet , Geneva
> _______________________________________________
> sunmanagers mailing list
> sunmanagers@sunmanagers.org
> http://www.sunmanagers.org/mailman/listinfo/sunmanagers
_______________________________________________
sunmanagers mailing list
sunmanagers@sunmanagers.org
http://www.sunmanagers.org/mailman/listinfo/sunmanagers
Received on Wed Aug 3 04:07:53 2005

This archive was generated by hypermail 2.1.8 : Thu Mar 03 2016 - 06:43:50 EST