I am tring to use PHPMailer for sending mail with pdf attachment.
Code :
include_once("./PHPMailer/PHPMailerAutoload.php");
$mail = new PHPMailer(); // create a new object
$mail->IsSMTP(); // enable SMTP
$mail->SMTPDebug = 1; // debugging: 1 = errors and messages, 2 = messages only
$mail->SMTPAuth = true; // authentication enabled
$mail->SMTPSecure = 'tls'; // secure transfer enabled REQUIRED for Gmail
$mail->Host = "smtp.gmail.com";
$mail->Port = 587; // or 587
$mail->IsHTML(true);
$mail->Username = "username@gmail.com";
$mail->Password = "accual password";
$mail->SetFrom("test1@gmail.com");
$mail->Subject = "Test";
$mail->Body = "hello";
$mail->AddAddress("test2@gmail.com");
if (!$mail->Send()) {
echo "Mailer Error: " . $mail->ErrorInfo;
} else {
echo "Message has been sent";
}
Error :
2016-10-25 10:40:27 CLIENT -> SERVER: EHLO test.something.com
2016-10-25 10:40:27 CLIENT -> SERVER: STARTTLS
2016-10-25 10:40:27 CLIENT -> SERVER: EHLO test.something.com
2016-10-25 10:40:27 CLIENT -> SERVER: AUTH LOGIN
2016-10-25 10:40:27 CLIENT -> SERVER: ... user name removed ...
2016-10-25 10:40:27 CLIENT -> SERVER: ... password removed ...
2016-10-25 10:40:27 SMTP ERROR: Password command failed: 535-5.7.8 Username and Password not accepted. Learn more at 535 5.7.8 https://support.google.com/mail/?p=BadCredentials cy7sm4615595wjc.26 - gsmtp
2016-10-25 10:40:27 SMTP Error: Could not authenticate.
2016-10-25 10:40:27 CLIENT -> SERVER: QUIT
2016-10-25 10:40:27 SMTP connect() failed. https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting Mailer Error: SMTP connect() failed. https://github.com/PHPMailer/PHPMailer/wiki/Troubleshootingthanks
How Can I resove this problem? I appreciate all response. Thanks ahead.