I use genericstable and FEATURE(`masquerade_envelope')
to rewrite some outgoing mail.
The problem is that both envelope-from and the "From:" header are
rewritten.
Is there a way to rewrite just the envelope-from and leave the "From:"
header intact?
I know that the direct hacking at the rulesets can do anything, but
would be glad to find a more or less ready-made solution.
Thank you for any ideas.
--
Victor Sudakov, VAS4-RIPE, VAS47-RIPN
2:5005/49@fidonet http://vas.tomsk.ru/
Not as such (with a canned solution), but in specific cases you can
perhaps achieve "identity rewriting" for the header (first requirement
is of course that the original envelope and header addresses are
different).
It's a pretty unusual request - I would say that in the vast majority of
cases rewriting both (i.e. what masquerade_envelope achhieves) is
desired, with header-only (i.e. the default) being a distant second. In
fact I don't think I've ever seen anyone ask for envelope-only before -
care to elaborate on why you want this?
>I know that the direct hacking at the rulesets can do anything, but
>would be glad to find a more or less ready-made solution.
Yes, it can be done with a custom mailer definition of course - look at
e.g. how the esmtp mailer turns out in the .cf with and without
masquerade_envelope and/or allmasquerade (which adds header recipient),
and you can probably figure out how it should look to achieve what you
want. Then give it a different name and paste it into your .mc after a
MAILER_DEFINITIONS line (and do whatever it takes to use it, depends a
bit on how you do outgoing mail routing).
--Per Hedeland
p...@hedeland.org
> It's a pretty unusual request - I would say that in the vast majority of
> cases rewriting both (i.e. what masquerade_envelope achhieves) is
> desired, with header-only (i.e. the default) being a distant second. In
> fact I don't think I've ever seen anyone ask for envelope-only before -
> care to elaborate on why you want this?
Sure. We have a web hosting which produces a significant amount of
outgoing mail (generated by users' scripts, forums etc). Users should be
free to use any address in the "From:" header, but I want all the
bounces and DSNs sent to one mailbox for analysis.
Perhaps later we might think of some scheme of sender rewriting, much
like Yahoo Groups uses for their mailing lists. But for the present,
directing all the bounces to one mailbox (and not bothering innocent
parties with bounces) would be a great step forward.
>> In fact I don't think I've ever seen anyone ask for
>> envelope-only before - care to elaborate on why you want this?
>
> Sure. We have a web hosting which produces a significant amount of
> outgoing mail (generated by users' scripts, forums etc).
Ah yes, a spam portal I think it's called.
OK, but then I think having envelope sender rewriting in sendmail is
quite the wrong way to go about it - just make sure the desired envelope
sender address is set appropriately to start with. I would guess that
the mail is sent via direct invocation of sendmail, in that case just
use the -f option (see the man page). In case it's done via SMTP, the
envelope sender is the 'MAIL From:' argument of course.
--Per Hedeland
p...@hedeland.org
> >> In fact I don't think I've ever seen anyone ask for
> >> envelope-only before - care to elaborate on why you want this?
> >
> > Sure. We have a web hosting which produces a significant amount of
> > outgoing mail (generated by users' scripts, forums etc).
> Ah yes, a spam portal I think it's called.
I presume, you have never seen a web forum with E-mail notifications?
You have also never seen a forum where a valid E-mail address is
required for access?
Get a life.
> OK, but then I think having envelope sender rewriting in sendmail is
> quite the wrong way to go about it - just make sure the desired envelope
> sender address is set appropriately to start with. I would guess that
> the mail is sent via direct invocation of sendmail, in that case just
> use the -f option (see the man page). In case it's done via SMTP, the
> envelope sender is the 'MAIL From:' argument of course.
It would work only for our own scripts.
But this is a commercial hosting. We do not have supervision over the
numerous web applications that the customers install. Nor do we want
to intervene unless there is some abuse.
If their scripts send mail via /usr/sbin/sendmail, I could provide a
wrapper, though this would be a waste of resources. But for SMTP
submissions, rewriting seems to be the only solution.
> >I know that the direct hacking at the rulesets can do anything, but
> >would be glad to find a more or less ready-made solution.
> Yes, it can be done with a custom mailer definition of course - look at
> e.g. how the esmtp mailer turns out in the .cf with and without
> masquerade_envelope and/or allmasquerade (which adds header recipient),
> and you can probably figure out how it should look to achieve what you
> want.
I am sorry but adding
MASQUERADE_AS(`domain.com')
FEATURE(masquerade_envelope)
to the .mc file does not produce any changes in the mailer
definitions. It only modifies the rulesets.
Any more ideas?
A very marginal waste.
> But for SMTP
>submissions, rewriting seems to be the only solution.
And are there any SMTP submissions? I believe it's quite uncommon for
"cgi scripts" and the like to use SMTP to send mail (and those that do
it probably get it wrong anyway).
--Per Hedeland
p...@hedeland.org
Yes, sorry, it's allmasquerade that changes the mailer definition. But
anyway, since you've now looked at the mailer definition, you'll have
found a reference to the EnvFromSMTP ruleset, which is the one
responsible for dealing with the envelope sender. And since it isn't
really masquerading you want to do, I'd suggest that you don't use that
feature but instead have the mailer definition call a ruleset of your
own instead of EnvFromSMTP. That ruleset just needs to throw away the
original address and insert your desired fixed one, and then call
EnvFromSMTP.
Something like this (untested):
LOCAL_RULESETS
SFixedEnvFrom
R$* $: sender < @ domain.com. >
R$* $: $>EnvFromSMTP $1
--Per Hedeland
p...@hedeland.org
> Is there a way to rewrite just the envelope-from and leave the "From:"
> header intact?
So, where are all the gurus? The task seems pretty trivial, I would be
surprised if sendmail really could not do this.
Of course sendmail can do it, wheter it is trivial to make it do it is
another thing - since it is not a common requirement, there has been no
effort at providing a "canned feature" for it. But anyway I already
posted the outline of a solution in
http://groups.google.com/group/comp.mail.sendmail/msg/cf17781ad3be3e99
- I'm afraid it won't get more trivial than that.
--Per Hedeland
p...@hedeland.org
> And since it isn't
> really masquerading you want to do, I'd suggest that you don't use that
> feature but instead have the mailer definition call a ruleset of your
> own instead of EnvFromSMTP. That ruleset just needs to throw away the
> original address and insert your desired fixed one, and then call
> EnvFromSMTP.
I like this idea. However, how do I gracefully change the esmtp mailer
S parameter? "S=EnvFromSMTP/HdrFromSMTP" is hardcoded into
cf/mailer/smtp.m4, as well as the EnvFromSMTP ruleset itself. And I
don't want my configuration to break with the next upgrade of
sendmail.
If I write my own mailer definition for this purpose, how do I make
my custom mailer the default one?
I already described this earlier in the thread:
>>>Then give it a different name and paste it into your .mc after a
>>>MAILER_DEFINITIONS line (and do whatever it takes to use it, depends a
>>>bit on how you do outgoing mail routing).
(Here "it" refers to the mailer definition you find in sendmail.cf.)
I.e. there isn't a single default - if parsing just reaches the end of
ruleset zero the message is handed to confSMTP_MAILER; if you have
e.g. a SMART_HOST definition that doesn't specify a mailer,
confRELAY_MAILER will be used. In most places you can specify the mailer
to be used, though.
--Per Hedeland
p...@hedeland.org
> I already described this earlier in the thread:
> >>>Then give it a different name and paste it into your .mc after a
> >>>MAILER_DEFINITIONS line (and do whatever it takes to use it, depends a
> >>>bit on how you do outgoing mail routing).
> (Here "it" refers to the mailer definition you find in sendmail.cf.)
> I.e. there isn't a single default - if parsing just reaches the end of
> ruleset zero the message is handed to confSMTP_MAILER;
I see. I must redefine confSMTP_MAILER to my custom mailer.
Thanks a lot for your help, your advice has been most useful.