Click here to Skip to main content
15,908,776 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello,

I created a simple html page that send a mail from Gmail account. at start it send mail from the page. but now it shows the error.

SMTP -> ERROR: Password not accepted from server: 535 Incorrect authentication data

Please Help me as i am stuck in that.

Here is my Code :

PHP
require_once ("class.phpmailer.php");
$mail = new PHPMailer();
$mail->IsSMTP();
$mail->IsHTML(true);
$mail->SMTPDebug  = 1;
$mail->SMTPAuth = true; // enable SMTP authentication
$mail->SMTPSecure = "tls"; // sets the prefix to the servier ssl or tls
$mail->Host = "smtp.gmail.com"; // sets GMAIL as the SMTP server
$mail->Port = 587; // set the SMTP port for the GMAIL server 465 or 587
$mail->Username = "mygmailaddress"; // GMAIL username $myemail
$mail->Password = "mypassword"; // GMAIL password

$mail->SetFrom('emailaddress','Admin'); // "name@yourdomain.com";
$mail->FromName = $yourname;  // set from Name
$mail->Subject = $subject;
$mail->Body = $message;

$mail->AddAddress("emailaddress"); // to Address

if($mail->Send())
{
echo "<html><body><span>Thank you for your enquiry. Please</span><a href=enquiry.html>Click Hear</a><span>to continue</span></body></html>";
}
else
{
echo "<html><body><span>Error in sending email. Please</span><a href=enquiry.html>Click Hear</a><span>to continue</span></body></html> ";
}
Posted
Comments
Christian Graus 31-Jul-12 23:46pm    
Have you looked at your other settings, or tried changing them ?

In my mail client, my Gmail account uses port 465. Also, my username is my full address (with @gmail.com); I can't tell from your anonymized snippet whether you have done this. Also, does your SetFrom address correspond to your Username? (If not, I think you have to go through some sort of authentication process with GMail to convince it you "own" both accounts.)
 
Share this answer
 
Comments
rohit_189 1-Aug-12 9:43am    
i use admin@hotelmansoonhaveli.com for this. i created this id through google apps. in start it send email from same code but now shows the error.
I haven't seen this with GMail, but every so often Hotmail refuses to accept outgoing mail via SMTP until I log in through the web interface and solve a Captcha. Try logging into GMail via the web and see if you have the right password.
 
Share this answer
 
Comments
rohit_189 2-Aug-12 11:18am    
I tried this and the password is correct. don't know what happen with this. it working in start but now all messed up

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900