Sendmail preserve_luser_host feature
Sendmail has the ability to check if a recipient is local or not, and
if it is then deliver it locally, otherwise relay it to another mail host.
You can use the LUSER_RELAY option when you use m4 to make the sendmail.cf
file from sendmail.mc (in the sendmail source code directory).
LUSER_RELAY is discussed here:
http://www.sendmail.org/m4/domains.html
it says, in part:
LUSER_RELAY The site that will handle lusers -- that is, apparently local names that aren't local accounts or aliases. To specify a local user instead of a site, set this to ``local:username''.
When you do that, by default, the recipient is changed to have the hostname
of the relay host after the at sign in the email address. This can seem
to throw off some email servers, and they may not accept email with that
changed recipient address. There is a feature in m4 called
preserve_luser_host
that can help to solve this problem.
see:
http://www.sendmail.org/m4/features.html#preserve_luser_host
preserve_luser_host
Preserve the name of the recipient host if LUSER_RELAY is
used. Without this option, the domain part of the
recipient address will be replaced by the host specified as
LUSER_RELAY. This feature only works if the hostname is
passed to the mailer (see mailer triple in op.me). Note
that in the default configuration the local mailer does not
receive the hostname, i.e., the mailer triple has an empty
hostname.
But. Note where it says that the default configuration does not pass the
hostname to the local mailer, so this can't work without more modification.
I would have had no idea on how to fix that, but luckily there is a guy out
there named Andrzej Fili who did know, and posted it here:
http://www.mailarchive.ca/lists/comp.mail.sendmail/2002-04/0596.html
It says:
From: Andrzej Filip
Date: Mon, 8 Apr 2002 23:27:00 +0000
Ben Thompson wrote:
> I have this same problem. That preserve_luser_host feature doesn't. :o)
>
> I tried setting the preserve_luser_host FEATURE as the README shows
> and it did not work. I can add a hack to ruleset 95 to make it work,
> but I would rather use the built-in feature to do this correctly.
>
> The problem appears to be that ruleset 0 is stripping off all domain
> information to attempt local delivery and then running it through
> ruleset 95 that re-writes it to point to the mail relay specified as
> LUSER_RELAY. I also tried using always_add_domain, but that didn't help.
>
> Any thoughts?
> [...]
IMHO it can be fixed by the following change:
Current:
R$=L < @ $=w . > $#local $: @ $1 special local names
R$+ < @ $=w . > $#local $: $1 regular local name
Fixed:
R$=L < @ $=w . > $#local $@ $2 $: @ $1 special
local names
R$+ < @ $=w . > $#local $@ $2 $: $1 regular
local name
I alpha tested it in 8.12.3
Description:
local mailer is selected from user_at_domain adrersses only in one place of sendmail.cf, but the R lines do not pass $h to local mailer beacuse $h is ignored by mailers with F=l flag set (default for local mailer). But $h is required by the feature so I added passing it to the local mailer.
P.S.
Patch cf/m4/proto.m4 file
And, he is right. If you go into the sendmail source directory and
to the cf/m4 folder and edit the proto.m4 file and make the changes he
describes above, then
make sendmail.cf
from your sendmail.cm file with the LUSER_RELAY option and
preserve_luser_host feature on, it makes a sendmail.cf file that works
to get mail to the relay host while preserving the hostname in the
recipient address. Cool! Thank you Andrzej.
It seems to have worked for us lusers anyway.