I was supplying wrong credentials for SMTP when I got this error message.
Call to protected method SMTP::errorHandler() from context 'PHPMailer' in /var/www/classes/PHPMailer/class.phpmailer.php on line 1677
Error occurs in class.phpmailer.php (1677), but it appears that SMTP::errorHandler is protected method.
Then I searched for this error and also found this report.
You must be using an old version. The PHPMailer class does not call an errorHandler function at all, and it's marked as protected in the SMTP class.
I'm using 5.2.16 and got the error mentioned below when supplied credentials were incorrect. Not sure why you're closing the issue without first trying to figure out the source of the problem.
The two links you provided point to things that no longer exist. Line 1677 in class.phpmailer.php does not contain a call to SMTP::errorHandler(), and the errorHandler method in the SMTP class is declared as protected; that scrutinizer note applies to an older version - that issue was fixed on August 29th in 7c1154b. There are no calls to errorHandler anywhere in the PHPMailer class; the string does not exist in the file.
Aha - I see why - they were fixed in 5.2.17, so you need to update.
This commit added error handling by protected method errorHandler() to class.smtp.php. Not sure why this method is called in the context 'PHPMailer'.
I see this commit, however I just checked that I was using master branch downloaded month ago which includes above mentioned fix. Any ideas?
Can you reproduce it with current master (or 5.2.17)?
I'm using this version, and one commit after that is in some other unrelated area.
The only thing I can think of is if $this is somehow not what it should be at the time. Can you please post code to reproduce and a stack trace when the error occurs, so we can see how it's getting to that point?
Code to reproduce the problem is shown below. This occurs only if I supply wrong SMTP credentials.
require_once("classes/PHPMailer/PHPMailerAutoload.php");
$mail = new PHPMailer;
$mail->isSMTP();
$mail->SMTPAuth = TRUE;
$mail->XMailer = ' ';
$mail->AllowEmpty = TRUE;
$mail->SMTPDebug = 0;
$mail->Host = 'HIDDEN';
$mail->Port = 25;
$mail->Username = 'HIDDEN';
$mail->Password = 'HIDDEN';
$mail->SMTPSecure = '';
$mail->setFrom('[email protected]');
$mail->addAddress('[email protected]');
$mail->Subject = 'This is a test subject';
$mail->Body = 'This is a test body';
# Deliver the message
$success = $mail->send();
Function debug_print_backtrace() placed on line 1677 produces the following output:
#0 PHPMailer->smtpClose() called at [classes/PHPMailer/class.phpmailer.php:670]
#1 PHPMailer->__destruct()
$mail->SMTPSecure = ''; sets an invalid value for SMTPSecure, though that didn't make a difference to me.
I can't reproduce this, closing.