Jump to content

SMTP Error: Could not authenticate


Paulo Jorge

Recommended Posts

tinha este código funcional, mas de repente deixou de dar e apareceu este erro alguem me sabe dizer o porque ?

// value sent from form
$nome=$_POST['nome'];
$email=$_POST['email'];
$assunto=$_POST['assunto'];
$mensagem=$_POST['mensagem'];
//error_reporting(E_ALL);
error_reporting(E_STRICT);

date_default_timezone_set('America/Toronto');

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

$mail = new PHPMailer();

//$body = file_get_contents('contents.html');
$body = $mensagem;//eregi_replace("[\]",'',$body);

$mail->IsSMTP(); // telling the class to use SMTP
$mail->Host = "mail.yourdomain.com"; // SMTP server
$mail->SMTPDebug = 2; // enables SMTP debug information (for testing)
// 1 = errors and messages
// 2 = messages only
$mail->SMTPAuth = true; // enable SMTP authentication
$mail->SMTPSecure = "tsl"; // sets the prefix to the servier
$mail->Host = "smtp.gmail.com"; // sets GMAIL as the SMTP server
$mail->Port = 587; // set the SMTP port for the GMAIL server
$mail->Username = "...@gmail.com"; // GMAIL username
$mail->Password = "...."; // GMAIL password

$mail->SetFrom($email, $nome);

$mail->AddReplyTo("name@yourdomain.com","First Last");

$mail->Subject = $assunto;

$mail->AltBody = "Olá, ".$name; // optional, comment out and test

$mail->MsgHTML($body);

$address = $email;
$mail->AddAddress('paulojorgeoliveiralopes@gmail.com', 'Paulo Lopes');

$mail->AddAttachment("images/infor.gif"); // attachment
$mail->Send();
Link to comment
Share on other sites

Eu tenho um endereço diferente de ligação ao servidor do GMail.

Experimentei agora e funcionou bem:

<?php
   require_once('class.phpmailer.php');
   $mail = new PHPMailer();

   // ---------- adjust these lines ---------------------------------------
   $mail->Username = "meuutilizador@gmail.com"; // your GMail user name
   $mail->Password = "minhapassword";
   $mail->AddAddress("endereço de envio@hotmail.com"); // recipients email
   $mail->FromName = "nome de envio"; // readable name

   $mail->Subject = "Subject title";
   $mail->Body    = "Here is the message you want to send to your friend.";
   //-----------------------------------------------------------------------

   $mail->Host = "ssl://smtp.gmail.com"; // GMail
   $mail->Port = 465;
   $mail->IsSMTP(); // use SMTP
   $mail->SMTPAuth = true; // turn on SMTP authentication
   $mail->From = $mail->Username;
   if(!$mail->Send())
    echo "Mailer Error: " . $mail->ErrorInfo;
   else
    echo "Message has been sent";
?>

Podes tirar isto também, não está lá a fazer nada.

$mail->Host = "mail.yourdomain.com"; // SMTP server

Link to comment
Share on other sites

  • 1 year later...

{Resposta - Resolvido AQUI}

Olá,

estava com o mesmo problema, e vi aqui nesse tópico que não resolveram. Então criei minha conta só pra passar a SOLUÇÃO para vocês e para outros que irão ainda ver esse tópico nesse ótimo Fórum (Portugal-a-Programar).

É o seguinte:

O GMail esta bloqueando outros aplicativos (clientes) de usarem, por questão de segurança (que acho desnecessário).

Então, lá vai a solução simples:

1- Logue em sua conta do Gmail

2- Vá nesse site: https://accounts.google.com/b/0/DisplayUnlockCaptcha

3- Clique em Continuar (Botãozinho Azul)

4- Pronto

//--------------------------------------------------------

Espero ter ajudado.

Se lhe ajudei, você pode me dizer obrigado. 😉

Qualquer dúvida, agradecimento ou algo do tipo, mande-me mensagem: guihgo100milha@gmail.com

Obs.: Sou Brasileiro.

Até a próxima. 👍

bY: Guihgo :{)

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site you accept our Terms of Use and Privacy Policy. We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.