I want to add custom headers with "envelope from" and "envelope to" info received emails. To do this, I added the following lines to smtpd_relay_restrictions:
smtpd_relay_restrictions = check_sender_access pcre:/etc/postfix/prepend_sender, check_recipient_access pcre:/etc/postfix/prepend_recipient Content of prepend_sender file: /(.+)/ PREPEND X-CustomHeader-Sender: $1 Content ot file prepend_recipient file: /(.+)/ PREPEND X-CustomHeader-Recipient: $1 Everything works great until I get an email for multiple recipients in my domain. In this case, the X-CustomHeader-Sender header is added as many times as there are recipients in the email, it looks something like this: X-CustomHeader-Sender: sen...@domain.tld X-CustomHeader-Recipient: ema...@example.com X-CustomHeader-Sender: sen...@domain.tld X-CustomHeader-Recipient: ema...@example.com X-CustomHeader-Sender: sen...@domain.tld X-CustomHeader-Recipient: ema...@example.com I did some experiments with smtpd_<helo|client|relay|sender|recipient>_restrictions, the behavior is the same in all cases. Is it possible to avoid this so that prepend in check_sender_access, check_client_access and check_helo_access is executed once, since sender, hello and client do not change? For example, this is what the log looks like if add rule /(.+)/ INFO "debug: check_client_access=$1" into smtpd_client_restrictions/check_client_access: 2025-04-23T16:17:39+03:00 postfix/smtpd[2381794]: connect from mail-yb1-f177.google.com[209.85.219.177] 2025-04-23T16:17:40+03:00 postfix/smtpd[2381794]: Anonymous TLS connection established from mail-yb1-f177.google.com[209.85.219.177]: TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 2025-04-23T16:17:40+03:00 postfix/smtpd[2381794]: NOQUEUE: info: RCPT from mail-yb1-f177.google.com[209.85.219.177]: "debug: check_client_access= mail-yb1-f177.google.com"; from=<sen...@domain.tld> to=<ema...@example.com> proto=ESMTP helo=<mail-yb1-f177.google.com> 2025-04-23T16:17:40+03:00 postfix/smtpd[2381794]: 675C218000D0: client= mail-yb1-f177.google.com[209.85.219.177] 2025-04-23T16:17:40+03:00 postfix/smtpd[2381794]: 675C218000D0: info: RCPT from mail-yb1-f177.google.com[209.85.219.177]: "debug: check_client_access= mail-yb1-f177.google.com"; from=<sen...@domain.tld> to=<ema...@example.com> proto=ESMTP helo=<mail-yb1-f177.google.com> 2025-04-23T16:17:40+03:00 postfix/smtpd[2381794]: 675C218000D0: info: RCPT from mail-yb1-f177.google.com[209.85.219.177]: "debug: check_client_access= mail-yb1-f177.google.com"; from=<sen...@domain.tld> to=<ema...@example.com> proto=ESMTP helo=<mail-yb1-f177.google.com> 2025-04-23T16:17:40+03:00 postfix/cleanup[2381802]: 675C218000D0: message-id=< capgodmhjvsaffbo2n77pxmjo6a0s9tzjlyxhrkkh4mxadds...@mail.gmail.com> 2025-04-23T16:17:40+03:00 postfix/qmgr[2381502]: 675C218000D0: from=<sen...@domain.tld>, size=7269, nrcpt=3 (queue active) For 1st recipient check do before queue, and then message go to queue and then checks do for other recipients. -- Best regards, Mike Teplynin
_______________________________________________ Postfix-users mailing list -- postfix-users@postfix.org To unsubscribe send an email to postfix-users-le...@postfix.org