E-mail Phpmailer to Hotmail

Asked

Viewed 400 times

1

I am not able to send an email form to my e-mail Hotmail. Below follow the codes:

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:

inserir a descrição da imagem aqui

1 answer

3


The door used by Hotmail is door 587, so:

$mail->Port = 587;

What can be tried besides changing the port, is to change the Smtpsecure , since the Hotmail uses Starttls, then:

$mail->SMTPSecure = 'ssl';

Check the Hotmail settings to see if it allows an external SMTP client to connect.

  • The following error is returned to me:2017-02-12 22:56:49 SMTP ERROR: Failed to connect to server: (0) 2017-02-12 22:56:49 SMTP connect() failed. https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting Error sending email: SMTP connect() failed. https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting

Browser other questions tagged

You are not signed in. Login or sign up in order to post.