0
$mail= new PHPmailer();
$mail-> IsSMTP();//telling the class to use SMTP
$mail->Host = gethostbyname('smtp.gmail.com');//SMTP server
$mail->SMTPDdebug =2; //enables SMTP debug information
$mail->SMTPAuth = true;//enable SMTP authentication
$mail->SMTPSecure = "tsl";//set the prefix to the server

$mail->Port =587;//set the SMTP port for thr GMAIL server
$mail->Username = "andriyvyhor@gmail.com";//GAMAIL username
$mail->Password ="andriyvyhor";
$mail->SetFrom=("andriyvyhor@gmail.com");
$mail->AddAddress("andriyvyhor@gmail.com");
$mail->Subject="TEXT";
$mail->Body="You sell your shares";
if(!$mail->Send())
{
    echo "Mailer erro:".$mail->ErrorInfo;
}
else
{
    echo "Message sent!";
}
}

am getting this error

SMTP Error: Could not authenticate. Mailer Error: SMTP Error: Could not authenticate.

Cœur
  • 37,241
  • 25
  • 195
  • 267
oleh
  • 9
  • 4
  • "could not authenticate" seems obvious enough. your gmail credentials are wrong. – Marc B Jul 18 '16 at 20:21
  • You've based your code on an obsolete example, and you're using an old version of PHPMailer. [Get the latest](https://github.com/PHPMailer/PHPMailer), and read the docs. – Synchro Jul 18 '16 at 20:50
  • 2
    Possible duplicate of ["SMTP Error: Could not authenticate" in PHPMailer](http://stackoverflow.com/questions/3949824/smtp-error-could-not-authenticate-in-phpmailer) – Synchro Jul 18 '16 at 20:51

0 Answers0