I try to send email from my server through Postfix, but I can't get it to work. I'm using an external SMTP server as relay host. This is the relevant part of /etc/postfix/main.cf
:
smtpd_relay_restrictions = permit_mynetworks permit_sasl_authenticated defer_unauth_destination
relayhost = [mail.myISP.nl]:submission
mynetworks = 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128
mailbox_size_limit = 0
recipient_delimiter = +
inet_interfaces = loopback-only
inet_protocols = all
smtp_generic_maps = hash:/etc/postfix/generic
smtp_sasl_auth_enable = yes
smtp_sasl_security_options = noanonymous
smtp_sasl_password_maps = hash:/etc/postfix/sasl_password
debug_peer_list=mail.myISP.nl
debug_peer_level=5
I installed libsasl2-2
, libsasl2-modules
and sasl2-bin
. In /etc/postfix/sasl_password
, I entered valid credentials:
[mail.myISP.nl]:587 myuserid:mypassword
after which I ran the command to convert the text file to a .db
file:
postmap /etc/postfix/sasl_password
and reloaded Postfix's configuration:
sudo systemctl reload postfix
However, no mail actually gets sent. I ran a TCP dump on the following command:
echo "This is a test" | mail -s "Testing" [email protected]
And the result was the following exchange with the remote server:
(S) srv17610.myISP.nl ESMTP Exim 4.86.2 Wed, 28 Dec 2016 11:06:24 +0100
(C) EHLO hostname
(S) 250-srv17610.myISP.nl Hello my.canonical.name.nl [xxx.xxx.xxx.xxx]
(S) 250-SIZE 20971520
(S) 250-8BITMIME
(S) 250-PIPELINING
(S) 250-AUTH PLAIN LOGIN
(S) 250-STARTTLS
(S) 250 HELP
(C) MAIL FROM:<[email protected]> SIZE=310
(C) RCPT TO:<[email protected]>
(C) DATA
(S) 250 OK
(S) 550 relay not permitted, authentication required
(S) 503-All RCPT commands were rejected with this error:
(S) 503-relay not permitted, authentication required
(S) 503 Valid RCPT command must precede DATA
(C) RSET
(C) QUIT
(S) 250 Reset OK
(S) 221 srv17610.myISP.nl closing
With (C) being Postfix and (S) the remote server. You can see that it doesn't issue an AUTH command, doesn't offer credentials, and therefore the mail is rejected. The /var/log/mail.log
simply says that mail has been sent. What goes wrong?
Your configuration looks legit, but postfix requires it's smtp_sasl_password_maps file to actually be stored in a optimized way not clear text.
if you don't have such a file
running the command:
will generate a sasl_password.db
to apply changes