使用phpmailer和microsoft exchange发送邮件时遇到问题。
这是我的代码:
$mail = new PHPMailer();
$mail->isSMTP();
$mail->Host = 'mail.myhost.com';
$mail->SMTPDebug = 2;
$mail->Username = "myUsername";
$mail->Password = "myPassword";
$mail->From = "from@server.com";
$mail->AddAddress("some.address@gmail.com");
$mail->Subject = "Test";
$mail->Body = 'Test';
$mail->send();
我收到此消息:
2014-06-04 13:34:49 SERVER -> CLIENT: 220 SRV-******.***.local Microsoft ESMTP MAIL Service ready at Wed, 4 Jun 2014 15:38:20 +0200
2014-06-04 13:34:49 CLIENT -> SERVER: EHLO myhost.com
2014-06-04 13:34:49 SERVER -> CLIENT: 250-SRV-******.***.local Hello [87.254.99.10] 250-SIZE 99999744 250-PIPELINING 250-DSN 250-ENHANCEDSTATUSCODES 250-STARTTLS 250-X-ANONYMOUSTLS 250-AUTH 250-X-EXPS NTLM 250-8BITMIME 250-BINARYMIME 250-CHUNKING 250-XEXCH50 250 XSHADOW
2014-06-04 13:34:49 CLIENT -> SERVER: MAIL FROM:
2014-06-04 13:34:49 SERVER -> CLIENT: 250 2.1.0 Sender OK
2014-06-04 13:34:49 CLIENT -> SERVER: RCPT TO:
2014-06-04 13:34:54 SERVER -> CLIENT: 550 5.7.1 Unable to relay
2014-06-04 13:34:54 SMTP ERROR: RCPT TO command failed: 550 5.7.1 Unable to relay
2014-06-04 13:34:54 CLIENT -> SERVER: QUIT
2014-06-04 13:34:54 SERVER -> CLIENT: 221 2.0.0 Service closing transmission channel SMTP Error: The following recipients failed: some.address@gmail.com
我的“从”和“到”邮件地址丢失......
有人知道这是什么问题吗?
答案 0 :(得分:0)
首先,我建议您在
中设置 true$mail = new PHPMailer(true);
对于 from 字段,将其插入方括号之间,并更改 setFrom
中的参数$mail->setFrom = ("from@server.com");