Swift Mailer Version 3.1.3
PHP 5.2.0 running on Debian 4.0
When connecting to my (remote) SMTP server, the server fails with a cryptic message: "authentication failed: bad protocol / cancel", regardless of SSL/TLS, PLAIN/LOGIN, etc.
The configuration of the SMTP server is:
- Debian 4.0
- Postfix 2.3.8
- SASL Authentication with PgSQL backend
- TLS, SSL both enabled
Because I use virtual users (also via the same PgSQL backend) on the mail server and use Postfix, it means that usernames must be specified in the "username@domain.tld" format, not just "username".
I tried manually connecting to the server and performing commands manually. I tried the well-documented format of "username@domain.tld\0username@domain.tld\0password", but got the same error.
I googled the above error and couldn't find anything useful, it seemed to be a very obscure problem. I figured it had to do with the @ character or something, but this ended up not being the case-- I'd get the error (via telnet:25) after entering even a simple character-only username. Interestingly I have Roundcube webmail set up and using SMTP/TLS to send emails to the same server without any problems, so after triple-checking settings, I figured Roundcube must be doing something differently to auth okay. After looking at the Roundcube source, it seems it uses the PEAR Net_SMTP lib. The string it uses to authenticate with PLAIN is as follows:
Code: Select all
$auth_str = base64_encode(chr(0) . $uid . chr(0) . $pwd);Code: Select all
$credentials = base64_encode(chr(0) . $user . chr(0) . $pass);I checked the older versions of the Net_SMTP library, it seems the above way of doing it has been there since the first version in 2002. Net_SMTP is used by Horde and Roundcube, so it's probably safe to assume that the above method works fairly universally, though it's probably worth researching and double-checking.
Thought I would share my problem and solution in case it comes up for anyone else.
Cheers on the great package, looking forward to using it!
~vanchuck