提问人:MalcolmInTheCenter 提问时间:7/15/2023 更新时间:7/15/2023 访问量:185
PHPMailer:如何从Outlook电子邮件发送电子邮件?
PHPMailer: How can I send an email from an Outlook email?
问:
我正在使用 PHPMailer 通过我的 Outlook 电子邮件发送电子邮件,但我一直收到此错误
Message could not be sent. Mailer Error:
"The following From address failed: [email protected] :
MAIL FROM command failed,Client not authenticated to send mail. [
xxxxxx.namprd13.prod.outlook.com 2023-07-14T21:47:08.967Z 08DB842E797B0C23]\r\n,530,5.7.57SMTP server error: MAIL FROM command failed Detail: Client not authenticated to send mail.
[xxxx.namprd13.prod.outlook.com 2023-07-14T21:47:08.967Z 08DB842E797B0C23]\r\n SMTP code: 530 Additional SMTP info: 5.7.57SMTP server error:
MAIL FROM command failed Detail: Client not authenticated to send mail.
[xxxxxx.namprd13.prod.outlook.com 2023-07-14T21:47:08.967Z 08DB842E797B0C23]\r\n SMTP code: 530 Additional SMTP info: 5.7.57"
我正在使用沙盒 outlook 电子邮件,这可能是问题所在,但对此表示高度怀疑,因为我能够使用 ms-graph-sdk 发送消息
这是我的代码:
try {
//Server settings
$mail->SMTPDebug = SMTP::DEBUG_SERVER;
$mail->Host = 'smtp-mail.outlook.com'; //smtp.office365.com:587
$mail->Username = '[email protected]';
$mail->Password = 'xxxxxxxxxx';
$mail->SMTPSecure = PHPMailer::ENCRYPTION_STARTTLS;
$mail->Port = 587;
$mail->isSMTP();
//$mail->SMTPAuth = true;
//Recipients
$mail->setFrom('[email protected]', 'Mailer');
$mail->addAddress('[email protected]');
//Content
$mail->isHTML(true);
$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 (! $response = $mail->send()) {
Log::info('Message could not be sent.');
Log::info('Mailer Error: ' . json_encode($mail->ErrorInfo));
exit;
} else {
echo 'Message of Send email using Outlook SMTP server has been sent';
}
echo 'Message has been sent';
}
catch (Exception $e) {
Log::info("Message could not be sent. Mailer Error:" . json_encode($mail->ErrorInfo));
}
我尝试了这里提供的 3 种解决方案 https://stackoverflow.com/a/68312304/2609521 但它们不起作用。
1. 2.
3.
答: 暂无答案
评论