I’m trying to send from my web server through Office 365 mail, but the connection is getting closed. I’m using PPHList 3.3.8. I see some similar questions posted on various boards, but nothing I’ve followed seems to change the error.
I checked with my hosting provider, and they say they don’t have SMTP Restrictions active.
I have a Let’s Encrypt certificate on my domain, and the checks I’ve done with DNS seem to say my records are OK.
Any suggestions?
Thanks
EDIT:
I downloaded PHPMailer 6.0.7 to see if it could be used with the current version of PHPList. I read other messages that say that there are many changes, and PHPList will need significant work to use PHPMailer 6.
I do see in the current version of PHPMailer’s SMTP.php file that there are different transaction ID patterns for exim, sendmail, postfix, Microsoft_ESMTP, Amazon_SES, SendGrid and CampaignMonitor. I don’t see these in the files for PHPMailer version 5, although I may just have not been looking in the right place.
Connection: opening to smtp.office365.com:587, timeout=5, options=array ()
Connection: opened
SMTP -> get_lines(): $data is ""
SMTP -> get_lines(): $str is "220-pcluster23.hostdomain.com ESMTP Exim 4.91 #1 Fri, 08 Feb 2019 07:41:30 -0700 "
SMTP -> get_lines(): $data is "220-pcluster23.hostdomain.com ESMTP Exim 4.91 #1 Fri, 08 Feb 2019 07:41:30 -0700 "
SMTP -> get_lines(): $str is "220-We do not authorize the use of this system to transport unsolicited, "
SMTP -> get_lines(): $data is "220-pcluster23.hostdomain.com ESMTP Exim 4.91 #1 Fri, 08 Feb 2019 07:41:30 -0700 220-We do not authorize the use of this system to transport unsolicited, "
SMTP -> get_lines(): $str is "220 and/or bulk e-mail."
SERVER -> CLIENT: 220-pcluster23.hostdomain.com ESMTP Exim 4.91 #1 Fri, 08 Feb 2019 07:41:30 -0700 220-We do not authorize the use of this system to transport unsolicited, 220 and/or bulk e-mail.
CLIENT -> SERVER: EHLO domain.org
SMTP -> get_lines(): $data is ""
SMTP -> get_lines(): $str is "250-pcluster23.hostdomain.com Hello domain.org [XXX.154.46.140]"
SMTP -> get_lines(): $data is "250-pcluster23.hostdomain.com Hello domain.org [XXX.154.46.140]"
SMTP -> get_lines(): $str is "250-SIZE 52428800"
SMTP -> get_lines(): $data is "250-pcluster23.hostdomain.com Hello domain.org [184.154.46.140]250-SIZE 52428800"
SMTP -> get_lines(): $str is "250-8BITMIME"
SMTP -> get_lines(): $data is "250-pcluster23.hostdomain.com Hello domain.org [184.154.46.140]250-SIZE 52428800250-8BITMIME"
SMTP -> get_lines(): $str is "250-PIPELINING"
SMTP -> get_lines(): $data is "250-pcluster23.hostdomain.com Hello domain.org [184.154.46.140]250-SIZE 52428800250-8BITMIME250-PIPELINING"
SMTP -> get_lines(): $str is "250-AUTH PLAIN LOGIN"
SMTP -> get_lines(): $data is "250-pcluster23.hostdomain.com Hello domain.org [184.154.46.140]250-SIZE 52428800250-8BITMIME250-PIPELINING250-AUTH PLAIN LOGIN"
SMTP -> get_lines(): $str is "250-STARTTLS"
SMTP -> get_lines(): $data is "250-pcluster23.hostdomain.com Hello domain.org [184.154.46.140]250-SIZE 52428800250-8BITMIME250-PIPELINING250-AUTH PLAIN LOGIN250-STARTTLS"
SMTP -> get_lines(): $str is "250 HELP"
SERVER -> CLIENT: 250-pcluster23.hostdomain.com Hello domain.org [XXX.154.46.140]250-SIZE 52428800250-8BITMIME250-PIPELINING250-AUTH PLAIN LOGIN250-STARTTLS250 HELP
CLIENT -> SERVER: STARTTLS
SMTP -> get_lines(): $data is ""
SMTP -> get_lines(): $str is "220 TLS go ahead"
SERVER -> CLIENT: 220 TLS go ahead
SMTP Error: Could not connect to SMTP host.
CLIENT -> SERVER: QUIT
SMTP -> get_lines(): $data is ""
SMTP -> get_lines(): $str is ""
Connection: closed
@pauldow From what I can see the error message is issued in only one place in phpmailer. You can try adding some extra debug statements to see exactly where it is failing
in file admin/PHPMailer/class.smtp.php replace the startTLS() function
public function startTLS()
{
if (!$this->sendCommand('STARTTLS', 'STARTTLS', 220)) {
$this->edebug('send command failed', self::DEBUG_CONNECTION);
return false;
}
//Allow the best TLS version(s) we can
$crypto_method = STREAM_CRYPTO_METHOD_TLS_CLIENT;
//PHP 5.6.7 dropped inclusion of TLS 1.1 and 1.2 in STREAM_CRYPTO_METHOD_TLS_CLIENT
//so add them back in manually if we can
if (defined('STREAM_CRYPTO_METHOD_TLSv1_2_CLIENT')) {
$crypto_method |= STREAM_CRYPTO_METHOD_TLSv1_2_CLIENT;
$crypto_method |= STREAM_CRYPTO_METHOD_TLSv1_1_CLIENT;
}
// Begin encrypted connection
if (!stream_socket_enable_crypto(
$this->smtp_conn,
true,
$crypto_method
)) {
$this->edebug('streamsocket failed', self::DEBUG_CONNECTION);
return false;
}
$this->edebug('start TLS successful', self::DEBUG_CONNECTION);
return true;
}
Set the smtp debug level to be 3 then send a test email. With your settings I get “start TLS successful” then it fails on authentication
I’m using PHP 7.1. Since your script refers to PHP 5.6.7, is that a (or the) problem?
I got
Connection: opening to smtp.office365.com:587, timeout=5, options=array ()
Connection: opened
SERVER -> CLIENT: 220-pcluster23.stablehost.com ESMTP Exim 4.91 #1 Sun, 10 Feb 2019 14:34:02 -0700 220-We do not authorize the use of this system to transport unsolicited, 220 and/or bulk e-mail.
CLIENT -> SERVER: EHLO eaa1310.org
SERVER -> CLIENT: 250-pcluster23.stablehost.com Hello eaa1310.org [184.154.46.140]250-SIZE 52428800250-8BITMIME250-PIPELINING250-AUTH PLAIN LOGIN250-STARTTLS250 HELP
CLIENT -> SERVER: STARTTLS
SERVER -> CLIENT: 220 TLS go ahead
streamsocket failed
SMTP Error: Could not connect to SMTP host.
CLIENT -> SERVER: QUIT
You can see that this function call is failing but I don’t have the knowledge to know why that might be.
Try looking in the php or web server error logs for any more information, or ask your hosting company to help.
Well, it’s working now. I did another online chat with the support people at my hosting service, and they DID have SMTP restrictions active. Good thing I got a different person this time. As you can see in my original post, I asked if SMTP restrictions were active.
He did now turn it off for me, so I can send the mail out.
Duncan, thank you for your help with this. I hope you didn’t spend too much time on it.