Send Return-Path to Custom Check Interface

For most mails this should be already in the mail-body IIRC (in the Return-path header)

What's your use-case where this is necessary?
 
Hi Stoiko,

Thank you for your reply. This is all contents of mail sent to my script:
Code:
Received: from source.smtp.local (unknown [10.10.10.10])
    by dest.mx.local (Proxmox) with ESMTP id 30368400F8
    for <receiver@my_domain.com>; Fri, 17 May 2024 14:14:28 +0700 (+07)
From: "sender@other_domain.com" <sender@other_domain.com>
Date: Fri, 17 May 2024 14:14:20 +0700
Subject: test
Message-Id: <8e39559dbbd446e6a6a249fa030ce446@a77f13402ec64ff698cbd472ce59a6c3>
To: "receiver@my_domain.com" <receiver@my_domain.com>
Reply-To: sender@other_domain.com
MIME-Version: 1.0
Content-Type: multipart/alternative; boundary="=-S4vO5eU0OEh/LrJlPNpAPA=="

--=-S4vO5eU0OEh/LrJlPNpAPA==
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: quoted-printable

test=

--=-S4vO5eU0OEh/LrJlPNpAPA==

As you see, Return-path header is missing. I need this header because this is real sender (email after MAIL FROM command)
 
This topic is very old, but i have the same problem.
I think the envelope-from or return-path are only set if they differ from the (header)-From

I compared a lot of emails and i'm sure this is, what happens here.
 
This topic is very old, but i have the same problem.
I think the envelope-from or return-path are only set if they differ from the (header)-From

I compared a lot of emails and i'm sure this is, what happens here.

I don't think Postfix/PMG adds any of these headers, they are added by the final delivery agent.

Reading this:
https://www.postfix.org/smtp.8.html

COMMAND ATTRIBUTE SYNTAX
flags=DORX
(optional)
Optional message processing flags.
...
R Prepend a "Return-Path: <sender>" message header with the
envelope sender address.

You could try adding flag=R in the template master.cf.in (for the scan/lmtp service) after the -o options, this should in theory add the return-path header to that file for your script to process.

It would look something like this (untested):

Code:
[% IF ! pmg.mail.before_queue_filtering -%]
scan      unix  -       -       n       -       [% pmg.mail.max_filters %]      lmtp
  -o lmtp_send_xforward_command=yes
  -o lmtp_connection_cache_on_demand=no
  -o smtp_dns_support_level=disabled
  flags=R
[% END -%]

And I believe this would only work with after-queue filtering, not before-queue filtering (Configuration > Mail Proxy > Options).
 
Last edited:
Thank you.
In 1700 mails from 7800 non-spam-mails / month there was a return path.
All other mails seems to have a Header-From which is identical to the original return path.

I just build up a process extracting either the return path or the (Header-)From of the mail.
If it's not working as i thought i will try your tipp.
 
Thank you.
In 1700 mails from 7800 non-spam-mails / month there was a return path.
All other mails seems to have a Header-From which is identical to the original return path.

I just build up a process extracting either the return path or the (Header-)From of the mail.
If it's not working as i thought i will try your tipp.

If your script never sees a return-path header and always uses the from header, you will know.