简体   繁体   中英

PHPMailer don't send e-mail

I'm trying to send mail over PHPMailer. Since 10 days PHPMailer don't send e-mail and throw an exception:

{
    "code": "ERROR",
    "message": "SMTP connect() failed. https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting"
}

This is below my code: It was working

$mail = new PHPMailer(true);

        try {
            // Server settings
            $mail->isSMTP();
            $mail->Host       = 'localhost';
            $mail->SMTPAuth   = false;
            $mail->Port       = 25;
            // Recipients
            $mail->setFrom($this->mailAddress, $this->mailName);
            $mail->addAddress($email);
            // Content
            $mail->isHTML(true);
            $mail->Subject = 'Réinitialisation du mot de passe';
            $mail->CharSet = 'UTF-8';
            $mail->Encoding = 'base64';
            $mail->Body    = 'test';
        } catch (Exception $e) {
            echo "Message could not be sent. Mailer Error: {$mail->ErrorInfo}";
        }

        return $mail->send();

I tried to upgrade PHPMailer to 6.1.7. I thought that PHPMailer had a security issues according to packagist .

Can someone help me to fix this error

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM