Problem
I would like to configure sendmail on my mail server to forward
mail addressed to a specific domain to a different domain. I
don't want all of my mail to be forwarded, so I can't set up the
server to forward all mail to a different server. Solution
As root, edit the file /usr/lib/sendmail.cf.Go to Ruleset 0 by searching for the entry S0. You should
see an entry that looks similar to the following:# handle numeric address spec
R$* < @ [ $+ ] > $* $: $>98 $1 < @ [ $2 ] > $3
R$* < @ [ $+ ] > $* $#smtp $@ [$2] $: $1 < @ [$2] > $3Make the following entry, where bar.com is the domain name of the domain you want to forward, and test.com is the domain name of the address you want mail forwarded to.
R$* < @ bar . com . > $#smtp $@ test.com $: $1 < @ bar.com >When you're finished, you should have an entry that looks similar to the following:
# handle numeric address spec
R$* < @ bar . com . > $#smtp $@ test.com $: $1 < @ bar.com >
R$* < @ [ $+ ] > $* $: $>98 $1 < @ [ $2 ] > $3
R$* < @ [ $+ ] > $* $#smtp $@ [$2] $: $1 < @ [$2] > $3This entry will result in all mail with the domain bar.com being forwarded to the domain test.com with an address of user@bar.com (user is the username of the person the mail is intended for). Make sure that test.com is configured to accept mail for the domain bar.com.
If for some reason the forwarded mail needs a different address (other than bar.com) substitute that address in the line so it looks similar to the following example:
R$* < @ bar . com . > $#smtp $@ test.com $: $1 < @ test.com >This would forward all mail addressed to bar.com to test.com with the address user@test.com.
You must kill and restart the sendmail daemon in order for the above changes to take effect.
See also
sendmail(ADMN), mail(C)