Mail not sending with PHPMailer over SSL using SMTP

前端 未结 5 2196
失恋的感觉
失恋的感觉 2020-12-05 16:11

I am trying to use PHPMailer to send e-mails over SMTP but so far have had no luck. I\'ve gone through a number of SO questions, PHPMailer tutorials and forum posts but stil

5条回答
  •  旧巷少年郎
    2020-12-05 17:00

    Don't use SSL on port 465, it's been deprecated since 1998 and is only used by Microsoft products that didn't get the memo; use TLS on port 587 instead: So, the code below should work very well for you.

    mail->IsSMTP(); // telling the class to use SMTP
    $mail->Host       = "smtp.gmail.com"; // SMTP server
    
    $mail->SMTPAuth   = true;                  // enable SMTP authentication
    $mail->SMTPSecure = "tls";                 // sets the prefix to the servier
    $mail->Host       = "smtp.gmail.com";      // sets GMAIL as the SMTP server
    $mail->Port       = 587;                   // set the SMTP port for the 
    

提交回复
热议问题