Postfix Login failed, please check the username and password

postfix

So I have followed this guide to set up Postfix with multiple domains/IPs https://unix.stackexchange.com/a/179175/102085

However now I am trying to send emails I get the following error

Login failed, please check the username and password and try again.

Log file:

Jul  2 10:30:59 admin postfix/smtpd[2697]: connect from unknown[176.31.26.12]
Jul  2 10:30:59 admin postfix/smtpd[2697]: warning: SASL authentication failure: cannot connect to saslauthd server: No such file or directory
Jul  2 10:30:59 admin postfix/smtpd[2697]: warning: unknown[176.31.26.12]: SASL LOGIN authentication failed: generic failure
Jul  2 10:30:59 admin postfix/smtpd[2697]: lost connection after AUTH from unknown[176.31.26.12]
Jul  2 10:30:59 admin postfix/smtpd[2697]: disconnect from unknown[176.31.26.12]
Jul  2 10:31:03 admin sendmail[2705]: t62DV1g7002705: from=root, size=531, class=0, nrcpts=1, msgid=<201507021331.t62DV1g7002705@admin.com>, relay=root@localhost
Jul  2 10:31:03 admin sendmail[2705]: t62DV1g7002705: to=root, ctladdr=root (0/0), delay=00:00:02, xdelay=00:00:00, mailer=relay, pri=30531, relay=[127.0.0.1] [127.0.0.1], dsn=4.0.0, stat=Deferred: Connection refused by [127.0.0.1]

/etc/postfix/master.cf

#smtp      inet  n       -       n       -       -       smtpd
89.46.10.25:smtp  inet  n  - - - -  smtpd -o myhostname=host1.domain1.com
89.46.10.26:smtp  inet  n  - - - -  smtpd -o myhostname=host1.domain2.com

What am I missing? I have created the user "admin" and the password is correct. When I switch master.cf to smtp inet n - n - - smtpd and comment the two IPs it works.

Best Answer

That cannot connect to saslauthd server: No such file or directory error message suggests that postfix cannot connect to saslauthd. If saslauthd is running, as you say it is, that means that postfix and saslauthd are not using the same location for the Unix domain socket they use for communication.

  1. In /etc/postfix/main.cf, check the value of parameter smtpd_sasl_path. Remember, this path is relative to the postfix chroot (by default /var/spool/postfix). It should be something like var/run/saslauthd, i.e. the full path of the socket in the earlier example would be /var/spool/postfix/var/run/saslauthd.
  2. In /etc/sysconfig/saslauthd check that the socket path matches the full path that postfix is expecting. You should see something like the following, pointing to the socket location:
    SOCKETDIR=/var/spool/postfix/var/run/saslauthd
    

If you do both of the above and check that your configuration is consistent, your authentication should work.

Check the postfix documentation for more information on SASL configuration.