【问题标题】:PHPMailer is giving me the following errorPHPMailer 给我以下错误
【发布时间】:2017-03-12 16:49:10
【问题描述】:

我正在使用 PHPMailer,当我尝试运行以下 PHP 时,我收到了以下错误消息:

无法发送邮件。邮件程序错误:SMTP 错误:数据未接受。SMTP 服务器错误:DATA END 命令失败详细信息:5.7.60 SMTP;客户端无权作为此发件人发送 SMTP 代码:550

php代码:

<?php

require 'phpmailer/PHPMailerAutoload.php';

$mail = new PHPMailer;

//$mail->SMTPDebug = 3;                               // Enable verbose debug output

$mail->isSMTP();                                      // Set mailer to use SMTP
$mail->Host = 'outlook.office365.com';  // Specify main and backup SMTP servers
$mail->SMTPAuth = true;                               // Enable SMTP authentication
$mail->Username = 'info@domain.com';                 // SMTP username
$mail->Password = '*password*';                           // SMTP password
$mail->SMTPSecure = 'tls';                            // Enable TLS encryption, `ssl` also accepted
$mail->Port = 587;                                    // TCP port to connect to

$mail->setFrom('from@example.com', 'Mailer');
$mail->addAddress('joe@example.net', 'Joe User');     // Add a recipient
$mail->addAddress('ellen@example.com');               // Name is optional
$mail->addReplyTo('info@example.com', 'Information');
// $mail->addCC('cc@example.com');
// $mail->addBCC('bcc@example.com');

$mail->isHTML(true);                                  // Set email format to HTML

$mail->Subject = 'Here is the subject';
$mail->Body    = 'This is the HTML message body <b>in bold!</b>';
$mail->AltBody = 'This is the body in plain text for non-HTML mail clients';

if(!$mail->send()) {
    echo 'Message could not be sent.';
    echo 'Mailer Error: ' . $mail->ErrorInfo;
} else {
    echo 'Message has been sent';
}


?>

【问题讨论】:

  • 我猜from@example.com 不是您 Office365 帐户上的有效帐户
  • @RiggsFolly 我刚刚更改了它,但它仍然无法正常工作。任何其他想法。我需要更改其他文件中的内容吗?
  • 你可以试试smtp.office365.com作为你的HOST,outlook.office365.com是POP3的url
  • @Binary111 你必须得到你的 gmail 帐户,然后设置,然后你必须确保不太安全的应用程序权限是可以的。

标签: php email office365 phpmailer


【解决方案1】:

我不确定当它说“客户端无权作为此发件人发送”时是否会更清楚。它的意思正是它所说的。

您使用from@example.com 的发件人地址(默认情况下也用作信封发件人;请参阅Sender 属性)发送,Outlook 不愿意让您使用该地址。您可能会被限制使用也是您的用户名的地址。 Gmail 也有类似的限制。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2016-08-23
    • 2021-01-24
    • 2013-03-30
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2010-09-24
    • 2023-03-30
    相关资源
    最近更新 更多