Operating System - HP-UX
1752793 Members
5965 Online
108789 Solutions
New Discussion юеВ

sendmail rule to explicitly reference aliases database

 
Jamie Harre
Occasional Advisor

sendmail rule to explicitly reference aliases database

I have a need to take an existing recipient address, eg. user@domain1.com, and rewrite it to user@domain2.com. If the user isn't in the aliases file, I need to leave it alone and let Openmail handle it. I could put all of the addresses in aliases, if I had to.
Versions: HP-UX 10.20, sendmail 8.8.6.
5 REPLIES 5
Paul Sperry
Honored Contributor

Re: sendmail rule to explicitly reference aliases database

In /etc/mail/sendmail.cf just
make sure you have the following lines

# location of alias file
O AliasFile=/etc/mail/aliases

and /etc/mail/aliases
would have

user# : user#@domain2.com
Christopher Caldwell
Honored Contributor

Re: sendmail rule to explicitly reference aliases database

Are you rewriting the envelope and locally delivering the mail, or once the envelope is rewritten, delivering the mail to another host?
Christopher Caldwell
Honored Contributor

Re: sendmail rule to explicitly reference aliases database

In re-writing, are you concerned with where the mail gets delivered, or what the envelope looks like, or both?
Jamie Harre
Occasional Advisor

Re: sendmail rule to explicitly reference aliases database

The current sendmail.cf has the aliases file defined, and a test alias is defined and newaliases has been run.
What we are currently doing is turning everything with domain1 over to Openmail, with the following rule (no line break):
R$+ domain1.co.in $* $#openmail $@ $j $: $1<$2domain1.co.in>

This server is in India, as you might guess. The rule is in ruleset 0.

My goal is to have specified users defined such that their message are rerouted to domain2, but the other users continue to get their mail the same way they do, today.

In truth, if there is a better way to acheive that goal, that would be fine. I'm only concerned that too much change will introduce too much risk. Thanks.
Christopher Caldwell
Honored Contributor

Re: sendmail rule to explicitly reference aliases database

I'd use the virtusertable feature of sendmail.

Uncomment these rulesets:
#Kvirtuser dbm /etc/mail/virtusertable

# handle virtual users
#R$+ < @ $=w . > $: < $(virtuser $1 @ $2 $@ $1 $: @ $) > $1 < @ $2 . >
#R<@> $+ + $* < @ $* . >
$: < $(virtuser $1 + * @ $3 $@ $1 $: @ $) > $1 + $2 < @
$3 . >
#R<@> $+ + $* < @ $* . >
$: < $(virtuser $1 @ $3 $@ $1 $: @ $) > $1 + $2 < @ $3 .
>
#R<@> $+ < @ $+ . > $: < $(virtuser @ $2 $@ $1 $: @ $) > $1 < @ $2 . >
#R<@> $+ $: $1
#R< error : $- $+ > $* $#error $@ $(dequote $1 $) $: $2
#R< $+ > $+ < @ $+ > $: $>97 $1


Build a file called virtusertable in /etc/mail.

On the left hand side of the file, you have an e-mail address (e.g. you@yourdomain.com); the corresponding right hand side is [user account|e-mail address|alias]

So you'd end up with something like:

you@domain1.com you@domain2.com

for each entry in the aliase table. Leave the rest alone, or specify a local account

local@domain1.com local

In addition, an e-mail address can appear on the right hand side of an entry in the alias table.

To build the virtusertable type

#/usr/sbin/makemap dbm /etc/mail/virtusertable < /etc/mail/virtusertable

Restart sendmail (to make the changes in sendmail.cf take effect).