-1

This is my code:

<?php
require_once "PHPMailer/PHPMailerAutoload.php";

$name = $_POST['name'];
$email = $_POST['email'];
$message = $_POST['message'];


$mail = new PHPMailer;

$mail->IsSMTP();
$mail->Host = "smtp.gmail.com"; //gethostbyname('smtp.gmail.com');
$mail->SMTPAuth = true;
$mail->SMTPDebug = 3;
$mail->SMTPSecure = "ssl";
$mail->Port = 465;
$mail->Username = "ku***wa***ar***@gmail.com";
$mail->Password = "t***r9***5******7";
$mail->From = $email;
$mail->FromName = $name;
$mail->AddAddress($mail->Username);
$mail->Subject = 'Contact form query / feedback';
$mail->Body = "
    <div><span>Name : </span><span>{$name}</span></div>
    <div><span>Email : </span><span>{$email}</span></div>
    <div><p>{$message}</p></div>
";

$mail->isHTML(true);

if ($mail->send()){
    echo "Your feedback/query is sent!";
}else{
    echo "Error! Unable to forward your request.<br> Pleas try again later!";
}  

Note: I have used " GMail " as my SMTP server and SMTPSecure is " ssl " and port is "465" and username & passwords are my GMail username & password

The Error Message is:

Error Message Image

Clay
  • 4,700
  • 3
  • 33
  • 49
Kunal Waghmare
  • 183
  • 3
  • 10
  • i think your password is wrong – JYoThI Oct 03 '16 at 06:11
  • 1
    Search before posting, and follow the link to the troubleshooting docs given in the error message; that's why it's there. – Synchro Oct 03 '16 at 06:50
  • This question is a duplicate of this http://stackoverflow.com/questions/20337040/gmail-smtp-debug-error-please-log-in-via-your-web-browser – Aleksandar Pavić Oct 03 '16 at 06:51
  • Possible duplicate of ["SMTP Error: Could not authenticate" in PHPMailer](http://stackoverflow.com/questions/3949824/smtp-error-could-not-authenticate-in-phpmailer) – Synchro Oct 03 '16 at 06:52

1 Answers1

0

Screen Shot : https://s16.postimg.org/4hgsh9d51/smtp.png

Here is your code modified

<?php
    include "PHPMailer_5.2.4/class.phpmailer.php"; 

    $name = $_POST['name'];
    $email = $_POST['email'];
    $message = $_POST['message'];


    $mail = new PHPMailer;

    $mail->IsSMTP();
    $mail->Host = "smtp.gmail.com"; //gethostbyname('smtp.gmail.com');
    $mail->SMTPDebug = 1; 
    $mail->SMTPAuth = true; 
    $mail->SMTPSecure = 'ssl'; 
    $mail->Port = 465;
    $mail->isHTML(true);
    $mail->Username = "hari.andoidsaiss@gmail.com";
    $mail->Password = "supreme@12#";
    $mail->From = $email;
    $mail->FromName = $name;
    $mail->AddAddress($mail->Username);
    $mail->Subject = 'Contact form query / feedback';
    $mail->Body = "
        <div><span>Name : </span><span>{$name}</span></div>
        <div><span>Email : </span><span>{$email}</span></div>
        <div><span>Message : </span><p>{$message}</p></div>
    ";



    if ($mail->send()){
        echo "Your feedback/query is sent!";
    }else{
        echo "Error! Unable to forward your request.<br> Pleas try again later!";
    }