phpmailer in hosting postage

-2

I am using the phpmailer class to send emails from my website, when I use it locally, the email is sent correctly, but when I use it on the server it only shows me that it has not been possible to accept the password. My user. I attach the code.

<html>
<head>
<title>PHPMailer - SMTP (Gmail) advanced test</title>
</head>
<body>

<?php
require_once('class.phpmailer.php');
//include("class.smtp.php"); // optional, gets called from within     class.phpmailer.php if not already loaded

$mail = new PHPMailer(true); // the true param means it will throw    exceptions on errors, which we need to catch

$mail->IsSMTP(); // telling the class to use SMTP

try {
$mail->Host       = "mail.yourdomain.com"; // SMTP server
$mail->SMTPDebug  = 2;                     // enables SMTP debug  information (for testing)
$mail->SMTPAuth   = true;                  // enable SMTP authentication
$mail->SMTPSecure = "ssl";                 // sets the prefix to the servier
$mail->Host       = "smtp.gmail.com";      // sets GMAIL as the SMTP server
$mail->Port       = 465;                   // set the SMTP port for the GMAIL server
$mail->Username   = "[email protected]";  // GMAIL username
$mail->Password   = "yourpassword";            // GMAIL password
$mail->AddAddress('[email protected]', 'John Doe');
$mail->SetFrom('[email protected]', 'First Last');
$mail->AddReplyTo('[email protected]', 'First Last');
$mail->Subject = 'PHPMailer Test Subject via mail(), advanced';
$mail->AltBody = 'To view the message, please use an HTML compatible email viewer!'; // optional - MsgHTML will create an alternate automatically
$mail->MsgHTML(file_get_contents('contents.html'));
$mail->AddAttachment('images/phpmailer.gif');      // attachment
$mail->AddAttachment('images/phpmailer_mini.gif'); // attachment
$mail->Send();
echo "Message Sent OK</p>\n";
} catch (phpmailerException $e) {
echo $e->errorMessage(); //Pretty error messages from PHPMailer
} catch (Exception $e) {
echo $e->getMessage(); //Boring error messages from anything else!
}
?>

</body>
</html>

the error is the following

SMTP -> ERROR: Password not accepted from server: 534-5.7.14
    
asked by Jesus 16.12.2016 в 22:58
source

1 answer

-1

I think this link could help you. The problem seems similar, although treated in English: PHPMailer - SMTP ERROR: Password command failed when send mail from my server

In short, the problem could be caused by some kind of external application that tries to use your email account, the repeated attempt to start the session or the login from a different country.

A possible solution for some users is:

-Access the account through the web

- Check recent attempts to access the account and accept suspicious access: link

- Deactivate the suspicious applications / technologies blocking feature: link

In addition to the above, some users have reported having to delete the captcha to login.

    
answered by 16.12.2016 / 23:15
source