1
I’m trying to send an email from my Localhost, but I can’t.
My code:
<?php
require_once('config/phpmailer/class.phpmailer.php');
//
//$email = $_POST["email"];
//
$mail = new PHPMailer();
//
$mail->IsSMTP(true);
$mail->Host = "smtp.gmail.com";
$mail->Port = 587;
$mail->SMTPAuth = true;
$mail->SMTPDebug = 1;
$mail->SMTPSecure = 'ssl';
$mail->Username = '[email protected]';
$mail->Password = 'mypassword';
//
$mail->From = "mygmail";
$mail->FromName = "hello";
//
$mail->AddAddress($email, 'assunto');
$mail->IsHTML(true);
$mail->Subject = "hello!";
$mail->Body = "oi teste";
$enviado = $mail->Send();
$mail->ClearAllRecipients();
$mail->ClearAttachments();
if ($enviado) {
$error = "E-mail enviado com sucesso!";
}
else {
echo "Não foi possível enviar o e-mail.";
$error = "<b>Informações do erro:</b> " . $mail->ErrorInfo;
}
?>
Error:
The following From address failed: [email protected] : Called Mail() without being connected
I’ve already released the account to devices on google, already tried to change ssl to tls too. The email and password are also correct.
Apparently it’s all right, just check the host if it’s correct. checks if the recipient’s email is correct, switches to another, makes diversifications of the code.
– Fábio Alves
I tried :( I changed the email you send, the email you receive, the smpt port, the program I use localhost, message, script also :( until the email password I changed. Do you know any alternative?
– Luan pedro
I tried other versions of phpmailer too.
– Luan pedro
Gmail’s smtp port is
465
– Fábio Alves