我正在尝试使用 PHP Pear 发送电子邮件。当我使用具有以下设置的 Gmail 发送电子邮件时,它可以工作:
$smtp = Mail::factory('smtp', array(
'host' => 'ssl://smtp.gmail.com',
'port' => '465',
'auth' => true,
'username' => 'username@gmail.com',
'password' => 'password!2016'
));
但在完成这项工作之前,我必须“允许不太安全的应用程序”访问我的帐户,您可以在此处阅读如何操作。
我尝试使用具有以下设置的 Outlook 帐户:
$smtp = Mail::factory('smtp', array(
'host' => 'tls://smtp.office365.com',
'port' => '587',
'auth' => true,
'username' => 'email@domain.org',
'password' => 'greatPasswordComesWithGreatResponsibilities'
));
但我收到此错误:
无法连接到 ssl://smtp.office365.com:587 [SMTP:无法连接套接字:fsockopen():无法连接到 ssl://smtp.office365.com:587(未知错误)(代码:- 1、回复:)]
我查看了微软关于他们的 SMTP 设置的官方文章。所以我认为我有正确的设置,但它不起作用。
我错过了什么吗?为什么我会收到此错误?在允许第三方应用程序发送电子邮件之前,我是否必须在我的 Outlook 帐户中配置一个设置,例如 Gmail?