【问题标题】:Godaddy - Office365 SMTP does not work?Godaddy - Office365 SMTP 不起作用?
【发布时间】:2018-01-26 03:30:02
【问题描述】:

我正在使用 PHPMailer 并尝试过其他方法,但这根本行不通。我不断收到服务器一直拒绝我访问的错误?这是使用的示例代码:

<?php
require 'PHPMailerAutoload.php';
$mail = new PHPMailer;
//$mail->SMTPDebug = 3;                               // Enable verbose debug output
$mail->isSMTP();                                      // Set mailer to use    SMTP
$mail->Host = 'smtp.office365.com';  // Specify main and backup SMTP servers
$mail->SMTPAuth = true;                               // Enable SMTP authentication
$mail->Username = 'xx@xx.com';                 // SMTP username
$mail->Password = 'xxx';                           // 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->addReplyTo('info@example.com', 'Information');
$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';
}

我使用的设置与官方文档中显示的相同:https://support.office.com/en-gb/article/POP-and-IMAP-settings-for-Outlook-Office-365-for-business-7fc677eb-2491-4cbc-8153-8e7113525f6c

似乎有什么问题?我在网上查了很多帖子,但似乎没有任何效果。有什么想法吗??

【问题讨论】:

标签: php email smtp office365


【解决方案1】:

在经济主机上 smtp 将无法工作,请按照下面列出的邮件驱动程序解决方案

    MAIL_DRIVER=mail
    MAIL_HOST=smtp.office365.com
    MAIL_PORT=587
    MAIL_USERNAME=office365_email
    MAIL_PASSWORD=office365_password
    MAIL_FORM=office365_email
    MAIL_ENCRYPTION=tls

邮件可能需要大约 2-5 分钟才能送达,但这是可行的解决方案。 谢谢

【讨论】:

    猜你喜欢
    • 2017-04-26
    • 2015-12-16
    • 2013-07-18
    • 1970-01-01
    • 2023-03-04
    • 2016-01-18
    • 2017-06-25
    • 2014-09-16
    • 2012-04-26
    相关资源
    最近更新 更多