Error sending email with PHPMAILER

Asked

Viewed 662 times

0

Hello, follow the code:

Inicia a classe PHPMailer
$mail = new PHPMailer();


$mail->IsSMTP(); 
$mail->Host = "smtp.dominio.com"; 
$mail->Username = '[email protected]'; // Usuário do servidor SMTP
$mail->Password = 'senha123'; // Senha do servidor SMTP


$mail->From = "[email protected]"; 
$mail->FromName = "meu dominio"; 



$mail->AddAddress("meuemail","meunome");

$mail->IsHTML(true); 

$mail->Subject  = "Confirmação de pagamento";
$mail->Body = "meu email em html..";


$enviado = $mail->Send();


$mail->ClearAllRecipients();
$mail->ClearAttachments();


if ($enviado) {
echo "E-mail enviado com sucesso!";
} else {
echo "Não foi possível enviar o e-mail.<br /><br />";
echo "<b>Informações do erro:</b> <br />" . $mail->ErrorInfo;
}

Follow the error:

It was not possible to send the email.

Error message: SMTP connect() failed.Could not send the email.

Error information§ãµes: SMTP connect() failed.

Anyway, has this error ever occurred with anyone? And what was the reason? I already enabled the ssl line there in php.ini that I heard some say I needed..

  • 1

    Set door and security type in phpmailer?

  • I had not set, but I set it for testing purposes, but the error persisted. I set these two lines: $mail->Port = 465;&#xA;$mail->SMTPAuth = true; Thanks for the help lost.

  • 2

    Solved, the host was wrong, I mistook the domain as being a host, which is actually where the domain is hosted.. the door I used 587, thank you all!

  • If your Script version is current, Phpmailer, your server is to be in version 5+ of PHP. Check this on your hosting.

  • I understand, but the mistake in question was to confuse domain with hosting, I was putting there on the Host the domain of the site I was using, and it does not give hosting, and I also put the 587 post. I will mark it as useful, because in fact it is necessary to update there in the site CPANEL PHP.

1 answer

1

Exchange the require('class.phpmailer.php'); for require('PHPMailerAutoload.php');

Don’t forget to check if you have the file Phpmailerautoload.php in the folder where you are calling Phpmailer

  • I do, and I made that change and the mistake persists, thank you for helping Alisson.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.