You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

OVH主机环境下PHPMailer连接Office365 SMTP失败求助

使用PHPMailer连接Office 365 SMTP时遭遇连接拒绝问题(OVH主机)

我正在使用PHPMailer从网站向指定地址发送邮件,以下是我的配置:

$mail = new PHPMailer();
    
$mail->CharSet = 'UTF-8';                                       // Format d'encodage à utiliser pour les caractères

$mail->SMTPDebug = 4;                                           // Valeur entre 0 (normal) et 4 (full debug). Attention : mettre cette valeur > 0 dévoule certains paramètres confidentiels !
    
$mail->isSMTP();
$mail->Host = 'smtp.office365.com';                             // Adresse IP ou DNS du serveur SMTP
$mail->Port = 587;                                              // Port TCP du serveur SMTP (port SMTP chez OVH : 465=avec_SSL et 587=sans_SSL/avec_tls)
$mail->SMTPAuth = TRUE;                                         // Utiliser l'authentification
    
$mail->SMTPSecure = 'TLS';  

$mail->Username   = 'email@xyz.x';                  
$mail->Password   = 'PWD';  

我已启用并强制开启了multifactor authentication(多因素认证),且创建了应用密码填入$mail->Password中,但仍出现如下错误:

2023-01-09 14:32:53 Connection: opening to smtp.office365.com:587, timeout=300, options=array()
2023-01-09 14:32:53 Connection failed. Error #2: stream_socket_client(): Unable to connect to smtp.office365.com:587 (Connection refused) [/home/vendor/phpmailer/phpmailer/src/SMTP.php line 388]
2023-01-09 14:32:53 SMTP ERROR: Failed to connect to server: Connection refused (111)
SMTP connect() failed. https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting

我的网站主机为OVH,尝试了谷歌上各类解决方案均无效,无论是否启用MFA都会出现相同错误,恳请有同类问题解决经验的用户提供可行方案,感谢!


内容的提问来源于stack exchange,提问作者Niss

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.05 09:05:31