Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Overwrite Sender Header #67

Open
TreasureMaster opened this issue Oct 20, 2021 · 3 comments
Open

Overwrite Sender Header #67

TreasureMaster opened this issue Oct 20, 2021 · 3 comments

Comments

@TreasureMaster
Copy link

TreasureMaster commented Oct 20, 2021

Hello!
I ran into the problem of sending mail via smtp.yandex.ru. This service requires the From and Sender headers to match. For example i get: "Sender: root@e379890e3f75" and "550 5.7.0 Sender or From header address rejected: not owned by authorized user". Now I am creating my dockerfile based on your image. I add this line run.sh:
echo -e "/^Sender:.*$/ REPLACE Sender: $OVERWRITE_FROM" >> /etc/postfix/smtp_header_checks
Can you add a variable to duplicate the From and Sender headers?

@juanluisbaptiste
Copy link
Owner

PR welcome.

@realizelol
Copy link

Have you tried using ENV:ALWAYS_ADD_MISSING_HEADERS=yes and ENV:OVERWRITE_FROM="My Name" <[email protected]> ?

This was introduced on 11 Oct 2021 maybe you haven't already the newest release? 99a2397

For me this is working.

best regards
realizelol

@remyzandwijk
Copy link

remyzandwijk commented Sep 19, 2023

Since this issue is still marked 'open', I felt okay with adding my 2 cents.

I am relaying email from a Linux box (Debian 11, Postfix as smarthost relay) to docker-postfix. With my previous email provider, that worked like a charm. All the email sent from the Linux box was delivered. However, the new email provider I am using does not accept the emails docker-postfix relays to it.

The log show the famous "Sender address rejected: not owned by user". Apparently the From line isn't rewritten, although I have the OVERRIDE_FROM environment variable set to a valid email address. However, sending a mail from the docker-postfix container itself does override the From line. The log shows:

smtprelay | Sep 19 20:03:24 smtprelay postfix/smtp[217]: DAA6D4AF: replace: header From

That log line does not show up when I send an email from the Linux box. I did some digging around and I found that Postfix does not use the smtp_header_checks when email is relayed with SMTP from another box. A working work-around is using the following Postfix configuration:

sender_canonical_maps = static:[email protected]
local_header_rewrite_clients = permit_inet_interfaces permit_mynetworks

If using that configuration, the smtp_header_checks can be omitted. Note that permitted_mynetworks is mandatory, otherwise Postfix will not apply the canonical map.

I also noticed that the header provided in SMTP_HEADER_TAG is applied twice in the email. I need to look into that a bit further.

Any comments?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants