Mansoor_5 0 Newbie Poster

Message could not be sent. Mailer Error: SMTP Error: Could not authenticate.
it worked on localhost perfectly but it gives error on live server
Here is my code

$mail = new PHPMailer(true);     
try {
$mail->IsSMTP(); 
$mail->Host = 'smtp.gmail.com';  
$mail->SMTPAuth = true; 
$mail->SMTPDebug = 2;
$mail->CharSet = "utf-8";
$mail->Username = "xxxxxxxxxxx@gmail.com";    
$mail->Password = "***********";                      
$mail->SMTPSecure = 'ssl';                      
$mail->Port = 465;                                 
$mail->setFrom('xyz@gmail.com', ' ');
$mail->addAddress($email);
$mail->addReplyTo('xyz@gmail.com');
$result='';
$mail->isHTML(true);                         
$mail->Subject = 'Your Password Reset Link';
$mail->Body    =  "Body";
$mail->AltBody =  "Body";
if($mail->send()){
$result="success";
echo "Success";
}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.