本文介绍了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 = "[email protected]";
        $mail->Password = "mypassword";

        $mail->From = "[email protected]";
        $mail->FromName = "My Mail Address";
        $mail->SetFrom("[email protected]", "My Mail Address");

        $mail->AddAddress('[email protected]');

        $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;

结果?

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

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

I'm using PHPMailer class for sent mail. And SMTP. I'm connecting to Exchange Mail server. But I have this error.

为什么?

谢谢!

推荐答案

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

May be you are using Administrator credentials. Don't know why but even I was not able to send mail using PHPMailer with admin credentials(There may be some security measures applicable for Administrator details). Try giving any other user credentials, it will work.It works for me with other user credentials.

然后,在您的代码中

  $mail->From = "[email protected]";
  $mail->FromName = "My Mail Address";
  $mail->SetFrom("[email protected]", "My Mail Address");

$ mail-> SetFrom("mailid","name")本身将设置为& FromName值.您无需再次设置.

$mail->SetFrom("mailid","name") itself will set From & FromName values. You no need to set that again.

这篇关于phpmailer交换服务器认证的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-01 20:09