PHPMailer, parece que envía pero no llega el mensaje

publicado por: Anonymous

sé que acabo de hacer una pregunta que me respondieron y solucioné el problema. Pero ahora resulta que PHPMailer me devuelve un “Mensaje enviado” pero no es cierto, no se ha enviado el mensaje. Quisiera saber a qué se debe esto..

enviar_mensaje.php

date_default_timezone_set('Etc/UTC');
require 'PHPMailer/PHPMailerAutoload.php';

require ('conexion.php');


$mail = new PHPMailer;

$mail->isSMTP();
$mail->SMTPDebug = 2;
$mail->Debugoutput = 'html';
$mail->Host = 'smtp.gmail.com';

$mail->Port = 587;
$mail->SMTPSecure = 'tls';
$mail->SMTPAuth = true;

$mail->CharSet = 'UTF-8';

$mail->Username = "[email protected]";
$mail->Password = "contrasena";
$mail->setFrom('[email protected]', 'Diana Hurtado');
$mail->addAddress('[email protected]', 'Marcela Gomez');
$mail->Subject = '¡Mensaje!';
$mail->msgHTML("<!DOCTYPE html>
                <html lang='en'>
                <head>
                    <meta charset='UTF-8'>
                    <title>Título</title>
                </head>
                <body>
                    Hola!

                </body>
                </html>");

if (!$mail->send()) {
    echo "Ha ocurrido un error, el mensaje no ha sido enviado: " . $mail->ErrorInfo;
} else {
    echo "Mensaje enviado!";
}

y el mensaje que aparece es:

SERVER -> CLIENT: 220 smtp.gmail.com ESMTP 195sm3190887vkv.33 - gsmtp
CLIENT -> SERVER: EHLO localhost
SERVER -> CLIENT: 250-smtp.gmail.com at your service, [186.30.156.224]250-SIZE 35882577250-8BITMIME250-STARTTLS250-ENHANCEDSTATUSCODES250-PIPELINING250-CHUNKING250 SMTPUTF8
CLIENT -> SERVER: STARTTLS
SERVER -> CLIENT: 220 2.0.0 Ready to start TLS
CLIENT -> SERVER: EHLO localhost
SERVER -> CLIENT: 250-smtp.gmail.com at your service, [186.30.156.224]250-SIZE 35882577250-8BITMIME250-AUTH LOGIN PLAIN XOAUTH2 PLAIN-CLIENTTOKEN OAUTHBEARER XOAUTH250-ENHANCEDSTATUSCODES250-PIPELINING250-CHUNKING250 SMTPUTF8
CLIENT -> SERVER: AUTH LOGIN
SERVER -> CLIENT: 334 VXNlcm5hbWU6
CLIENT -> SERVER: QmljaUJvZ290YTIwMTdAZ21haWwuY29t
SERVER -> CLIENT: 334 UGFzc3dvcmQ6
CLIENT -> SERVER: YmljaWJvZ290YWNvbnRyYXNlbmE=
SERVER -> CLIENT: 235 2.7.0 Accepted
CLIENT -> SERVER: MAIL FROM:<[email protected]>
SERVER -> CLIENT: 250 2.1.0 OK 195sm3190887vkv.33 - gsmtp
CLIENT -> SERVER: RCPT TO:<[email protected]>
SERVER -> CLIENT: 250 2.1.5 OK 195sm3190887vkv.33 - gsmtp
CLIENT -> SERVER: DATA
SERVER -> CLIENT: 354 Go ahead 195sm3190887vkv.33 - gsmtp
CLIENT -> SERVER: Date: Tue, 25 Jul 2017 14:56:29 +0000
CLIENT -> SERVER: Return-Path: <[email protected]>
CLIENT -> SERVER: To: Marcela Gomez <[email protected]>
CLIENT -> SERVER: From: Diana Hurtado <[email protected]>
CLIENT -> SERVER: Subject: =?UTF-8?Q?=C2=A1Mensaje!?=
CLIENT -> SERVER: Message-ID: <[email protected]>
CLIENT -> SERVER: X-Priority: 3
CLIENT -> SERVER: X-Mailer: PHPMailer 5.2.7 (https://github.com/PHPMailer/PHPMailer/)
CLIENT -> SERVER: MIME-Version: 1.0
CLIENT -> SERVER: Content-Type: multipart/alternative;
CLIENT -> SERVER: boundary="b1_42d2d2fabd7f4018ffa2819b94dd83f7"
CLIENT -> SERVER: Content-Transfer-Encoding: 8bit
CLIENT -> SERVER: 
CLIENT -> SERVER: --b1_42d2d2fabd7f4018ffa2819b94dd83f7
CLIENT -> SERVER: Content-Type: text/plain; charset=us-ascii
CLIENT -> SERVER: 
CLIENT -> SERVER: Hola!
CLIENT -> SERVER: 
CLIENT -> SERVER: 
CLIENT -> SERVER: --b1_42d2d2fabd7f4018ffa2819b94dd83f7
CLIENT -> SERVER: Content-Type: text/html; charset=UTF-8
CLIENT -> SERVER: Content-Transfer-Encoding: 8bit
CLIENT -> SERVER: 
CLIENT -> SERVER: <!DOCTYPE html>
CLIENT -> SERVER: <html lang='en'>
CLIENT -> SERVER: <head>
CLIENT -> SERVER: <meta charset='UTF-8'>
CLIENT -> SERVER: <title>Título</title>
CLIENT -> SERVER: </head>
CLIENT -> SERVER: <body>
CLIENT -> SERVER: Hola!
CLIENT -> SERVER: 
CLIENT -> SERVER: </body>
CLIENT -> SERVER: </html>
CLIENT -> SERVER: 
CLIENT -> SERVER: 
CLIENT -> SERVER: 
CLIENT -> SERVER: --b1_42d2d2fabd7f4018ffa2819b94dd83f7--
CLIENT -> SERVER: 
CLIENT -> SERVER: .
SERVER -> CLIENT: 250 2.0.0 OK 1500994689 195sm3190887vkv.33 - gsmtp
CLIENT -> SERVER: QUIT
SERVER -> CLIENT: 221 2.0.0 closing connection 195sm3190887vkv.33 - gsmtp
Mensaje enviado!

solución

Debes configurar primero el correo donde recibirás los mensajes, ya que gmail protege tu correo de mensajes provenientes de servidores desconocidos para él deberás activar el IMAP en tu correo de gmail, esto se hace entrando a configuración, Reenvio y correo POP/IMAP y activar IMAP.

También verifica la forma en las que estas enviando el correo. ya que tu username ‘[email protected]’ no creo que exista.

Suerte y no dudes en preguntar

Respondido por: Anonymous

Leave a Reply

Your email address will not be published. Required fields are marked *