Discussion:
sender_canonical_classes not working like expected
(too old to reply)
Georg Schönweger
2011-01-26 09:24:29 UTC
Permalink
Hi,

i have here postfix 2.6.5 on Ubuntu. Outgouing mails are sent via an
external SMTP Server (relayhost..). When i send an email from a local
user to a real email address i have in the email header "Return-Path:
***@SERVER_NAME". So i can't get back any bouncing or error mails.. I
use the server mainly for websites so when i send mails via the
webserver then i have the same problem, the envelope sender is
"www-***@SERVER_NAME" (i know i could change this via PHP-Mail command
but i'm using a CMS and i won't change that..) So i tried to masquerade
ONLY the envelope sender address. For this i use Canonical address mapping.
/etc/postfix/main.cf:
sender_canonical_classes = envelope_sender
sender_canonical_maps = hash:/etc/postfix/sender_canonical

/etc/postfix/sender_canonical:
@SERVER_NAME ***@example.org

Now if i do as root or as any other local user:
mail -s testoMail local_user < mailContent.txt

then not only the envelope sender (Return-Path) gets changed, but also
the *header_sender (From: ..)*

this is the source-code of the mail;
From ***@example.org Wed Jan 26 10:00:48 2011
Return-Path: <***@example.org>
X-Original-To: ***@SERVER_NAME Delivered-To: ***@SERVER_NAME
Received: by SERVER_NAME (Postfix, from userid 0)
id 7C11D255B447; Wed, 26 Jan 2011 10:00:48 +0100 (CET)
Subject: testmail
To: <***@SERVER_NAME>
X-Mailer: mail (GNU Mailutils 2.0)
Message-Id: <***@SERVER_NAME>
Date: Wed, 26 Jan 2011 10:00:48 +0100 (CET)
From: ***@example.org (root)

mailContent..

so why does postfix also masquerade the From: header if i set in
"sender_canonical_classes = envelope_sender"? I tried this on another
postfix server (version 2.5.1) and there the problem doesn't exist. Also
interesting is that if i set the FROM header via the unix mail command
(for example: mail -a "FROM: ***@SERVER_NAME" -s testoMail local_user <
mailContent.txt) then only the envelope sender get changed.

I'm very confused now and i hope someone can help me. I'm also
interested if someone has a better approach of doing this. Maybe i
should also note that my Unix hostname (/etc/hostname) is different than
"myhostname" in postfix, but i think thats no problem?

Georg
Victor Duchovni
2011-01-26 17:11:39 UTC
Permalink
Post by Georg Schönweger
i have here postfix 2.6.5 on Ubuntu. Outgouing mails are sent via an
external SMTP Server (relayhost..). When i send an email from a local
use the server mainly for websites so when i send mails via the
webserver then i have the same problem, the envelope sender is
but i'm using a CMS and i won't change that..) So i tried to masquerade
ONLY the envelope sender address. For this i use Canonical address mapping.
sender_canonical_classes = envelope_sender
sender_canonical_maps = hash:/etc/postfix/sender_canonical
Don't use sender_canonical_maps, it is essentially an obsolete feature,
its semantics are flawed. Use smtp_generic_maps, selectively per-transport
(master.cf -o smtp_generic_maps=$transportname_generic_maps overrides)
if you need different results depending on destination.
--
Viktor.
Georg Schönweger
2011-01-26 18:42:47 UTC
Permalink
aha, thx for this info! I tried smtp_generic_maps already, the problem
with that is that it overrides envelope AND header addresses. I want to
override only the envelope address (Return-Path). Any other ideas?

Is sender_canonical_maps buggy? should i deactivate it anyway?

Georg
Post by Victor Duchovni
Post by Georg Schönweger
i have here postfix 2.6.5 on Ubuntu. Outgouing mails are sent via an
external SMTP Server (relayhost..). When i send an email from a local
use the server mainly for websites so when i send mails via the
webserver then i have the same problem, the envelope sender is
but i'm using a CMS and i won't change that..) So i tried to masquerade
ONLY the envelope sender address. For this i use Canonical address mapping.
sender_canonical_classes = envelope_sender
sender_canonical_maps = hash:/etc/postfix/sender_canonical
Don't use sender_canonical_maps, it is essentially an obsolete feature,
its semantics are flawed. Use smtp_generic_maps, selectively per-transport
(master.cf -o smtp_generic_maps=$transportname_generic_maps overrides)
if you need different results depending on destination.
Victor Duchovni
2011-01-27 06:38:32 UTC
Permalink
Post by Georg Schönweger
aha, thx for this info! I tried smtp_generic_maps already, the problem
with that is that it overrides envelope AND header addresses. I want to
override only the envelope address (Return-Path). Any other ideas?
If it just for the envelope sender, sender_canonical_maps is not as
problematic, since the semantic issues arise when headers are rewritten
inconsistently (different rewriting of From:/To:/Cc:/Reply-To:).
Post by Georg Schönweger
Is sender_canonical_maps buggy? should i deactivate it anyway?
Not buggy, just difficult to use correctly.
Post by Georg Schönweger
Post by Georg Schönweger
i have here postfix 2.6.5 on Ubuntu. Outgouing mails are sent via an
external SMTP Server (relayhost..). When i send an email from a local
use the server mainly for websites so when i send mails via the
webserver then i have the same problem, the envelope sender is
but i'm using a CMS and i won't change that..) So i tried to masquerade
ONLY the envelope sender address. For this i use Canonical address mapping.
sender_canonical_classes = envelope_sender
sender_canonical_maps = hash:/etc/postfix/sender_canonical
With appropriate table data, it should be possible to rewrite given
envelope senders to given alternative envelope senders.
--
Viktor.
Georg Schönweger
2011-01-27 07:52:00 UTC
Permalink
so how should the sender_canonical file look like? Actually it looks like;
@server.localdomain ***@example.org

so every email which comes from @server.localdomain
(***@server.localdomain, ***@localdomain...) should be replaced with
the existing address ***@example.org. But this doesn't work always,
also the header "From: .." gets changed, i explained that in my first mail.

Georg
Post by Victor Duchovni
Post by Georg Schönweger
aha, thx for this info! I tried smtp_generic_maps already, the problem
with that is that it overrides envelope AND header addresses. I want to
override only the envelope address (Return-Path). Any other ideas?
If it just for the envelope sender, sender_canonical_maps is not as
problematic, since the semantic issues arise when headers are rewritten
inconsistently (different rewriting of From:/To:/Cc:/Reply-To:).
Post by Georg Schönweger
Is sender_canonical_maps buggy? should i deactivate it anyway?
Not buggy, just difficult to use correctly.
Post by Georg Schönweger
Post by Georg Schönweger
i have here postfix 2.6.5 on Ubuntu. Outgouing mails are sent via an
external SMTP Server (relayhost..). When i send an email from a local
use the server mainly for websites so when i send mails via the
webserver then i have the same problem, the envelope sender is
but i'm using a CMS and i won't change that..) So i tried to masquerade
ONLY the envelope sender address. For this i use Canonical address mapping.
sender_canonical_classes = envelope_sender
sender_canonical_maps = hash:/etc/postfix/sender_canonical
With appropriate table data, it should be possible to rewrite given
envelope senders to given alternative envelope senders.
mouss
2011-01-29 21:11:56 UTC
Permalink
Post by Georg Schönweger
so how should the sender_canonical file look like? Actually it looks like;
@server.localdomain ***@example.org
also the header "From: .." gets changed, i explained that in my first mail.
maybe you want
http://www.postfix.org/postconf.5.html#canonical_classes

Loading...