"Authentication unsuccessful" when connecting by smtp from office365 using PHPMailer

0

The problem is that I am not able to connect by Office 365 SMTP to send emails using PHP's PHPMailer library

require 'inc/phpmailer/PHPMailerAutoload.php';



$phpmailer = new PHPMailer();

//Datos del email
$phpmailer->Subject = 'Asunto...';
$phpmailer->addAddress('[email protected]');
$phpmailer->msgHTML('<h1>El mensaje...</h1>');

//Aqui configuramos el SMTP
$phpmailer->isSMTP();
$phpmailer->SMTPDebug = 2;
$phpmailer->Debugoutput = 'html';
$phpmailer->Host = "smtp.office365.com";
$phpmailer->Port = 587;
//$phpmailer->SMTPSecure = 'tls';
$phpmailer->SMTPAuth = true;
$phpmailer->Username = "[email protected]";
$phpmailer->Password = "xxxxxxxxx";

//Enviamos
$resp = $phpmailer->send();
var_dump($resp);

The answer that the server gives me is 535 5.7.3 Authentication unsuccessful. I do not know if I have the wrong configuration or is that you have to configure the account so that external applications can connect (With Gmail I know that you have to activate the option "Allow less secure applications", I do not know if with O365 there is some configuration of the style and that's why it fails)

    
asked by Juan Rodríguez 19.07.2017 в 15:01
source

0 answers