Schwerwiegender PHP-Fehler: Nicht abgefangener PHPMailer\PHPMailer\Exception: SMTP-Fehler: Verbindung zum SMTP-Host konnte nicht hergestellt werden
P粉128563140
P粉128563140 2023-08-31 10:04:24
0
1
474

Ich habe versucht, die Funktion „Passwort vergessen“ in PHPMailer zu verwenden und habe diese Fehlermeldung erhalten:

[12.05.2023 17:53:32 UTC] Schwerwiegender PHP-Fehler: PHPMailerPHPMailerException nicht erfasst: SMTP-Fehler: Verbindung zum SMTP-Host in /home konnte nicht hergestellt werden /raso1970/cliquedigitalepdo.com4muz.com/vendor/phpmailer/phpmailer/src/PHPMailer.php:2233 Stacktrace: #0 /home/raso1970/cliquedigitalepdo.com4muz.com/vendor/phpmailer/phpmailer/src/PHPMailer.php(2019): PHPMailerPHPMailerPHPMailer->smtpConnect() #1 /home/raso1970/cliquedigitalepdo.com4muz.com/vendor/phpmailer/phpmailer/src/PHPMailer.php(1678): PHPMailerPHPMailerPHPMailer->smtpSend() #2 /home/raso1970/cliquedigitalepdo.com4muz.com/vendor/phpmailer/phpmailer/src/PHPMailer.php(1516): PHPMailerPHPMailerPHPMailer->postSend() #3 /home/raso1970/cliquedigitalepdo.com4muz.com/forgot.php(75): PHPMailerPHPMailerPHPMailer->send() #4 {Haupt} eingeworfen in /home/raso1970/cliquedigitalepdo.com4muz.com/vendor/phpmailer/phpmailer/src/PHPMailer.php in Zeile 2233

Das ist mein Code in Forget.php:

   prepare("UPDATE Benutzer SET token = :token WHERE user_email = :email")) { $stmt->bindValue(':token', $token); $stmt->bindValue(':email', $email); $stmt->execute([ 'token' => $token, 'email' => $E-Mail ]); // $stmt->close(); /*** * * Konfigurieren Sie PHPMailer * **/ $mail = neuer PHPMailer(true); $mail->isSMTP(); $mail->Host = Config::SMTP_HOST; $mail->Username = Config::SMTP_USER; $mail->Password = Config::SMTP_PASSWORD; $mail->Port = Config::SMTP_PORT; $mail->SMTPSecure = 'PHPMailer::ENCRYPTION_SMTPS'; $mail->SMTPAuth = 'ssl'; $mail->isHTML(true); $mail->CharSet = 'UTF-8'; $mail->setFrom('contact@com4muz.com'); $mail->addAddress('contact@com4muz.com'); $mail->Subject = 'Veuillez réinitialiser votre mot de passe'; $mail->Body = '

Klicken Sie auf die Schaltfläche, um Ihr Passwort neu zu initialisieren https://cliquedigitalepdo.com4muz.com/reset.php?email='.$email.'&token='.$token.'

'; if($mail->send()) { $emailSent = true; } anders { echo „NICHT GESENDET“; } } } } }?>
Ich habe versucht, diese beiden Zeilen auszukommentieren:

use PHPMailerPHPMailerSMTP; verwenden Sie PHPMailerPHPMailerException;

Es scheint keine Verbindung zu SMTP möglich zu sein, aber ich verwende dieselbe SMTP-Konfiguration, um E-Mails von contact.php zu senden, und es funktioniert.

PS: Es ist erwähnenswert, dass ich lokal denselben Code verwende und es funktioniert. Daher besteht das Problem nur online.

Ich verwende die gleiche PHP-Version 8.2 sowohl für lokale als auch für Online-Anwendungen.

P粉128563140
P粉128563140

Antworte allen (1)
P粉094351878

我已经整理好了。 实际上,forgot.php第 60 行有一个拼写错误。

出于某种原因,我写了单引号。 所以,我替换了这个:

$mail->SMTPSecure = 'PHPMailer::ENCRYPTION_SMTPS';

通过这个:

$mail->SMTPSecure = PHPMailer::ENCRYPTION_SMTPS;

现在,它可以工作了,我可以发送电子邮件来重置密码。

    Neueste Downloads
    Mehr>
    Web-Effekte
    Quellcode der Website
    Website-Materialien
    Frontend-Vorlage
    Über uns Haftungsausschluss Sitemap
    Chinesische PHP-Website:Online-PHP-Schulung für das Gemeinwohl,Helfen Sie PHP-Lernenden, sich schnell weiterzuentwickeln!