esackbauer
Hello,
for your info i have found a way to working with rules:
Confirming, I hit and fixed this exact same issue. If you’re running mailcow (or Postfix in general) behind an SMTP relay that requires verified senders — this happens with Oracle Email Delivery, SMTP2GO, Amazon SES, SendGrid, Mailgun, and basically every modern relay service — redirect/forward rules set up in webmail always fail with something like:
550 From header sender domain not verified (external.domain.com)
Root cause: when a user forwards mail (e.g. from info@yourdomain.com to Gmail), the message keeps the original external sender’s address in the From: header (whoever originally wrote the email). That domain obviously can’t be verified with your relay because you don’t own it. The relay rejects it as an anti-spoofing measure.
Fix: rewrite the From: header on outgoing mail using Postfix’s smtp_header_checks, but only when the sender isn’t one of your own domains — so regular mail from your users is left untouched, and only forwarded mail gets rewritten.
File to create: data/conf/postfix/header_checks_forward.pcre
/From:\s(?!.@(?:yourdomain1.com|yourdomain2.com))(?:“?([^”<])“?\s)?<?([\w.+-]+@[\w.-]+)>?\s*$/i REPLACE From: ”$1 (fwd)" noreply@yourdomain1.com
Replace yourdomain1.com|yourdomain2.com with all the domains you host in mailcow, separated by |, with dots escaped (.). The final address (noreply@yourdomain1.com) needs to be an approved/verified sender with your relay.
File to edit: data/conf/postfix/extra.cf (just add the line, don’t touch anything already there)
smtp_header_checks = pcre:/opt/postfix/conf/header_checks_forward.pcre
Steps:
Create the .pcre file with your domains
Add the line to extra.cf
Test the regex before restarting:
docker exec -it <postfix_container_name> postmap -q “From: External Name user@external.com” pcre:/opt/postfix/conf/header_checks_forward.pcre
Should return a REPLACE From: … line. Test again with a sender from one of your own domains — it should return nothing (no rewrite).
- Restart Postfix only:
docker compose restart postfix-mailcow
Users can now freely set up redirect/forward rules in webmail to any external address (Gmail, Outlook, etc.): the sender gets rewritten automatically and the relay will stop rejecting them.
Note: the recipient will see your domain as the sender (with the original name in parentheses, like “External Name (fwd)”) instead of the true original sender — that’s the necessary trade-off to comply with the SPF/DMARC alignment rules any modern relay enforces. There’s no way around it if you’re using a verified relay instead of direct port 25.
UPDATE 05/07/2026 17.52
Using this in /opt/postfix/conf/header_checks_forward.pcre is better because you can see real sender in Name (see screenshot)
/From:\s(?!.@(?:domain1.eu|domain2.net|domain3.it|domain4.it))(?:“?([^”<])“?\s)?<?([\w.+-]+@[\w.-]+)>?\s*$/i REPLACE From: ”$1 ($2) (fwd)" noreply@domain1.it