I setup a mx backup server to relay emails to two domains. The 2 main email servers(mail.domain1.tld and smtp.domain2.tld) are located on two different IP. I want all emails to @domain1.tld relay to mail.domain1.tld, and all email to @domain2.tld to smtp.domain.tld.
However, with my current configuration, all emails relay to mail.domain1.tld, even through I use "sender_dependent_relayhost_maps". I think it may because I have "relayhost = mail.domain1.tld:587". Once I disable this line and the server only try to relay to itself then eventually failed.
Could someone help me pls? Thanks a lot.
Here is my postfix configuration:
Code:
# 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
maximal_backoff_time = 1w
maximal_queue_lifetime = 3w
minimal_backoff_time = 15m
mydestination = localhost.localdomain, localhost
myhostname = theta.domain1.tld
mynetworks = 127.0.0.0/8
myorigin = /etc/mailname
queue_run_delay = 300s
readme_directory = no
recipient_delimiter = +
relay_domains = hash:/etc/postfix/relaydomains
relay_recipient_maps =
relayhost = mail.domain1.tld:587
sender_dependent_relayhost_maps = hash:/etc/postfix/transport
smtp_sasl_auth_enable = yes
smtp_sasl_mechanism_filter = login, plain
smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd
smtp_sasl_security_options = noanonymous
smtp_sasl_type = cyrus
smtp_sender_dependent_authentication = yes
smtp_tls_CAfile = /etc/postfix/sasl/smtpd.cert
smtp_use_tls = yes
smtpd_banner = $myhostname ESMTP
smtpd_recipient_restrictions = permit_sasl_authenticated, permit_mynetworks, reject_unauth_destination
Code:
# cat transport
@domain1.tld mail.domain1.tld:587
@domain2.tld smtp.domain2.tld:587
Code:
# cat relaydomains
domain1.tld OK
domain2.tld OK
Code:
# cat sasl_passwd
mail.domain1.ld:587 <username1>:<password1>
mail.domain2.ld:587 <username2>:<password2>