Estoy tratando de enviar un correos a través de un formulario html
con php
, el código que uso es el siguiente:
$mail = new PHPMailer(true);
try {
//Server settings
$mail->SMTPDebug = 2; // Enable verbose debug output
$mail->isSMTP(); // Set mailer to use SMTP
$mail->Host = 'smtp.office365.com'; // Specify main and backup SMTP servers
$mail->SMTPAuth = true; // Enable SMTP authentication
$mail->Username = 'correo@domio.com'; // SMTP username
$mail->Password = 'passwordCorreo'; // SMTP password
$mail->SMTPSecure = 'tls'; // Enable TLS encryption, `ssl` also accepted
$mail->Port = 587;
//Recipients
$mail->setFrom($from, $username);
$mail->addAddress($address, 'Contacto'); // Add a recipient
// Content
$mail->isHTML(true); // Set email format to HTML
$mail->Subject = $subject;
$mail->Body = "<b>".$body."</b>";
$mail->send();
echo 'Message has been sent';
} catch (Exception $e) {
echo "Message could not be sent. Mailer Error: {$mail->ErrorInfo}";
}
Por lo que he visto en varios foros y publicaciones mi código no esta mal ya que es el mismo que proporciona PHPMAILER
para las conexiones, lo único que cambié son los parámetros de conexión a mi servidor de correo.
El error que me genera es el siguiente:
2019-07-05 16:00:52 SERVER -> CLIENT: 220 PR2PR09CA0009.outlook.office365.com Microsoft ESMTP MAIL Service ready at Fri, 5 Jul 2019 16:00:51 +0000
2019-07-05 16:00:52 CLIENT -> SERVER: EHLO localhost
2019-07-05 16:00:53 SERVER -> CLIENT: 250-PR2PR09CA0009.outlook.office365.com Hello [200.77.121.178]250-SIZE 157286400250-PIPELINING250-DSN250-ENHANCEDSTATUSCODES250-STARTTLS250-8BITMIME250-BINARYMIME250-CHUNKING250 SMTPUTF8
2019-07-05 16:00:53 CLIENT -> SERVER: STARTTLS
2019-07-05 16:00:53 SERVER -> CLIENT: 220 2.0.0 SMTP server ready
2019-07-05 16:00:54 CLIENT -> SERVER: EHLO localhost
2019-07-05 16:00:54 SERVER -> CLIENT: 250-PR2PR09CA0009.outlook.office365.com Hello [200.77.121.178]250-SIZE 157286400250-PIPELINING250-DSN250-ENHANCEDSTATUSCODES250-AUTH LOGIN XOAUTH2250-8BITMIME250-BINARYMIME250-CHUNKING250 SMTPUTF8
2019-07-05 16:00:54 CLIENT -> SERVER: AUTH LOGIN
2019-07-05 16:00:54 SERVER -> CLIENT: 334 VXNlcm5hbWU6
2019-07-05 16:00:54 CLIENT -> SERVER: <credentials hidden>
2019-07-05 16:00:54 SERVER -> CLIENT: 334 UGFzc3dvcmQ6
2019-07-05 16:00:54 CLIENT -> SERVER: <credentials hidden>
2019-07-05 16:00:58 SERVER -> CLIENT: 235 2.7.0 Authentication successful
2019-07-05 16:00:58 CLIENT -> SERVER: MAIL FROM:<selarbac.angel@hotmail.com>
2019-07-05 16:00:58 SERVER -> CLIENT: 250 2.1.0 Sender OK
2019-07-05 16:00:58 CLIENT -> SERVER: RCPT TO:<comercializacion_vikingo@hergarza.com.mx>
2019-07-05 16:00:58 SERVER -> CLIENT: 250 2.1.5 Recipient OK
2019-07-05 16:00:58 CLIENT -> SERVER: DATA
2019-07-05 16:00:58 SERVER -> CLIENT: 354 Start mail input; end with <CRLF>.<CRLF>
2019-07-05 16:00:58 CLIENT -> SERVER: Date: Fri, 5 Jul 2019 18:00:52 +0200
2019-07-05 16:00:58 CLIENT -> SERVER: To: Contacto <correo@dominio.com>
2019-07-05 16:00:58 CLIENT -> SERVER: From: angel <Correo@ejemplo.com>
2019-07-05 16:00:58 CLIENT -> SERVER: Subject: prueba
2019-07-05 16:00:58 CLIENT -> SERVER: Message-ID: <qnIg2OM4a9NZSGR25nPDtj8wHauwwjRZqHGVgZbV0M@localhost>
2019-07-05 16:00:58 CLIENT -> SERVER: X-Mailer: PHPMailer 6.0.7 (https://github.com/PHPMailer/PHPMailer)
2019-07-05 16:00:58 CLIENT -> SERVER: MIME-Version: 1.0
2019-07-05 16:00:58 CLIENT -> SERVER: Content-Type: text/html; charset=iso-8859-1
2019-07-05 16:00:58 CLIENT -> SERVER:
2019-07-05 16:00:58 CLIENT -> SERVER: <b>prueba mensaje</b>
2019-07-05 16:00:58 CLIENT -> SERVER:
2019-07-05 16:00:58 CLIENT -> SERVER: .
2019-07-05 16:00:59 SERVER -> CLIENT: 554 5.2.0
El error generado es el siguiente:
STOREDRV.Submission.Exception:SendAsDeniedException.MapiExceptionSendAsDenied; Failed to process message due to a permanent exception with message Cannot submit message. 16.55847:260F0000, 17.43559:0000000004020000000000000100000000000000, 20.52176:140FF0870800F01FCB030000, 20.50032:140FF0878317401080030400, 0.35180:D0030000, 255.23226:0A00A382, 255.27962:0A000000, 255.27962:0E000000, 255.31418:1F000130, 16.55847:88000000, 17.43559:00000000E0020000000000000200000000000000, 20.52176:140FF087080040108
2019-07-05 16:00:59 SMTP ERROR: DATA END command failed: 554 5.2.0 STOREDRV.Submission.Exception:SendAsDeniedException.MapiExceptionSendAsDenied; Failed to process message due to a permanent exception with message Cannot submit message. 16.55847:260F0000, 17.43559:0000000004020000000000000100000000000000, 20.52176:140FF0870800F01FCB030000, 20.50032:140FF0878317401080030400, 0.35180:D0030000, 255.23226:0A00A382, 255.27962:0A000000, 255.27962:0E000000, 255.31418:1F000130, 16.55847:88000000, 17.43559:00000000E0020000000000000200000000000000, 20.52176:140FF087080040108
SMTP Error: data not accepted.
Message could not be sent. Mailer Error: SMTP Error: data not accepted.SMTP server error: DATA END command failed Detail: STOREDRV.Submission.Exception:SendAsDeniedException.MapiExceptionSendAsDenied; Failed to process message due to a permanent exception with message Cannot submit message. 16.55847:260F0000, 17.43559:0000000004020000000000000100000000000000, 20.52176:140FF0870800F01FCB030000, 20.50032:140FF0878317401080030400, 0.35180:D0030000, 255.23226:0A00A382, 255.27962:0A000000, 255.27962:0E000000, 255.31418:1F000130, 16.55847:88000000, 17.43559:00000000E0020000000000000200000000000000, 20.52176:140FF087080040108 SMTP code: 554 Additional SMTP info: 5.2.02019-07-05 16:00:59 CLIENT -> SERVER: QUIT
Es posible que me falte alguna configuración?
El servidor esta activo y funcionando.