I have the following code:
<?php
require'PHPMailerAutoload.php';
$mail = new PHPMailer();
$mail->IsSMTP();
$mail->Port = '465';
$mail->Host = 'smtp.gmail.com';
$mail->IsHTML(true);
$mail->Mailer = 'smtp';
$mail->SMTPSecure = 'ssl';
$mail->SMTPAuth = true;
$mail->Username = '[email protected]';
$mail->Password = 'senhadoemail';
$mail->SingleTo = true;
$mail->From = "[email protected]";
$mail->FromName = "nomedousuario";
$mail->addAddress("[email protected]");
$mail->Subject = "assunto do email";
$mail->Body = "conteudo do email";
if(!$mail->Send()){
echo "Erro ao enviar Email:" . $mail->ErrorInfo;
}else{
echo "Mensagem enviada com sucesso!"
}
?>
This code works normally, sending emails from a sender that has a Gmail account to any other account, the problem is that switching to Live / Hotmail does not work. The changes I tried to make were as follows:
$mail->Host = 'smtp.live.com';
$mail->SMTPSecure = 'tsl';
I also changed the sender's email to @ hotmail.com .
The error I get is: SMTP connection failed()
.
I ran this code in localhost and would like to know what I'm doing wrong.