Tengo un problema hace ya varios días y no estoy encontrando una solucion por ningun lado, primero probe con php mail, y no me funcionaba y me recomendaron usar php mailer, pero de igual manera creo que el servidor de correo seguro no funciona o nose que pasa.., me sale que el mensaje es enviado y sale un mensaje raro, mi codigo es el siguiente. Formulario HTML:
<!DOCTYPE html>
<html>
<head>
<title>FORMULARIO</title>
</head>
<body>
<form action="PHPMailer-master/enviarmail.php" method="post">
<h3>Nombre</h3>
<input type="text" name="nombre">
<h3>Apellido</h3>
<input type="text" name="apellido">
<h3>Mensaje</h3>
<textarea name="mensaje"></textarea>
Enviar
<input type="submit" value="Enviar">
</form>
</body>
</html>
Codigo php:
<?php
// Import PHPMailer classes into the global namespace
// These must be at the top of your script, not inside a function
use PHPMailer\PHPMailer\PHPMailer;
use PHPMailer\PHPMailer\Exception;
//Load Composer's autoloader
require 'src/Exception.php';
require 'src/PHPMailer.php';
require 'src/SMTP.php';
$mail = new PHPMailer(true); // Passing `true` enables exceptions
try {
//Server settings
$mail->SMTPDebug = 2; // Enable verbose debug output
$mail->isSMTP();
// Set mailer to use SMTP
$mail->Host = 'single-priva4.privatednsorg.com:465'; // Specify main and backup SMTP servers
$mail->SMTPAuth = true; // Enable SMTP authentication
$mail->Username = '[email protected]'; // SMTP username
$mail->Password = 'Juanse123.'; // SMTP password
$mail->SMTPSecure = 'ssl'; // Enable TLS encryption, `ssl` also accepted
$mail->Port = 465; // TCP port to connect to
$nombre=$_POST['nombre'];
$apellido=$_POST['apellido'];
$mensaje=$_POST['mensaje'];
//Content
$mail->isHTML(true); // Set email format to HTML
$mail->Subject = 'CURSO';
$mail->Body = 'NOMBRE: ' . $nombre . "<br>Apellido: " . $apellido . "<br>Mensaje: " . $mensaje ;
$mail->AltBody = 'Ejemplo de BODY 2';
$mail->send();
echo 'Mensaje enviado';
} catch (Exception $e) {
echo 'Message could not be sent. Mailer Error: ', $mail->ErrorInfo;
}
?>
Al ejecutar en mi hosting, me sale mensaje enviado y este mensaje:
2018-08-16 15:18:56 SERVER -> CLIENT: 220-single-priva4.privatednsorg.com ESMTP Exim 4.91 #1 Thu, 16 Aug 2018 11:18:56 -0400 220-We do not authorize the use of this system to transport unsolicited, 220 and/or bulk e-mail.
2018-08-16 15:18:56 CLIENT -> SERVER: EHLO www.cygnus.com.py
2018-08-16 15:18:56 SERVER -> CLIENT: 250-single-priva4.privatednsorg.com Hello www.cygnus.com.py [65.60.62.226]250-SIZE 52428800250-8BITMIME250-PIPELINING250-AUTH PLAIN LOGIN250 HELP
2018-08-16 15:18:56 CLIENT -> SERVER: AUTH LOGIN
2018-08-16 15:18:56 SERVER -> CLIENT: 334 VXNlcm5hbWU6
2018-08-16 15:18:56 CLIENT -> SERVER: <credentials hidden>
2018-08-16 15:18:56 SERVER -> CLIENT: 334 UGFzc3dvcmQ6
2018-08-16 15:18:56 CLIENT -> SERVER: <credentials hidden>
2018-08-16 15:18:56 SERVER -> CLIENT: 235 Authentication succeeded
2018-08-16 15:18:56 CLIENT -> SERVER: MAIL FROM:<[email protected]>
2018-08-16 15:18:56 SERVER -> CLIENT: 250 OK
2018-08-16 15:18:56 CLIENT -> SERVER: RCPT TO:<[email protected]>
2018-08-16 15:18:56 SERVER -> CLIENT: 250 Accepted
2018-08-16 15:18:56 CLIENT -> SERVER: DATA
2018-08-16 15:18:56 SERVER -> CLIENT: 354 Enter message, ending with "." on a line by itself
2018-08-16 15:18:56 CLIENT -> SERVER: Date: Thu, 16 Aug 2018 11:18:56 -0400
2018-08-16 15:18:56 CLIENT -> SERVER: To: Juan Portillo <[email protected]>
2018-08-16 15:18:56 CLIENT -> SERVER: From: Juan <[email protected]>
2018-08-16 15:18:56 CLIENT -> SERVER: Subject: CURSO
2018-08-16 15:18:56 CLIENT -> SERVER: Message-ID: <[email protected]>
2018-08-16 15:18:56 CLIENT -> SERVER: X-Mailer: PHPMailer 6.0.5 (https://github.com/PHPMailer/PHPMailer)
2018-08-16 15:18:56 CLIENT -> SERVER: MIME-Version: 1.0
2018-08-16 15:18:56 CLIENT -> SERVER: Content-Type: multipart/alternative;
2018-08-16 15:18:56 CLIENT -> SERVER: boundary="b1_DESKyjWHbKeCItedA7v19pxw5c4LEPadZQO26CnMQ"
2018-08-16 15:18:56 CLIENT -> SERVER: Content-Transfer-Encoding: 8bit
2018-08-16 15:18:56 CLIENT -> SERVER:
2018-08-16 15:18:56 CLIENT -> SERVER: This is a multi-part message in MIME format.
2018-08-16 15:18:56 CLIENT -> SERVER: --b1_DESKyjWHbKeCItedA7v19pxw5c4LEPadZQO26CnMQ
2018-08-16 15:18:56 CLIENT -> SERVER: Content-Type: text/plain; charset=us-ascii
2018-08-16 15:18:56 CLIENT -> SERVER:
2018-08-16 15:18:56 CLIENT -> SERVER: Ejemplo de BODY 2
2018-08-16 15:18:56 CLIENT -> SERVER:
2018-08-16 15:18:56 CLIENT -> SERVER: --b1_DESKyjWHbKeCItedA7v19pxw5c4LEPadZQO26CnMQ
2018-08-16 15:18:56 CLIENT -> SERVER: Content-Type: text/html; charset=us-ascii
2018-08-16 15:18:56 CLIENT -> SERVER:
2018-08-16 15:18:56 CLIENT -> SERVER: NOMBRE: Juan <br>Apellido: Portillo<br>Mensaje: ghdfhgfgfj
2018-08-16 15:18:56 CLIENT -> SERVER:
2018-08-16 15:18:56 CLIENT -> SERVER:
2018-08-16 15:18:56 CLIENT -> SERVER: --b1_DESKyjWHbKeCItedA7v19pxw5c4LEPadZQO26CnMQ--
2018-08-16 15:18:56 CLIENT -> SERVER:
2018-08-16 15:18:56 CLIENT -> SERVER: .
2018-08-16 15:18:57 SERVER -> CLIENT: 250 OK id=1fqK36-00FSCv-FF
2018-08-16 15:18:57 CLIENT -> SERVER: QUIT
2018-08-16 15:18:57 SERVER -> CLIENT: 221 single-priva4.privatednsorg.com closing connection
Mensaje enviado
$mail->addAddress('[email protected]', 'Joe User');