MyBB Community Forums

Full Version: SMTP Auth problems
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi,

Like many people over the years I'm having trouble with MyBB sending email, due to issues with SMTP Auth. I've tried both SMTP Mail and PHP Mail. Both work fine if I turn AUTH off on my mail server (hmailserver). Neither work if I turn it on. I need it turned on.

Joomla is handling SMTP Auth just fine.

Looking at the mail server log files (hmailserver) it appears that MyBB is never responding to the AUTH request -

Quote:"SMTPD" 6852 4066739 "2013-09-25 22:28:37.361" "127.0.0.1" "SENT: 220 mx-2.tribetech.net ESMTP"
"SMTPD" 6188 4066739 "2013-09-25 22:28:37.361" "127.0.0.1" "RECEIVED: EHLO localhost"
"SMTPD" 6188 4066739 "2013-09-25 22:28:37.361" "127.0.0.1" "SENT: 250-mx-2.tribetech.net[nl]250-SIZE 20480000[nl]250 AUTH LOGIN"
"SMTPD" 5004 4066739 "2013-09-25 22:28:37.361" "127.0.0.1" "RECEIVED: MAIL FROM:<***@***.***>"
"SMTPD" 5004 4066739 "2013-09-25 22:28:37.377" "127.0.0.1" "SENT: 250 OK"
"SMTPD" 5004 4066739 "2013-09-25 22:28:37.377" "127.0.0.1" "RECEIVED: RCPT TO:<***@***.***>"
"SMTPD" 5004 4066739 "2013-09-25 22:28:37.377" "127.0.0.1" "SENT: 530 SMTP authentication is required."

Here's a similar request from a Joomla install on the same machine -

Quote:"SMTPD" 6852 4066740 "2013-09-25 22:33:23.971" "127.0.0.1" "SENT: 220 mx-2.tribetech.net ESMTP"
"SMTPD" 6852 4066740 "2013-09-25 22:33:23.971" "127.0.0.1" "RECEIVED: EHLO localhost"
"SMTPD" 6852 4066740 "2013-09-25 22:33:23.971" "127.0.0.1" "SENT: 250-mx-2.tribetech.net[nl]250-SIZE 20480000[nl]250 AUTH LOGIN"
"SMTPD" 6188 4066740 "2013-09-25 22:33:23.971" "127.0.0.1" "RECEIVED: AUTH LOGIN"
"SMTPD" 6188 4066740 "2013-09-25 22:33:23.971" "127.0.0.1" "SENT: 334 ********"
"SMTPD" 6852 4066740 "2013-09-25 22:33:23.971" "127.0.0.1" "RECEIVED: ****************"
"SMTPD" 6852 4066740 "2013-09-25 22:33:23.971" "127.0.0.1" "SENT: 334 ********"
"SMTPD" 6852 4066740 "2013-09-25 22:33:23.971" "127.0.0.1" "RECEIVED: ***"
"SMTPD" 6852 4066740 "2013-09-25 22:33:23.986" "127.0.0.1" "SENT: 235 authenticated."
"SMTPD" 6188 4066740 "2013-09-25 22:33:23.986" "127.0.0.1" "RECEIVED: MAIL FROM:<***@***>"
"SMTPD" 6188 4066740 "2013-09-25 22:33:23.986" "127.0.0.1" "SENT: 250 OK"
"SMTPD" 6904 4066740 "2013-09-25 22:33:23.986" "127.0.0.1" "RECEIVED: RCPT TO:<***@***>"
"SMTPD" 6904 4066740 "2013-09-25 22:33:23.986" "127.0.0.1" "SENT: 250 OK"
"SMTPD" 6188 4066740 "2013-09-25 22:33:23.986" "127.0.0.1" "RECEIVED: RCPT TO:<***@***>"
"SMTPD" 6188 4066740 "2013-09-25 22:33:23.986" "127.0.0.1" "SENT: 250 OK"
"SMTPD" 6852 4066740 "2013-09-25 22:33:23.986" "127.0.0.1" "RECEIVED: DATA"
"SMTPD" 6852 4066740 "2013-09-25 22:33:24.002" "127.0.0.1" "SENT: 354 OK, send."
"SMTPD" 6992 4066740 "2013-09-25 22:33:24.033" "127.0.0.1" "SENT: 250 Queued (0.015 seconds)"

(emails and passwords redacted)

As you can see, Joomla gets the AUTH LOGIN response and answers accordingly. MyBB ignores it and is clearly not parsing the output correctly.

One issue is line 285 of smtp.php which looks for "250-AUTH" when "250 AUTH" is also a legitimate response. Matching for 250.AUTH doesn't appear to help.

People seem to have been having issues with this for years, it would be nice if we could solve it in the code once and for all.

I'll keep digging, help appreciated.

ETA:
Might be an issue with trailing spaces. I changed line 285 and 286 of smtp.php from

preg_match("#250-AUTH( |=)(.+)$#mi", $data, $matches);
if(!$this->auth($matches[2]))

to

preg_match("#250.AUTH( |=)(.+)$#mi", $data, $matches);
if(!$this->auth(trim($matches[2])))

and SMTP authentication works! Cool