Email PHPMailer for Hotmail

0

I'm not able to send an email form to my Hotmail email. Here are the codes below:

Form with the data that will be sent.

<form id="form-contato" method="post" action="email.php">
    <div>
        <div class="row">
            <div class="6u 12u(mobile)">
                <input type="text" name="name" id="nome" placeholder="Nome" />
            </div>
            <div class="6u 12u(mobile)">
                <input type="text" name="email" id="email" placeholder="Email" />
            </div>
        </div>
        <div class="row">
            <div class="12u">
                <input type="text" name="subject" id="assunto" placeholder="Assunto" />
            </div>
        </div>
        <div class="row">
            <div class="12u">
                <textarea name="message" id="mensagem" placeholder="Mensagem"></textarea>
            </div>
        </div>
        <div class="row 200%">
            <div class="12u">
                <ul class="actions">
                    <li><input type="submit" value="Enviar mensagem"/></li>
                    <li><input type="reset" value="Limpar campos" class="alt" /></li>
                </ul>
            </div>
        </div>
    </div>
</form>

Email.php class to capture form data and send email:

<?php 

  require_once 'PHPMailer/PHPMailerAutoload.php';

  $mail = new PHPMailer;
  $mail->SMTPDebug=1;
  $mail->isSMTP();
  $mail->CharSet = "utf8";
  $mail->Host = 'smtp.live.com';
  $mail->SMTPAuth = true;
  $mail->Username = '[email protected]';
  $mail->Password = 'minhasenha';
  $mail->SMTPSecure = 'tls';
  $mail->Port = 465; 
  $mail->FromName = "De";
  $mail->isHTML(true);
  $mail->addAddress($_POST['email'],$_POST['nome']);
  $mail->Subject = $_POST['assunto'];
  $mail->Body =$_POST['mensagem'];

  if(!$mail->Send()){       
      echo 'Erro ao enviar e-mail: '.$mail->ErrorInfo;
  }else{
      echo 'E-mail enviado';
  }

Error returned:

    
asked by anonymous 10.02.2017 / 15:55

1 answer

2

The port used by hotmail is port 587, then:

$mail->Port = 587;

What can be tried other than changing the port, is to change the SMTPSecure, since Hotmail uses StartTLS , then:

$mail->SMTPSecure = 'ssl';

Check your hotmail settings if it allows an external SMTP client to connect.

    
10.02.2017 / 19:03