Phpmailer: SMTP Auth problem

Created on 2 Jun 2016  Â·  14Comments  Â·  Source: PHPMailer/PHPMailer

I think I have a from email address length problem, but I am not sure.

All the tests in my development environment passed, with both the client email as well as my personnel email. To the outlook.com smtp server.
On my live server my personnel email "[email protected]" passed to the outlook.com server so i expect the connection on my live server is not a problem. But my client email "[email protected]" 37 characters fail the whole time with "SMTP connect() failed".
The yy is the exact length of the actual email.

2016-06-02 11:24:34 Connection: opening to smtp-mail.outlook.com:587, timeout=300, options=array ( )
2016-06-02 11:24:34 Connection: opened
2016-06-02 11:24:34 SERVER -> CLIENT: 220 BLU436-SMTP62.smtp.hotmail.com Microsoft ESMTP MAIL Service, Version: 8.0.9200.16384 ready at Thu, 2 Jun 2016 04:24:34 -0700
2016-06-02 11:24:34 CLIENT -> SERVER: EHLO forms.ncomp.co.za
2016-06-02 11:24:34 SERVER -> CLIENT: 250-BLU436-SMTP62.smtp.hotmail.com Hello [88.198.228.13] 250-TURN 250-SIZE 41943040 250-ETRN 250-PIPELINING 250-DSN 250-ENHANCEDSTATUSCODES 250-8bitmime 250-BINARYMIME 250-CHUNKING 250-VRFY 250-TLS 250-STARTTLS 250 OK
2016-06-02 11:24:34 CLIENT -> SERVER: STARTTLS
2016-06-02 11:24:34 SERVER -> CLIENT: 220 2.0.0 SMTP server ready
2016-06-02 11:24:34 CLIENT -> SERVER: EHLO forms.ncomp.co.za
2016-06-02 11:24:35 SERVER -> CLIENT: 250-BLU436-SMTP62.smtp.hotmail.com Hello [88.198.228.13] 250-TURN 250-SIZE 41943040 250-ETRN 250-PIPELINING 250-DSN 250-ENHANCEDSTATUSCODES 250-8bitmime 250-BINARYMIME 250-CHUNKING 250-VRFY 250-AUTH LOGIN PLAIN XOAUTH2 250 OK
2016-06-02 11:24:35 CLIENT -> SERVER: AUTH LOGIN
2016-06-02 11:24:35 SERVER -> CLIENT: 334 VXNlcm5hbWU6
2016-06-02 11:24:35 CLIENT -> SERVER: xxx==
2016-06-02 11:24:35 SERVER -> CLIENT: 334 UGFzc3dvcmQ6
2016-06-02 11:24:35 CLIENT -> SERVER: xxx==
2016-06-02 11:24:35 SERVER -> CLIENT: 535 5.0.0 Authentication Failed
2016-06-02 11:24:35 SMTP ERROR: Password command failed: 535 5.0.0 Authentication Failed 
2016-06-02 11:24:35 SMTP Error: Could not authenticate.
2016-06-02 11:24:35 CLIENT -> SERVER: QUIT
2016-06-02 11:24:35 SERVER -> CLIENT: 221 2.0.0 BLU436-SMTP62.smtp.hotmail.com Service closing transmission channel 2016-06-02 11:24:35 Connection: closed
2016-06-02 11:24:35 SMTP connect() failed. https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting 
require_once(JPATH_SITE . DIRECTORY_SEPARATOR . 'components' . DIRECTORY_SEPARATOR . 'com_surveyforce' . DIRECTORY_SEPARATOR . 'assets' . DIRECTORY_SEPARATOR . 'phpmailer' . DIRECTORY_SEPARATOR . 'PHPMailerAutoload.php');

$mail = new PHPMailer;

$mail->SMTPDebug = 3;                               // Enable verbose debug output
//echo $userProfile->profile5['smtpusername'] . '----' . $userProfile->profile5['smtppassword'];
$mail->CharSet = "UTF-8";
$mail->isSMTP();                                      // Set mailer to use SMTP
//      $mail->Host = $userProfile->profile5['smtphost'];  // Specify main and backup SMTP servers
$mail->Host = gethostbyname($userProfile->profile5['smtphost']);  // Specify main and backup SMTP servers
$mail->SMTPAuth = true;                               // Enable SMTP authentication
$mail->Username = $userProfile->profile5['smtpusername'];                 // SMTP username
$mail->Password = $userProfile->profile5['smtppassword'];                           // SMTP password
$mail->SMTPSecure = 'tls';                            // Enable TLS encryption, `ssl` also accepted
$mail->Port = $userProfile->profile5['smtpport'];                                    // TCP port to connect to

$mail->setFrom($email_reply, $joomlaname);
//  $mail->From = $email_reply;
//  $mail->set('FromName', $joomlaname);
//  $mail->FromName = $joomlaname;
$mail->addAddress($user_row->email, $user_name);     // Add a recipient
//  $mail->addAddress('[email protected]');               // Name is optional
//  $mail->addReplyTo($email_reply, '');
//  $mail->addCC('[email protected]');
//  $mail->addBCC('[email protected]');

//  $mail->addAttachment('/var/tmp/file.tar.gz');         // Add attachments
//  $mail->addAttachment('/tmp/image.jpg', 'new.jpg');    // Optional name
$mail->isHTML(true);                                  // Set email format to HTML

$mail->Subject = $subject;
$mail->Body    = $message_user;
$mail->AltBody = $user_name . "\n Find the links below. \n" . $textlink . "\n\nRegards,\n" . $joomlaname;   

if(!$mail->send()) {
 $result = 0;
 $mailerror = $mail->ErrorInfo;
//          echo $mailerror;
} else {
$result = 1;
}

I took really care and several tests to make sure the username and password is correct i even started copy and paste the values from the same source, so i really don't believe the username and password is incorrect.

If email address lenght is the problem i couldn't in the phpmailer files find where to change the length.

Hopefully you can find the problem from the above info. Let me know if you need anything else.

Thanks in advance.

Most helpful comment

Yes problem found.
My server is in Germany and I live in South Africa. Microsoft found the activity as suspicious. You go onto your live account onto the following link: https://account.live.com/Activity And press on the Germany activity and press the button "this is me". Then the smtp started to work.

All 14 comments

PHPMailer only imposes RFC-compliant length limits on actual addresses, not usernames, because many servers don't use email addresses as user names, so the length is not a problem here. The RFC limits are 320 chars for a whole address, 64 for the local part, so you are well within limts anyway. I suggest you double-check your ID and password.

I edited your posting to remove easily decoded passwords.

Thanks for the reply, i am continuing my fault finding i am just posting here maybe you see the problem before i do:
To test my username and password i hardcoded it into my php code:

$mail->Username = 'xxx';                 // SMTP username
$mail->Password = 'yyy';                           // SMTP password

Locally on my development machine it sends without a problem see below the success log. But still my live server fails with the exact same username and password hardcoded.

Hopefully i have removed all identifiable info from the logs.

Local pass logs

2016-06-02 13:03:05 Connection: opening to 65.55.176.126:587, timeout=300, options=array ( ) 
2016-06-02 13:03:05 Connection: opened 
2016-06-02 13:03:06 SERVER -> CLIENT: 220 BLU436-SMTP241.smtp.hotmail.com Microsoft ESMTP MAIL Service, Version: 8.0.9200.16384 ready at Thu, 2 Jun 2016 06:03:07 -0700
2016-06-02 13:03:06 CLIENT -> SERVER: EHLO localhost 
2016-06-02 13:03:06 SERVER -> CLIENT: 250-BLU436-SMTP241.smtp.hotmail.com Hello [154.70.211.42] 250-TURN 250-SIZE 41943040 250-ETRN 250-PIPELINING 250-DSN 250-ENHANCEDSTATUSCODES 250-8bitmime 250-VRFY 250-TLS 250-STARTTLS 250 OK 
2016-06-02 13:03:06 CLIENT -> SERVER: STARTTLS 
2016-06-02 13:03:06 SERVER -> CLIENT: 220 2.0.0 SMTP server ready 
2016-06-02 13:03:07 CLIENT -> SERVER: EHLO localhost 
2016-06-02 13:03:07 SERVER -> CLIENT: 250-BLU436-SMTP241.smtp.hotmail.com Hello [154.70.211.42] 250-TURN 250-SIZE 41943040 250-ETRN 250-PIPELINING 250-DSN 250-ENHANCEDSTATUSCODES 250-8bitmime 250-VRFY 250-AUTH LOGIN PLAIN XOAUTH2 250 OK 
2016-06-02 13:03:07 CLIENT -> SERVER: AUTH LOGIN 
2016-06-02 13:03:08 SERVER -> CLIENT: 334 VXNlcm5hbWU6 
2016-06-02 13:03:08 CLIENT -> SERVER: xxx== 
2016-06-02 13:03:08 SERVER -> CLIENT: 334 UGFzc3dvcmQ6 
2016-06-02 13:03:08 CLIENT -> SERVER: xxx== 
2016-06-02 13:03:09 SERVER -> CLIENT: 235 2.7.0 Authentication succeeded 
2016-06-02 13:03:09 CLIENT -> SERVER: MAIL FROM: 
2016-06-02 13:03:09 SERVER -> CLIENT: 250 2.1.0 xxx....Sender OK 
2016-06-02 13:03:09 CLIENT -> SERVER: RCPT TO: 
2016-06-02 13:03:09 SERVER -> CLIENT: 250 2.1.5 xxx 
2016-06-02 13:03:09 CLIENT -> SERVER: DATA 
2016-06-02 13:03:09 SERVER -> CLIENT: 354 Start mail input; end with . 
2016-06-02 13:03:09 CLIENT -> SERVER: Date: Thu, 2 Jun 2016 15:03:05 +0200 
2016-06-02 13:03:09 CLIENT -> SERVER: To: Piet Pompies 
2016-06-02 13:03:09 CLIENT -> SERVER: From: xxx 
2016-06-02 13:03:09 CLIENT -> SERVER: Subject: Voltooi asb die vorm 
2016-06-02 13:03:09 CLIENT -> SERVER: Message-ID: <183d136418a3384a846f02321b29cc4f@localhost> 
2016-06-02 13:03:09 CLIENT -> SERVER: X-Mailer: PHPMailer 5.2.15 (https://github.com/PHPMailer/PHPMailer) 
2016-06-02 13:03:09 CLIENT -> SERVER: MIME-Version: 1.0 
2016-06-02 13:03:09 CLIENT -> SERVER: Content-Type: multipart/alternative; 
2016-06-02 13:03:09 CLIENT -> SERVER: boundary="b1_183d136418a3384a846f02321b29cc4f" 
2016-06-02 13:03:09 CLIENT -> SERVER: Content-Transfer-Encoding: 8bit 
2016-06-02 13:03:09 CLIENT -> SERVER: 
2016-06-02 13:03:09 CLIENT -> SERVER: This is a multi-part message in MIME format. 
2016-06-02 13:03:09 CLIENT -> SERVER: 
2016-06-02 13:03:09 CLIENT -> SERVER: --b1_183d136418a3384a846f02321b29cc4f 
2016-06-02 13:03:09 CLIENT -> SERVER: Content-Type: text/plain; charset=us-ascii 
2016-06-02 13:03:09 CLIENT -> SERVER: 
2016-06-02 13:03:09 CLIENT -> SERVER: Piet Pompies 
2016-06-02 13:03:09 CLIENT -> SERVER: Find the links below. 
2016-06-02 13:03:09 CLIENT -> SERVER: http://localhost:81/formsncomp/url.php?uid=9d9d13a5b95f65bd7d981d7cc77e213f&surv=7 
2016-06-02 13:03:09 CLIENT -> SERVER: 
2016-06-02 13:03:09 CLIENT -> SERVER:
2016-06-02 13:03:09 CLIENT -> SERVER: Regards, 
2016-06-02 13:03:09 CLIENT -> SERVER: xxx 
2016-06-02 13:03:09 CLIENT -> SERVER: 
2016-06-02 13:03:09 CLIENT -> SERVER: 
2016-06-02 13:03:09 CLIENT -> SERVER: --b1_183d136418a3384a846f02321b29cc4f 
2016-06-02 13:03:09 CLIENT -> SERVER: Content-Type: text/html; charset=us-ascii 
2016-06-02 13:03:09 CLIENT -> SERVER: 
2016-06-02 13:03:09 CLIENT -> SERVER:

Piet Pompies
2016-06-02 13:03:09 CLIENT -> SERVER: 
2016-06-02 13:03:09 CLIENT -> SERVER:

Voltooi asb die vorm in deur te druk op onderstaande skakel.
2016-06-02 13:03:09 CLIENT -> SERVER: 
2016-06-02 13:03:09 CLIENT -> SERVER:

VW1 Link
2016-06-02 13:03:09 CLIENT -> SERVER: 2016-06-02 13:03:09 CLIENT -> SERVER:

Groete
2016-06-02 13:03:09 CLIENT -> SERVER: 2016-06-02 13:03:09 CLIENT -> SERVER:

xxx
2016-06-02 13:03:09 CLIENT -> SERVER: 
2016-06-02 13:03:09 CLIENT -> SERVER: 
2016-06-02 13:03:09 CLIENT -> SERVER: 
2016-06-02 13:03:09 CLIENT -> SERVER: --b1_183d136418a3384a846f02321b29cc4f-- 
2016-06-02 13:03:09 CLIENT -> SERVER: 
2016-06-02 13:03:09 CLIENT -> SERVER: . 
2016-06-02 13:03:18 SERVER -> CLIENT: 250 2.6.0 <183d136418a3384a846f02321b29cc4f@localhost> Queued mail for delivery 
2016-06-02 13:03:18 CLIENT -> SERVER: QUIT 
2016-06-02 13:03:18 SERVER -> CLIENT: 221 2.0.0 BLU436-SMTP241.smtp.hotmail.com Service closing transmission channel 
2016-06-02 13:03:18 Connection: closed 

Live server failed logs

2016-06-02 13:11:55 Connection: opening to 65.55.176.126:587, timeout=300, options=array ( ) 
2016-06-02 13:11:55 Connection: opened 
2016-06-02 13:11:55 SERVER -> CLIENT: 220 BLU436-SMTP186.smtp.hotmail.com Microsoft ESMTP MAIL Service, Version: 8.0.9200.16384 ready at Thu, 2 Jun 2016 06:11:55 -0700 
2016-06-02 13:11:55 CLIENT -> SERVER: EHLO forms.ncomp.co.za 
2016-06-02 13:11:56 SERVER -> CLIENT: 250-BLU436-SMTP186.smtp.hotmail.com Hello [88.198.228.13] 250-TURN 250-SIZE 41943040 250-ETRN 250-PIPELINING 250-DSN 250-ENHANCEDSTATUSCODES 250-8bitmime 250-BINARYMIME 250-CHUNKING 250-VRFY 250-TLS 250-STARTTLS 250 OK 
2016-06-02 13:11:56 CLIENT -> SERVER: STARTTLS 
2016-06-02 13:11:56 SERVER -> CLIENT: 220 2.0.0 SMTP server ready 
2016-06-02 13:11:56 CLIENT -> SERVER: EHLO forms.ncomp.co.za 
2016-06-02 13:11:56 SERVER -> CLIENT: 250-BLU436-SMTP186.smtp.hotmail.com Hello [88.198.228.13] 250-TURN 250-SIZE 41943040 250-ETRN 250-PIPELINING 250-DSN 250-ENHANCEDSTATUSCODES 250-8bitmime 250-BINARYMIME 250-CHUNKING 250-VRFY 250-AUTH LOGIN PLAIN XOAUTH2 250 OK 
2016-06-02 13:11:56 CLIENT -> SERVER: AUTH LOGIN 
2016-06-02 13:11:56 SERVER -> CLIENT: 334 VXNlcm5hbWU6 
2016-06-02 13:11:56 CLIENT -> SERVER: xxx== 
2016-06-02 13:11:56 SERVER -> CLIENT: 334 UGFzc3dvcmQ6 
2016-06-02 13:11:56 CLIENT -> SERVER: xxx== 
2016-06-02 13:11:56 SERVER -> CLIENT: 535 5.0.0 Authentication Failed 
2016-06-02 13:11:56 SMTP ERROR: Password command failed: 535 5.0.0 Authentication Failed 
2016-06-02 13:11:56 SMTP Error: Could not authenticate. 
2016-06-02 13:11:56 CLIENT -> SERVER: QUIT 
2016-06-02 13:11:56 SERVER -> CLIENT: 221 2.0.0 BLU436-SMTP186.smtp.hotmail.com Service closing transmission channel 
2016-06-02 13:11:56 Connection: closed 
2016-06-02 13:11:56 SMTP connect() failed. https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting 

Thanks in advance

I don't know if this makes a difference. On my development environment i don't have an active ipv6 connection. But on my live server the ipv6 is active.
I have tried the ipv6 paragraph you have on the troubleshooting guide. But it didn't work.

It's not using IPv6 here. Are the encoded login and password the same on both?

What do you mean do you want me to compare the xxx values that i removed on the 2 error reports.

Yes - they are simply your plain-text id and password, base64-encoded. Check them yourself, don't repost them here! You can check them by base64-decoding them to make sure they are the values they should be.

The pass and fail log matches on this 4 lines of the log.
2016-06-02 13:03:07 CLIENT -> SERVER: AUTH LOGIN
2016-06-02 13:03:08 SERVER -> CLIENT: 334 VXNlcm5hbWU6
2016-06-02 13:03:08 CLIENT -> SERVER: xxx==
2016-06-02 13:03:08 SERVER -> CLIENT: 334 UGFzc3dvcmQ6
2016-06-02 13:03:08 CLIENT -> SERVER: xxx==

If I base64_decode them they are the correct username and password.

OK, in that case I can't explain it - it looks as though hotmail is blacklisting your IP or something, though it seems odd that it would do that _after_ accepting your connection. The only other thing which is odd is that the *.smtp.microsoft.com hostnames do not appear to have DNS entries. This support doc suggests using smtp-mail.outlook.com for outbound, on outlook.com, though I'm not sure if infrastructure is shared between all of live, hotmail, outlook and office365.

"smtp-mail.outlook.com" is the host that I use. Microsoft probably routes it or something.

I got the info from the same link as you posted.

Ok, well I think you need to open a support ticket with them as there doesn't seem to be anything wrong at your end.

Thanks for the help. You wouldn't probably know who to contact. I don"t think the calll centre will know anything about this. I will see what i can find.

-----Oorspronklike Boodskap-----
Van: "Marcus Bointon" [email protected]
Gestuur: ‎02/‎06/‎2016 05:48 nm.
Aan: "PHPMailer/PHPMailer" [email protected]
AA: "NielBuys" [email protected]; "Author" [email protected]
Onderwerp: Re: [PHPMailer/PHPMailer] SMTP Auth problem (#741)

Ok, well I think you need to open a support ticket with them as there doesn't seem to be anything wrong at your end.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub, or mute the thread.

Yes problem found.
My server is in Germany and I live in South Africa. Microsoft found the activity as suspicious. You go onto your live account onto the following link: https://account.live.com/Activity And press on the Germany activity and press the button "this is me". Then the smtp started to work.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

aduh95 picture aduh95  Â·  4Comments

AndroidDesigner picture AndroidDesigner  Â·  4Comments

akephalos picture akephalos  Â·  6Comments

weirdeagle picture weirdeagle  Â·  3Comments

nsssim picture nsssim  Â·  6Comments