PHPMailer with GMail: SMTP Error

前端 未结 2 967
春和景丽
春和景丽 2020-12-11 21:13

I am making use of PHPMailer to send mail through GMail. The code I use is straight from a tutorial and it works perfectly on my laptop. However, testing this on a Windows 2

相关标签:
2条回答
  • 2020-12-11 21:46

    First thing notice off-hand: Gmail uses TLS. Don't know if having SSL instead of TLS will make much of a difference but SSL is the predecessor to TLS.

    I recommend checking out also, its phpmailer customized for using gmail. PHPGMailer

    0 讨论(0)
  • 2020-12-11 22:02

    To use PHPMailer with gmail, don't use SSL/465 (it's been deprecated since 1998), use TLS/587 as Noctrine suggests, and here's how:

    include 'phpmailer/class.phpmailer.php';
    $mail = new PHPMailer;
    $mail->IsSMTP();
    $mail->SMTPAuth = true; // enable SMTP authentication
    $mail->Host = "tls://smtp.gmail.com"; // GMAIL's SMTP server
    $mail->Port = 587; // SMTP port used by GMAIL server
    ...
    

    You should find that works.

    0 讨论(0)
提交回复
热议问题