1

I have Postfix + Dovecot + Mysql config, where I support multiple domains. The problem is when I add subdomain that already has main domain in virtual_mailbox_domains, Postfix rewrites it to main domain. For example: I send email as me@mail.example.com, Postfix rewrites it to me@example.com and send it as such. It works well for domains, but subdomains are rewritten to domains.

My example.com DNS setting: (spf details mocked, spf values are the same)

A   @                1.1.1.1
A   mail             1.1.1.1
TXT mail._domainkey  <value>
TXT mail2._domainkey <value>
MX  @                example.com
MX  mail             mail.example.com
TXT @                v=spf1 a mx ip4:1.1.1.1 ip6:ffff::ffff:ffff:ffff:ffff ~all
TXT mail             v=spf1 a mx ip4:1.1.1.1 ip6:ffff::ffff:ffff:ffff:ffff ~all

virtual_mailbox_domains

id | name
---|-----------------
1  | example.com
2  | mail.example.com

virtual_mailbox_maps

id | domain_id | pass | email
---------------------------------
1  | 1         | ***  | support@example.com
2  | 2         | ***  | newsletter@mail.example.com

virtual_alias_maps - empty

log:

...
Oct 24 01:29:44 mail postfix/smtpd[23898]: 216B9E32C5: client=dedicated-ail47.rev.name.com[1.1.1.1], sasl_method=LOGIN, sasl_username=newsletter@mail.example.com
Oct 24 01:29:44 mail postfix/cleanup[23901]: 216B9E32C5: message-id=<4afe4d8755119f7298f51e2586aa7f64@example.com>
Oct 24 01:29:44 mail opendkim[20747]: 216B9E32C5: DKIM-Signature field added (s=mail, d=example.com )
...

In OpenDKIM config domain and subdomain is configured separately.

How can I configure Postfix to not rewrite these addresses?

Navidot
  • 111
  • 3
  • Did you configure /etc/postfix/virtual_domains with all the needed domains ? If you refer only to sub-domains of a main, you only need proper MX records for it to work. – Overmind Oct 24 '19 at 09:07
  • @Overmind thanks for your reply. I use virtual_mailbox_domains and keep my config in MySql rather then map files. My virtual_mailbox_domains looks similar as posted. I use domains and subdomains for sending emails but they are separate addresses & mailboxes (at least I want to keep it this way). For example, example.com domain for support addresses (like support@, gdpr@) and mail.example.com subdomain for newsletter related addresses (like: newsletter@, bounce@). As you said it could be a problem with MX setup because I have main domain setting there with maybe overrides the one for subdomain. – Navidot Oct 24 '19 at 10:18

1 Answers1

0

Check if you have an entry

/etc/postfix/main.cf:
    masquerade_domains = example.com

if yes, change it to

/etc/postfix/main.cf:
    masquerade_domains = mail.example.com example.com

or remove

masquerade_domains

altogether from your configuration, if you don't want any domain address rewriting.

See https://www.postfix.org/ADDRESS_REWRITING_README.html Address masquerading for details.

Arigion
  • 138
  • 7