PHP - Error - PHPMailer

 
Vista:
sin imagen de perfil
Val: 85
Ha aumentado 1 puesto en PHP (en relación al último mes)
Gráfica de PHP

Error - PHPMailer

Publicado por Luis (33 intervenciones) el 15/12/2017 12:00:19
Tengo el siguiente error cuando intento enviar un correo de forma local mediante un formulario php

1
Error: SMTP connect() failed. https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting

A ver si alguien me puede echar una mano.
Mi código de configuración de es siguiente:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
<?php
 
require './phpmailer/PHPMailerAutoload.php';
 
$mail = new PHPMailer;
 
$nombre = $_POST['name'];
$email = $_POST['email'];
$telefono = $_POST['phone'];
$mensaje = $_POST['message'];
 
$mail->isSMTP();
$mail->Host = 'smtp.gmail.com';
$mail->SMTPAuth = true;
$mail->Username = '******@gmail.com';
$mail->Password = '********';
$mail->SMTPSecure = 'ssl';
$mail->Port = 465;
 
$mail->setFrom('*********@hotmail.com', 'Luis');
$mail->addAddress($email,$nombre);
//$mail->isHTML(true);  
 
$bodyContent = 'Contenido del mensaje<br><br>Nombre: '.$nombre.'<br><br>Email: '.$email.'<br><br>
	Teléfono: '.$telefono.'<br><br>Mensaje:<br>'.$mensaje.' ';
 
$mail->Subject = 'Asunto';
$mail->Body    = $bodyContent;
 
 
if($mail->Send())
{
    echo'<script type="text/javascript">
            alert("Enviado Correctamente");
         </script>';
}
else{
 
    echo'Error: '.$mail->ErrorInfo;
}
 
 
?>
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder
Imágen de perfil de xve
Val: 3.943
Oro
Ha mantenido su posición en PHP (en relación al último mes)
Gráfica de PHP

Error - PHPMailer

Publicado por xve (6935 intervenciones) el 15/12/2017 16:19:26
Hola Luis, el error esta claro... no se puede conectar con el servidor de correo...

prueba a habilitar el debug...
1
$mail->SMTPDebug = 3;

haber que te dice...


Intenta probar esta configuración (https://www.lawebdelprogramador.com/codigo/PHP/1884-Envio-de-correo-mediante-servidor-SMTP.html):
1
2
3
4
5
6
$mail->SMTPAuth   = true;
$mail->SMTPSecure = "tls";
$mail->Host       = "smtp.gmail.com";
$mail->Username   = "miCuenta@gmail.com";
$mail->Password   = "miPassword";
$mail->Port       = 587;
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar
sin imagen de perfil
Val: 85
Ha aumentado 1 puesto en PHP (en relación al último mes)
Gráfica de PHP

Error - PHPMailer

Publicado por Luis (33 intervenciones) el 18/12/2017 09:07:49
Este es el nuevo error que me sale:

1
2017-12-18 08:21:20	Connection: opening to smtp.gmail.com:587, timeout=300, options=array ( ) 2017-12-18 08:21:29	Connection: opened 2017-12-18 08:21:29	SERVER -> CLIENT: 220 smtp.gmail.com ESMTP d71sm8974842wma.7 - gsmtp 2017-12-18 08:21:29	CLIENT -> SERVER: EHLO localhost 2017-12-18 08:21:29	SERVER -> CLIENT: 250-smtp.gmail.com at your service, [88.27.244.72] 250-SIZE 35882577 250-8BITMIME 250-STARTTLS 250-ENHANCEDSTATUSCODES 250-PIPELINING 250-CHUNKING 250 SMTPUTF8 2017-12-18 08:21:29	CLIENT -> SERVER: STARTTLS 2017-12-18 08:21:30	SERVER -> CLIENT: 220 2.0.0 Ready to start TLS 2017-12-18 08:21:40	SMTP Error: Could not connect to SMTP host. 2017-12-18 08:21:40	SMTP NOTICE: EOF caught while checking if connected 2017-12-18 08:21:40	Connection: closed 2017-12-18 08:21:40	SMTP connect() failed. https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting 

Tras cambiar los parametros
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar
sin imagen de perfil
Val: 85
Ha aumentado 1 puesto en PHP (en relación al último mes)
Gráfica de PHP

Error - PHPMailer

Publicado por Luis (33 intervenciones) el 19/12/2017 09:11:47
Necesito ayuda T.T
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar