0

I was trying to configure PHP to use Gmail and he had the following problem

$mail = new PHPMailer(true);                           
    try { 
        $mail->CharSet = "UTF-8";                    
        $mail->SMTPDebug = 1;                       
        $mail->isSMTP();                              
        $mail->Host = 'smtp.gmail.com';
        $mail->SMTPAutoTLS = false;
        $mail->SMTPAuth = true;                    
        $mail->Username = 'xxxx';             
        $mail->Password = 'xxxx';         
        $mail->SMTPSecure = 'ssl';                            
        $mail->Port = 465;  

        $mail->setFrom('xxxx@gmail.com', 'Mailer');  //addresser
        $mail->addAddress($email, $username);  // recipients

        $mail->addReplyTo('xxxx@gmail.com', 'info'); 

        $mail->isHTML(true);                        
        $mail->Subject = 'Here's the subject of the email' . time();
        $mail->Body = '<h1>Here's the message</h1>' . date('Y-m-d H:i:s');
        $mail->AltBody = 'Displays this content if the mail client does not support HTML';

        $mail->send();
        echo 'send an e-mail success';
    } catch (Exception $e) {
        echo 'e-mail sending failed: ', $mail->ErrorInfo;
    }

SMTP connect() failed. https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting

Forever
  • 31
  • 3

0 Answers0