1

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

Ahmed SEDDIK
  • 149
  • 12
  • 1
    Have you tried following the troubleshooting steps at the link shown in your error message? It can't connect to the SMTP server on your localhost. Make sure the smtp server is running and that you're not running it on a non-default port. – aynber Aug 10 '20 at 16:02
  • Does this answer your question? [SMTP connect() failed PHPmailer - PHP](https://stackoverflow.com/questions/22927634/smtp-connect-failed-phpmailer-php) – kayes Ibna Qayum Aug 10 '20 at 17:19
  • I'm using Exchange adresse mail. How can i verify that my SMTP server is running on my localhost. I'm using it with docker containor – Ahmed SEDDIK Aug 11 '20 at 16:18

1 Answers1

0

Check this post SMTP connect() failed PHPmailer - PHP