2

I'am config the postfix server to receive inbound mail. there is need to support two domain in one server. but I found I can not make it right.

/etc/mailname

a.com

postconf -n

alias_database = hash:/etc/aliases
alias_maps = hash:/etc/aliases
append_dot_mydomain = no
biff = no
config_directory = /etc/postfix
inet_interfaces = all
mailbox_size_limit = 0
mydestination = a.com, b.com, i-c7fiqzb6.pek1.qingcloud.com, localhost.pek1.qingcloud.com, localhost
myhostname = i-c7fiqzb6.pek1.qingcloud.com
mynetworks = 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128
myorigin = /etc/mailname
readme_directory = no
recipient_delimiter = +
relayhost =
smtp_tls_session_cache_database = btree:${data_directory}/smtp_scache
smtpd_banner = $myhostname ESMTP $mail_name (Ubuntu)
smtpd_relay_restrictions = permit_mynetworks permit_sasl_authenticated defer_unauth_destination
smtpd_tls_cert_file = /etc/ssl/certs/ssl-cert-snakeoil.pem
smtpd_tls_key_file = /etc/ssl/private/ssl-cert-snakeoil.key
smtpd_tls_session_cache_database = btree:${data_directory}/smtpd_scache
smtpd_use_tls = yes
virtual_alias_maps = pcre:/etc/postfix/redirect.pcre

/etc/postfix/redirect.pcre

/^.*@a\.com$/     acom
/^.*@b\.com$/     bcom

/etc/aliases

postmaster:    root

acom: "| commandA"
bcom: "| commandB"

Mails send to a.com can be delivered to commandA.
But mails send to b.com will be delivered to commandA too:

Sep 18 02:09:11 i-bplqojpl postfix/local[27458]: 2AB8A22CB6: to=<acom@a.com>, orig_to=<send+xxxxxx@b.com>, relay=local, delay=2, delays=1.1/0/0/0.94, dsn=2.0.0, status=sent (delivered to command: commandA)

But I found when I change the /etc/mailname to "b.com", every mail will be delivered to commandB, the Postfix only support one domain?

hfcorriez
  • 51
  • 4

1 Answers1

3

I made resolved!

The reason is like @TimHaegele said: It will use myorigin to match.

The solution is:

Change the /etc/mailname

localhost

Then move a.com and b.com from mydestination to virtual_alias_domains

It will be OK!

hfcorriez
  • 51
  • 4