tags:

views:

86

answers:

3

Hi Everybody,

I'm Using PHPMailer in a Simple Script For Send Email's Through Gmail, And I'm Getting an "Unknown Error" (At least For me!):

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

SMTP server error: 5.7.1 Username and Password not accepted. Learn more at 535 5.7.1 http://mail.google.com/support/bin/answer.py?answer=14257 p38sm2467302ybk.16

I've Read About Configure OpenSSL For SSL/TLS Connections, and i did it. Apache And PHP Are properly-Configured (With OpenSSL extension Running in PHP and mod_ssl running in Apache 2.2.16).

This is The PHP Script:

 <?php
  require_once ("PHPMailer\class.phpmailer.php");
  $Correo = new PHPMailer();
  $Correo->IsSMTP();
  $Correo->SMTPAuth = true;
  $Correo->SMTPSecure = "tls";
  $Correo->Host = "smtp.gmail.com";
  $Correo->Port = 587;
  $Correo->UserName = "[email protected]";
  $Correo->Password = "gmailpassword";
  $Correo->SetFrom('[email protected]','De Yo');
  $Correo->FromName = "From";
  $Correo->AddAddress("[email protected]");
  $Correo->Subject = "Prueba con PHPMailer";
  $Correo->Body = "<H3>Bienvenido! Esto Funciona!</H3>";
  $Correo->IsHTML (true);
  if (!$Correo->Send())
  {
    echo "Error: $Correo->ErrorInfo";
  }
  else
  {
    echo "Message Sent!";
  }
?>

The Username And Password Are Ok, And I Tried in Thunderbird, Without Any Problem. I've also Used SSL Authentication And Port 465, getting the same Error.

Can Anyone Help Me?

Thanks in Advance!

PS: Sorry For My English. I'm Not a "Native-Speaker"

+2  A: 

Try this instead :

$Correo->Username = "[email protected]";

I tested it and its working perfectly without no other change

racar
Man! You're The Best!
Astantler
@Astantler you can mark his answer as accepted using the check mark symbol to the left.
Pekka
@Pekka Thank's For The Clarification!
Astantler
A: 

Thank You So Much To racar. I've Tried it And It Works! Again, Thank You! :)

Astantler