phpmailer交换服务器认证

Civ*_*ova 5 php exchange-server phpmailer

我的邮件发送代码:

    $mail = new PHPMailer(true);
    $mail->IsSMTP();

    try {
        $mail->Host = 192.168.205.19;
        $mail->Port = 25;
        $mail->SMTPDebug  = 2;
        $mail->SMTPSecure = "tls";
        $mail->SMTPAuth = true;
        $mail->Username = "mymailadress@mysite.com";
        $mail->Password = "mypassword";

        $mail->From = "mymailaddress@mysite.com";
        $mail->FromName = "My Mail Address";
        $mail->SetFrom("mymailaddress@mysite.cm", "My Mail Address");

        $mail->AddAddress('toaddress@mysite.com');

        $mail->Subject = "Test for subject";
        $mail->MsgHTML("Test my mail body");

        if ($mail->Send()) {
            $result = 1;
        } else {
            $result = "Error: " . $mail->ErrorInfo;
        }
    } catch (phpmailerException $e) {
        $result = $e->errorMessage();
    } catch (Exception $e) {
        $result = $e->getMessage();
    }

    return $result;
Run Code Online (Sandbox Code Playgroud)

结果?

SMTP -> FROM SERVER:220 evo.callpex.int Microsoft ESMTP MAIL Service ready at Tue, 27 Nov 2012 17:45:24 +0200 
SMTP -> ERROR: Password not accepted from server: 535 5.7.3 Authentication unsuccessful 
Run Code Online (Sandbox Code Playgroud)

我正在使用PHPMailer类发送邮件.和SMTP.我正在连接到Exchange邮件服务器.但我有这个错误.

为什么?

谢谢!

Siv*_*r J 1

可能您正在使用管理员凭据。不知道为什么,但即使我也无法使用具有管理员凭据的 PHPMailer 发送邮件(可能有一些适用于管理员详细信息的安全措施)。尝试提供任何其他用户凭据,它会起作用。它适用于我与其他用户凭据。

并且,在你的代码中

  $mail->From = "mymailaddress@mysite.com";
  $mail->FromName = "My Mail Address";
  $mail->SetFrom("mymailaddress@mysite.cm", "My Mail Address");
Run Code Online (Sandbox Code Playgroud)

$mail->SetFrom("mailid","name") 本身将设置 From 和 FromName 值。您无需再次设置。