php - 使用 phpmailer 发送邮件时如何修复 SMTP 错误
问题描述
我知道这个问题被问了很多次,但我仍然找不到解决这个问题的方法。
我正在尝试使用 PHP Mailer 从本地 MAMP 服务器发送邮件。
我已经检查了 PHP Mailer 的 wiki/troubleshooting 询问的所有内容并且一切正常,所以我不知道如何解决这个问题。
这是代码:
try {
$mail = new PHPmailer(true);
$mail->SetLanguage('fr');
$mail->IsSMTP();
$mail->IsHTML(true);
$mail->SMTPDebug=1;
$mail->SMTPAuth=true;
$mail->SMTPSecure='ssl';
$mail->Host= 'smtp-mail.outlook.com';
$mail->Port='587';
$mail->Username='******@hotmail.fr';
$mail->Password='******';
$mail->From='******@hotmail.fr';
$mail->AddAddress('******@hotmail.fr');
$mail->CharSet="utf-8";
$mail->Subject='Newsletter';
$mail->Body=$msg;
$mail->Send();
}
catch (Exception $e) {
echo $e->errorMessage();
}
作为错误消息,我得到的唯一响应是:
2019-07-08 12:38:55 SMTP 错误:无法连接到服务器:(0)Échec de la connexion SMTP。 https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting Échec de la connexion SMTP。 https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting
有人可以帮忙吗?
解决方案
推荐阅读
- python - Scrapy - LinkExtractor 和设置 DEPTH_LIMIT 不起作用?
- mysql - MySql 存储过程是原子的吗?
- r - 为数据框自动生成 roxygen2 文档的最佳方法是什么?
- python - Fabric2 中的 Sudo
- javascript - 在 Vuejs 中显示数据
- powershell - 如何使用已经存在的文件夹复制文件和文件夹?
- android - 无法从 admob 加载奖励视频
- javascript - Javascript - 使用包含逗号的数组更新管道分隔符
- html - 图像上的居中文本在使用 HTML 和 CSS 的网格上重叠
- android - Android API 24 及更低版本上的 PBKDF2WithHmacSHA256