首页 > 解决方案 > 使用 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

有人可以帮忙吗?

标签: phphtml

解决方案


推荐阅读