Boa Tarde, fiz um código em php e ja faz 2 dias que estou tentando testar o envio de e-mail e esta dando o erro : SMTP Error: Could not connect to SMTP host. Erro: Não foi possível enviar a mensagem. SMTP Error: Could not connect to SMTP host segue o código :
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head> <meta charset="utf-8"> <title>EAD - Teste</title> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="description" content=""> <meta name="author" content=""></head><body><?php//Dados do formulário$nome = "Sergio"; $assunto = "Teste E-mail"; $fone = "996206485"; $email = "
[email protected]"; $mensagem = "teste"; //Monta a mensagem que será enviada$body = " Nome: $nome <br/> E-mail: $email<br/> Telefone: $fone<br/> Mensagem: $mensagem ";//Credenciais$username = "
[email protected]";$password = "minhasenha";$remetente = array("Cliente", "
[email protected]");$destinatario = "
[email protected]"; //Instancia a classe phpmailer.phprequire("phpmailer/class.phpmailer.php");include("phpmailer/class.smtp.php");$mail = new PHPMailer();$mail->SetLanguage("br"); $mail->isSMTP(); $mail->Port = 465; $mail->Host = "smtp.gmail.com"; $mail->SMTPAuth = true; $mail->SMTPSecure = "ssl"; $mail->Username = $username; $mail->Password = $password; $mail->FromName = $remetente[0]; $mail->From = $remetente[1]; $mail->Subject = $assunto; $mail->Body = $body; $mail->AddAddress($destinatario); if ($mail->send()):echo "<center>Ok! Mensagem Enviada com Sucesso</center>";else:echo "Erro: Não foi possível enviar a mensagem.<br/> $mail->ErrorInfo "; endif;?></body></html>
Ja habilitei a extensão sll no wamp server no localhost , ja dei unlockcaptcha no gmail e nada