Bonjour,

j'ai une page de contact qui envoie le message à une adresse GMAIL. J'utilise pour cela PHPMailer, mais lors de l'envoi, message d'erreur :
2025-09-13 14:56:54 SERVER -> CLIENT:
SMTP connect() failed. https://github.com/PHPMailer/PHPMail...roubleshooting
SMTP connect() failed. https://github.com/PHPMailer/PHPMail...roubleshooting
Mon code est le suivant :

Code php : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
public static function send(string $msg, string $subject): void
    { 
            $mail = new PHPMailer(); 
            $mail->isHTML(true);
            $mail->CharSet = "UTF-8";
 
            //$mail->SMTPDebug = SMTP::DEBUG_SERVER;                      //Enable verbose debug output
            $mail->isSMTP();                                            //Send using SMTP à enlever si en ligne
            $mail->Host       = 'smtp.gmail.com';                                    //Set the SMTP server to send through
            $mail->SMTPAuth   = true;                                   //Enable SMTP authentication
            $mail->Username   = 'une_adresse@gmail.com';                     //SMTP username
            $mail->Password   = 'xxxxx';                               //SMTP password
            $mail->SMTPSecure = PHPMailer::ENCRYPTION_STARTTLS;                                //Enable implicit TLS encryption
            $mail->Port       = 465;
            ///debug
            $mail->SMTPDebug = 2; // 0 = off, 1 = commandes, 2 = détails connexion
            $mail->Debugoutput = 'html';
            etc


chatGPT me parle de mot de passe application à générer dans mon compte GMAIL. C'est bon ? (Avant de me lancer, je demande confirmation)