php - PHPMailer - Could not authenticate -


i've been running phpmailer year on php server. fine until 3 days ago when started getting following error:

smtp error: not authenticate.

allow less secure apps on

here code:

function sendemail($to,$cc,$bcc,$subject,$body) { require 'phpmailerautoload.php';  $mail = new phpmailer(true); $mail->smtpdebug  = 1; try { $addresses = explode(',', $to); foreach ($addresses $address) {     $mail->addaddress($address); } if($cc!=''){    $mail->addcustomheader("cc: " . $cc); } if($bcc!=''){    $mail->addcustomheader("bcc: " . $bcc); } $mail->issmtp(); $mail->smtpauth = true; // turn on smtp authentication $mail->smtpsecure = "tls";                 // sets prefix servier $mail->host = "smtp.gmail.com";      // sets gmail smtp server $mail->port = 587;    $mail->username = "myemail@gmail.com"; // smtp username $mail->password = "myemailpass"; // smtp password $webmaster_email = "myemail@gmail.com"; //reply email id $name=$email; $mail->from = $webmaster_email; $mail->fromname = "service"; //$mail->addreplyto($webmaster_email, "difractal customer service"); $mail->wordwrap = 50; // set word wrap $mail->ishtml(true); // send html $mail->subject = $subject; $mail->body = $body; return $mail->send(); } catch (phpmailerexception $e) {  $myfile = fopen("debug_email.txt", "w");             fwrite($myfile,$e->errormessage() . "\n" . $mail->errorinfo);             fclose($myfile);//pretty error messages phpmailer } catch (exception $e) { $myfile = fopen("debug_email_stp.txt", "w");             fwrite($myfile,$e->getmessage());             fclose($myfile);//pretty error messages phpmailer             } } 

note updated phpmailer latest version try remedy problem nothing has changed! old version 5.2.2 still having same problem!

edit: had 1 successful email go through google , sent properly. makes me question if it's lag issue or of sort. know how phpmailer functions under high loads or if high loads can cause above error?

try going to: myaccount.google.com -> "connected apps & sites", , turn "allow less secure apps" "on". alternative: try changing smtp port to: 465 (gmail also).


Comments

Popular posts from this blog

angular - Is it possible to get native element for formControl? -

unity3d - Rotate an object to face an opposite direction -

javascript - Why jQuery Select box change event is now working? -