0
I’m having a problem sending an email with user registration validation code from my localhost. On my localhost I have Wamp Server installed configured to use port 80, I have redirected all external access to my host’s IP to port 80 so it is possible to access the server externally for access to the database etc... I did several searches on the internet of how to do this I found tutorials using Sendmail that did not give anything or want an error just said that the email was sent, but when checking the inbox of the email nothing. I found Phpmailer who at least presented an error that was:
SERVER -> CLIENT: SMTP NOTICE: EOF Caught while checking if Connected SMTP error: Unable to perform authentication. SMTP Connect() failed. https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting Error: SMTP Connect() failed. https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting
NOTE: I did everything that the tutorials said I even tried to use an example for gmail that comes along with the class when you download on Github. Could someone give me a solution or alternative that is not paid for? Below my php code:
<?php
require 'phpmailer/PHPMailerAutoload.php';
$mail = new PHPMailer;
$mail->setLanguage('pt');
$mail->SMTPDebug = 2;
$mail->Debugoutput = 'html';
$host = 'smtp.gmail.com';
$username = '[email protected]';
$password = 'minha_senha';
$port = 465;
$secure = 'ssl';
$from = $username;
$fromName = 'Meu Nome Completo';
$mail->IsSMTP();
$mail->Host = $host;
$mail->SMTPAuth = true;
$mail->Username = $username;
$mail->Password = $password;
$mail->Port = $port;
$mail->SMTPSecure = $secure;
$mail->From = $from;
$mail->FromName = $fromName;
$mail->addReplyTo($from, $fromName);
$mail->addAddress('destinatario@qualquer_dominio.com', 'Nome do Destinatario');
$mail->isHTML(true);
$mail->CharSet = 'utf-8';
$mail->WordWrap = 50;
$mail->Subjet = 'Testando phpmail';
$mail->Body = 'Enviando emails com <b>PHPMailer</b> para <h2>TESTE</h2>';
$mail->AltBody = 'Enviando emails com PHPMailer para TESTE';
$send = $mail->Send();
if($send) {
echo 'E-mail enviado com sucesso!';
} else {
echo 'Erro: ' . $mail->ErrorInfo;
}
?>
The error is in authentication. Have you tried port 587? The TLS order is a little different on 587. One more detail: nowadays you can not use google accounts via SMTP with user and password, need to use user + token (SASL) instead, unless it is enabled the option to allow "less secure applications" in the account. Better check this out too.
– Bacco
Hi tried in every possible way by port 587 appears more errors yet the least error option was to 465 using ssl. Regarding the google account I enabled everything I found in my searches including access by less secure app.
– Gustavo Almeida Cavalcante