Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

change return-path to custom value

1,282 views
Skip to first unread message

Razvan Cosma

unread,
May 27, 2010, 5:54:57 PM5/27/10
to
 Hi everyone,
I am trying to get message bounces/delays piped into a script while keeping the user-visible From: header intact. To do this, I have asked the senders to relay through me and include a header of the form X-bounces-to: scrip...@mydomain.com. In the postfix relay host I added
main.cf:
 header_checks = regexp:/etc/postfix/header_checks
header_checks:
 /^Return-Path: (.*)/            REPLACE X-Original-Return-Path: $1
 /^X-bounces-to: (.*)/        REPLACE Return-Path: $1
The log does say
 postfix/cleanup: replace: header X-bounces-to: scrip...@mydomain.com from somehost[1.2.3.4]; from=<z...@domain1.com> to=<a...@domain2.com> proto=SMTP: Return-Path: scrip...@mydomain.com
which sounds a bit odd - is this a concatenation of several informations from the message headers or some error on my part?

The messages do go out with the wrong return-path - the address used in the MAIL FROM: line, in this case z...@domain1.com. My question would be: does cleanup(8) do another replace of the headers just before the message leaves the system? If so, can it be disabled?

mouss

unread,
May 27, 2010, 6:19:37 PM5/27/10
to
Razvan Cosma a écrit :

> Hi everyone,
> I am trying to get message bounces/delays piped into a script while
> keeping the user-visible From: header intact. To do this, I have asked
> the senders to relay through me and include a header of the form
> X-bounces-to: scrip...@mydomain.com
> <mailto:scrip...@mydomain.com>. In the postfix relay host I added
> main.cf <http://main.cf>:

> header_checks = regexp:/etc/postfix/header_checks
> header_checks:
> /^Return-Path: (.*)/ REPLACE X-Original-Return-Path: $1
> /^X-bounces-to: (.*)/ REPLACE Return-Path: $1
> The log does say
> postfix/cleanup: replace: header X-bounces-to: scrip...@mydomain.com
> <mailto:scrip...@mydomain.com> from somehost[1.2.3.4];
> from=<z...@domain1.com <mailto:z...@domain1.com>> to=<a...@domain2.com
> <mailto:a...@domain2.com>> proto=SMTP: Return-Path:
> scrip...@mydomain.com <mailto:scrip...@mydomain.com>

> which sounds a bit odd - is this a concatenation of several informations
> from the message headers or some error on my part?
>
> The messages do go out with the wrong return-path - the address used in
> the MAIL FROM: line, in this case z...@domain1.com
> <mailto:z...@domain1.com>. My question would be: does cleanup(8) do

> another replace of the headers just before the message leaves the
> system? If so, can it be disabled?
>

You must understand the difference between the "envelope" and the
"headers". The MAIL FROM command specifies the _envelope_ sender. The
fact that this gets written into the Return-Path header is a good thing,
but it happens at delivery time (and it is optional. see the manpage of
"pipe"...).


to play with the sender address, use smtp generic maps. but better set
the correct sender address at the time the message is sent. users can do
"sendmail -f $sender...". This is better than relying on headers. and it
follows an old principle: fix problems near the source.

Wietse Venema

unread,
May 27, 2010, 7:26:06 PM5/27/10
to
Razvan Cosma:

> /^Return-Path: (.*)/ REPLACE X-Original-Return-Path: $1
> /^X-bounces-to: (.*)/ REPLACE Return-Path: $1

The Return-Path: header DOES NOT CONTROL delivery of bounce messages.

Instead, bounce messages are sent to the envelope sender address
(the address in the MAIL FROM command).

Wietse

Razvan Cosma

unread,
May 28, 2010, 5:14:06 AM5/28/10
to
Hi - understood. Now, as the messages are received from other hosts, I can't change the MAIL FROM part of the conversation. Also, as they are sent from .net (using system.net.mail) the sender application can't change the envelope sender without changing the From: line too (it's a limitation of that class). The alternatives now are to
1. not use system.net.mail, and write another smtp class in .net
2. somehow make postfix insert a header that makes other mailer-daemons bounce NDRs/out-of-offices/etc to it, instead of the From: address.
#1 is far from trivial for various reasons, so any hints towards #2 would be very helpful

Wietse Venema

unread,
May 28, 2010, 6:06:04 AM5/28/10
to
Razvan Cosma:

> Hi - understood. Now, as the messages are received from other hosts, I can't
> change the MAIL FROM part of the conversation. Also, as they are sent from
> .net (using system.net.mail) the sender application can't change the
> envelope sender without changing the From: line too (it's a limitation of
> that class). The alternatives now are to
> 1. not use system.net.mail, and write another smtp class in .net
> 2. somehow make postfix insert a header that makes other mailer-daemons
> bounce NDRs/out-of-offices/etc to it, instead of the From: address.
> #1 is far from trivial for various reasons, so any hints towards #2 would be
> very helpful

Postfix has a HUGE document on address rewriting (headers and
envelopes). Try "postfix address rewriting" in your favorite
search box.

Wietse

0 new messages