问题
My mail send code:
$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;
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
I'm using PHPMailer class for sent mail. And SMTP. I'm connecting to Exchange Mail server. But I have this error.
Why?
Thanks!
回答1:
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.
And, In your code
$mail->From = "mymailaddress@mysite.com";
$mail->FromName = "My Mail Address";
$mail->SetFrom("mymailaddress@mysite.cm", "My Mail Address");
$mail->SetFrom("mailid","name") itself will set From & FromName values. You no need to set that again.
来源:https://stackoverflow.com/questions/13587983/phpmailer-exchange-server-authentication