0

Host cannot send mail over relay host with port 587.

I have two servers. One mail server and one server that uses the mail server as a relay host.

The client server should send over Port 587. A telnet connection is possible between the client and mail server on port 587. But trying to send mail results in the following lines (/var/log/maillog):

May 23 07:16:56 mail postfix/smtpd[15476]: connect from HOST_DNS[HOST_IP]
May 23 07:16:56 mail postfix/smtpd[15476]: disconnect from HOST_DNS[HOST_IP] ehlo=1 auth=0/2 quit=1 commands=2/4

EDIT:

I also get this in maillog:

May 23 09:32:13 187 postfix/smtp[402991]: maps_find: smtp_sasl_password_maps: MYHOSTNAME: not found
May 23 09:32:13 187 postfix/smtp[402991]: maps_find: smtp_sasl_password_maps: [MYHOSTNAME]:587: not found

In main.cf:

relayhost=[MYHOSTNAME]:587

and in /etc/postfix/sasl_passwd:

[MYHOSTNAME]:587 user@domain:password

SOLVED THIS PART: Syntax error in sasl_passwd and missing postmap command. Problem above still exists.

Tom Krebs
  • 3
  • 2
  • Does the client authenticate? SMTP/MSA requires authentication. – Zac67 May 23 '23 at 08:06
  • It was a syntax error in the sasl_passwd file, now the authentication works so i can send a mail with the terminal function mail. But if i will send it over php I still get the errors above. – Tom Krebs May 23 '23 at 08:10

1 Answers1

0

You probably have in addition to

relayhost = [MYHOSTNAME]:587

also enabled authentication to MYHOSTNAME with:

smtp_sasl_auth_enable = yes
smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd
smtp_tls_CAfile = /etc/ssl/certs/ca-certificates.crt
smtp_use_tls = yes

The maps_find: error suggests that you did not update the Postfix lookup after updating the plain text file /etc/postfix/sasl_passwd with sudo postmap /etc/postfix/sasl_passwd

HBruijn
  • 77,029
  • 24
  • 135
  • 201
  • Unfortunately I already set auth enable. – Tom Krebs May 23 '23 at 08:43
  • With maps_find you were right, but I still cannot send mails with the php function. I see no errors in the log the connection just does not work... – Tom Krebs May 23 '23 at 08:45
  • Is your PHP code configured to use the system mail functionality i.e. /usr/lib/sendmail or is it more sophisticated code that attempts to make SMTP connection ? – HBruijn May 23 '23 at 08:48
  • I use the system mail. In my config are entries like: mailpath: /usr/sbin/sendmail smtp_host: myhostname and smtp_port: 587 and my suspicion is that sendmail has problems with port 587, but I cannot figure it out. – Tom Krebs May 23 '23 at 08:54
  • I found an error message regarding my sendmail problem. **Failed to send AUTH LOGIN command. Error: 530 5.7.0 Must issue a STARTTLS command first** – Tom Krebs May 23 '23 at 09:35
  • It looks like you're not allowed to authenticate over a clear text channel ; which makes sense. Add a setting `smtp_use_tls = yes` and you may also need to add `smtp_tls_CAfile = /etc/ssl/certs/ca-certificates.crt` (with the correct path to where on your system the CA certificate bundle is stored ) answered edited as well to reflect that – HBruijn May 23 '23 at 09:40
  • I think thats the actual problem. I activated these settings but it is still not working. Same error. Is it possible that I have to install a diffrent certificate first? – Tom Krebs May 23 '23 at 10:22
  • Thanks, the smtp_tls_CAfile helped to solve the problem. – Tom Krebs May 24 '23 at 06:08