Trouble with Dovecot, Postfix, and PHPMailer

There are many things that can go wrong with a Dovecot/Postfix installation. Here are two things to watch out for:


The following parameter in /etc/postfix/ will require TLS authentication for everything:


If you send emails with PHPMailer using SMTP authentication, you will then also need to turn TLS on:

$mail->SMTPSecure = 'tls';

Alternatively, you can turn off the TLS requirement:


Authentication Mechanism

It seems that when PHPMailer uses SMTP authentication, it cannot use the PLAIN but only the LOGIN mechanism. You need to make sure this is defined in the Dovecot configuration file /etc/dovecot/conf.d/10-auth.conf:

auth_mechanisms = plain login

On my way to finding this out, I had to deal with a lot of error messages such as:

530 Authentication Required
Invalid authentication mechanism
Relay access denied

If you see any of these, you may want to check out the aforementioned INI file settings.