Personal I'm having a problem sending an email with user registration validation code from my localhost. In my localhost I have the Wamp Server installed configured to use port 80, I redirected all external accesses to the IP of my host to port 80 in this way it is possible to access the server externally for access to the database etc ... I did several searches on the internet how to do this I found tutorials using Sendmail that did not give anything or if an error just said that the email was sent, but when checking in the email inbox nothing. I found PHPMailer that at least presented an error that was:
SERVER - > CLIENT: SMTP NOTICE: EOF caught while checking if connected SMTP Error: Authentication failed. SMTP Connect () failed. link Error: SMTP Connect () failed. link
NOTE: I did everything the tutorials said I even tried to use an example for gmail that comes with the class when you download Github. Could someone give me a solution or alternative that is not paid? 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;
}
?>