Postfix sends mail to relayhost, but relayhost bounces back with dsn=5.0.0 and no further details.
Q: How can I debug this in detail so that I can find out where I made the mistake?
Setup:
smtp-client.test.com :
this is a test server on which I installed postfix with Debian 10. This test server simulates the situation when it hosts a company's website and it should be able to send e-mails generated from scripts. So no user e-mail. Only outbound e-mails generated by scripts on this server. Postfix relays these e-mails to the following smtp-server:
relayhost.test.com :
this is server space at a hosting service. This is now a test server, but in production it wil act as the company mail server. It accepts smtp-traffic on port 587 with TLS. (for example with Thunderbird this server can be used as smtp-server on port 587 without any problem).
Problem/question: postfix is configured to send mail to the relayhost, but the relayhost bounces the e-mail back with dsn=5.0.0 status=bounced, and without any further details.
all settings in /etc/postfix/main.cf
:
smtpd_banner = $myhostname ESMTP $mail_name (Debian/GNU)
biff = no
append_dot_mydomain = no
readme_directory = no
compatibility_level = 2
smtpd_tls_cert_file=/etc/ssl/certs/ssl-cert-snakeoil.pem
smtpd_tls_key_file=/etc/ssl/private/ssl-cert-snakeoil.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 = test.mydomain.com
alias_maps = hash:/etc/aliases
alias_database = hash:/etc/aliases
myorigin = /etc/mailname
mydestination = $myhostname, testX.novalocal, localhost.novalocal, localhost
relayhost = [relayhost.test.com]:587
mynetworks = 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128
mailbox_size_limit = 0
recipient_delimiter = +
inet_interfaces = loopback-only
default_transport = error
relay_transport = error
inet_protocols = all
smtp_sasl_auth_enable = yes
smtp_sasl_mechanism_filter = plain
smtp_sasl_security_options = noanonymous
smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd
smtp_tls_security_level = encrypt
smtp_tls_CAfile = /etc/ssl/certs/ca-certificates.crt
/etc/postfix/sasl_passwd
looks like:
[relayhost.test.com]:587 [email protected]:mypassword
hash database file /etc/postfix/sasl_passwd.db
and restarting postfix:
sudo postmap sasl_passwd
sudo systemctl restart postfix
next: sending a test mail:
mailx -s "testmail" [email protected] < testmessage.txt
This results in the following lines in /var/log/mail.log
:
Jan 29 23:35:26 testX postfix/postfix-script[13256]: stopping the Postfix mail system
Jan 29 23:35:26 testX postfix/master[13023]: terminating on signal 15
Jan 29 23:35:27 testX postfix/postfix-script[13384]: warning: symlink leaves directory: /etc/postfix/./makedefs.out
Jan 29 23:35:27 testX postfix/postfix-script[13420]: starting the Postfix mail system
Jan 29 23:35:27 testX postfix/master[13422]: daemon started -- version 3.4.14, configuration /etc/postfix
Jan 29 23:35:34 testX postfix/pickup[13423]: 60836C262C: uid=1000 from=<user>
Jan 29 23:35:34 testX postfix/cleanup[13431]: 60836C262C: message-id=<[email protected]>
Jan 29 23:35:34 testX postfix/qmgr[13424]: 60836C262C: from=<[email protected]>, size=473, nrcpt=1 (queue active)
Jan 29 23:35:34 testX postfix/error[13433]: 60836C262C: to=<[email protected]>, relay=none, delay=0.12, delays=0.09/0.01/0/0.02, dsn=5.0.0, status=bounced ([relayhost.test.com]:587)
Jan 29 23:35:34 testX postfix/cleanup[13431]: 6C649C262D: message-id=<[email protected]>
Jan 29 23:35:34 testX postfix/qmgr[13424]: 6C649C262D: from=<>, size=2312, nrcpt=1 (queue active)
Jan 29 23:35:34 testX postfix/bounce[13434]: 60836C262C: sender non-delivery notification: 6C649C262D
Jan 29 23:35:34 testX postfix/qmgr[13424]: 60836C262C: removed
Jan 29 23:35:34 testX postfix/local[13436]: 6C649C262D: to=<[email protected]>, relay=local, delay=0.03, delays=0.01/0.01/0/0.01, dsn=2.0.0, status=sent (delivered to mailbox)
Jan 29 23:35:34 testX postfix/qmgr[13424]: 6C649C262D: removed
I tried to get more details in mail.log
adding the following lines to main.cf
:
debug_peer_list = relayhost.test.com
debug_peer_level = 3
...but this doesn't give me more details in mail.log
nor in syslog
.
How can I find out at what stage in the authentication process the relayhost refuses the connection, without having access to the logs of the hosting provider (who hosts my relayhost)?