Intent
We are trying to use the sender_dependent_default_transport_maps
feature of postfix to use different SMTP relays based on the from
address of a mail.
The goals are:
- allow our partners to use their own domain name as
from
email address for automated messages (e.g.[email protected]
) - make sure that emails sent from
[email protected]
actually reach their users (e.g.[email protected]
)
Current configuration
Our current configuration is working fine but only uses our own SMTP server.
The /etc/postfix/master.cf
is simple and looks like:
# ==========================================================================
# service type private unpriv chroot wakeup maxproc command + args
# (yes) (yes) (no) (never) (100)
# ==========================================================================
smtp inet n - y - - smtpd
smtp unix - - y - - smtp
relay unix - - y - - smtp
The /etc/postfix/main.cf
is the following:
smtpd_banner = $myhostname ESMTP $mail_name (Ubuntu)
biff = no
append_dot_mydomain = no
readme_directory = no
smtpd_tls_cert_file=<path to PEM>
smtpd_tls_key_file=<path to KEY>
smtpd_use_tls=yes
smtpd_tls_session_cache_database = btree:${data_directory}/smtpd_scache
smtp_tls_session_cache_database = btree:${data_directory}/smtp_scache
smtpd_relay_restrictions = permit_mynetworks permit_sasl_authenticated defer_unauth_destination
myhostname = appserver.provider.com
alias_maps = hash:/etc/aliases
alias_database = hash:/etc/aliases
mydestination = $myhostname, appserver, localhost.localdomain, , localhost
relayhost = mail.provider.com:465
mynetworks = 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128
mailbox_size_limit = 0
recipient_delimiter = +
inet_interfaces = all
inet_protocols = all
smtp_sasl_auth_enable = yes
smtp_sasl_password_maps = hash:/etc/postfix/sasl/passwd
smtp_sasl_mechanism_filter =
smtp_sasl_security_options =
smtp_tls_security_level = encrypt
smtp_tls_wrappermode = yes
smtp_tls_mandatory_ciphers = high
canonical_maps = hash:/etc/postfix/canonical_maps
sender_canonical_maps = hash:/etc/postfix/sender_canonical_maps
header_checks = regexp:/etc/postfix/header_checks
Attempted configuration
I tried the following configuration in order to achieve the goal.
- Update the
main.cf
:- remove the line
relayhost = mail.provider.com:465
- add a line
sender_dependant_default_transport_maps = hash:/etc/postfix/sender_dependant_default_transport.map
- remove the line
Add a
/etc/postfix/sender_dependant_default_transport.map
with the following content:@partner1.com : smtp.partner1.com @provider.com : mail.provider.com:465
generate the map db:
sudo postmap /etc/postfix/sender_dependant_default_transport.map
- restart the service:
sudo service postfix restart
Outcome
Sending from @provider.com
to @provider.com
The email does not get sent:
postfix/smtpd[3011]: connect from localhost[127.0.0.1]
postfix/smtpd[3011]: 3BE61178E1E: client=localhost[127.0.0.1]
postfix/cleanup[3032]: 3BE61178E1E: message-id=<[email protected]>
postfix/qmgr[2997]: 3BE61178E1E: from=<[email protected]>, size=376, nrcpt=1 (queue active) postfix/smtp[3033]: connect to mx2.provider.com[<IPv6>]:25: Network is unreachable
postfix/smtp[3033]: SSL_connect error to mx1.provider.com[<IPv4>]:25:
postfix/smtp[3033]: warning: TLS library problem: error:140770FC:SSL routines:SSL23_GET_SERVER_HELLO:unknown protocol:s23_clnt.c:794: postfix/smtp[3033]: 3BE61178E1E: Cannot start TLS: handshake failure postfix/smtp[3033]: SSL_connect error to mx2.provider.com[<IPv4>]:25: -1 postfix/smtp[3033]: warning: TLS library problem: error:140770FC:SSL routines:SSL23_GET_SERVER_HELLO:unknown protocol:s23_clnt.c:794:
postfix/smtp[3033]: 3BE61178E1E: Cannot start TLS: handshake failure
postfix/smtp[3033]: SSL_connect error to mx3.provider.com[<IPv4>]:25:
postfix/smtp[3033]: warning: TLS library problem: error:140770FC:SSL routines:SSL23_GET_SERVER_HELLO:unknown protocol:s23_clnt.c:794: postfix/smtp[3033]: 3BE61178E1E: Cannot start TLS: handshake failure postfix/smtp[3033]: connect to mx1.provider.com[<IPv6>]:25: Network is unreachable
postfix/smtp[3033]: 3BE61178E1E: to=<[email protected]>, relay=none, delay=19, delays=18/0.01/0.54/0, dsn=4.4.1, status=deferred (connect to mx1.provider.com[<IPv6>]:25: Network is unreachable)
Sending from @partner1.com
to @provider.com
The email does not get sent:
postfix/smtpd[3237]: connect from localhost[127.0.0.1]
postfix/smtpd[3237]: 6234B178E1E: client=localhost[127.0.0.1]
postfix/cleanup[3252]: 6234B178E1E: message-id=<[email protected]>
postfix/qmgr[2997]: 6234B178E1E: from=<[email protected]>, size=368, nrcpt=1 (queue active) postfix/smtp[3253]: connect to mx3.provider.com[<IPv6>]:25: Network is unreachable
postfix/smtp[3253]: SSL_connect error to mx2.provider.com[<IPv4>]:25: -1
postfix/smtp[3253]: warning: TLS library problem: error:140770FC:SSL routines:SSL23_GET_SERVER_HELLO:unknown protocol:s23_clnt.c:794: postfix/smtp[3253]: 6234B178E1E: Cannot start TLS: handshake failure postfix/smtp[3253]: connect to mx1.provider.com[<IPv6>]:25: Network is unreachable
postfix/smtp[3253]: SSL_connect error to mx3.provider.com[<IPv4>]:25: -1
postfix/smtp[3253]: warning: TLS library problem: error:140770FC:SSL routines:SSL23_GET_SERVER_HELLO:unknown protocol:s23_clnt.c:794: postfix/smtp[3253]: 6234B178E1E: Cannot start TLS: handshake failure postfix/smtp[3253]: connect to mx2.provider.com[<IPv6>]:25: Network is unreachable
postfix/smtp[3253]: 6234B178E1E: to=<[email protected]>, relay=none, delay=16, delays=16/0.01/0.33/0, dsn=4.4.1, status=deferred (connect to mx2.provider.com[<IPv6>]:25: Network is unreachable)
Actual question
Sorry for the very long introduction but I wanted to make sure I was thorough.
It seems that:
- the config change in the
main.cf
was picked up because postfix does not try to use the default relay anymoremail.provider.com
but defaults to the MX records - The
sender_dependant_default_transport_maps
is not used at all
How to make sure it is actually used? Could it be another cause?
According to the postfix logs while restarting, the parameter is not used:
postfix[4582]: /usr/sbin/postconf: warning: /etc/postfix/main.cf: unused parameter: sender_dependant_default_transport_maps=hash:/etc/postfix/sender_dependant_default_transport_maps
but it does tell me why it is not used..
It was finally just a typo:
sender_dependant_default_transport_maps
doesn't exist while the correct spelling issender_dependent_default_transport_maps