Настройка PHP Mailer и Office 365 - PullRequest
0 голосов
/ 08 марта 2019

Моя компания перешла с адреса электронной почты локального веб-сервера на офис 365, и теперь электронные письма не принимаются. Я пытаюсь эту конфигурацию, но не работает

$mailer = new PHPMailer();
    $mailer->IsSMTP();
    $mailer->SMTPDebug = 3;
    $mailer->Port = 587; 
    $mailer->Host = 'smtp.office365.com';
    $mailer->SMTPAuth = true; 
    $mailer->Username = "xxxxxx";
    $mailer->Password = "xxxxxx";
    $mailer->SMTPOptions = array(
        'ssl' => array(
            'verify_peer' => false,
            'verify_peer_name' => false,
            'allow_self_signed' => true
        )
    );
    $mailer->FromName = 'Bart S. Locaweb'; 
    $mailer->From = 'remetente@email.com.br'; 
    $mailer->AddAddress('destinatario@email.com','Nome do  destinatário');
    $mailer->Subject = 'Teste enviado através do PHP Mailer SMTPLW';
    $mailer->Body = 'Este é um teste realizado com o PHP Mailer SMTPLW';
    if(!$mailer->Send())
    {
        echo "Message was not sent";
        echo "Mailer Error: " . $mailer->ErrorInfo; exit; }
    print "E-mail enviado!";
        }

Я прочитал несколько вещей, связанных с этой темой, и первое, что нужно сделать, это проверить, есть ли у меня соединение с сервером Office 365 ... и у меня есть

Testing smtp.gmail.com:587: successfull connected
Testing smtp.gmail.com:465: ERROR: 101 - Network is unreachable
Testing smtp.office365.com:587: successfull connected

Так что я не понимаю, почему я получаю это уведомление

SMTP ERROR: Password command failed: 535 Incorrect authentication data
SMTP Error: Could not authenticate.
CLIENT -> SERVER: QUIT
SERVER -> CLIENT: 221 loge.dnsloge.com closing connection
Connection: closed
SMTP connect() failed. https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting
Message was not sentMailer Error: SMTP connect() failed. https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting

и пользователь и пароль верны .... любая помощь?

...