Mail not sending with PHPMailer over SSL using SMTP

前端 未结 5 2169
失恋的感觉
失恋的感觉 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 16:56

    Firstly, use these settings for Google:

    $mail->IsSMTP();
    $mail->Host = "smtp.gmail.com";
    $mail->SMTPAuth = true;
    $mail->SMTPSecure = "tls"; //edited from tsl
    $mail->Username = "myEmail";
    $mail->Password = "myPassword";
    $mail->Port = "587";
    

    But also, what firewall have you got set up?

    If you're filtering out TCP ports 465/995, and maybe 587, you'll need to configure some exceptions or take them off your rules list.

    https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting

    0 讨论(0)
  • 2020-12-05 16:58
    $mail->IsSMTP();
    $mail->Host = "smtp.gmail.com";
    $mail->SMTPAuth = true;
    $mail->SMTPSecure = "ssl";
    $mail->Username = "myemail@gmail.com";
    $mail->Password = "**********";
    $mail->Port = "465";
    

    That is a working configuration.

    try to replace what you have

    0 讨论(0)
  • 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 
    
    0 讨论(0)
  • 2020-12-05 17:03

    I got a similar failure with SMTP whenever my client machine changes network connection (e.g., home vs. office network) and somehow restarting network service (or rebooting the machine) resolves the issue for me. Not sure if this would apply to your case, but just in case.

    sudo /etc/init.d/networking restart   # for ubuntu
    
    0 讨论(0)
  • 2020-12-05 17:03

    First, Google created the "use less secure accounts method" function:

    https://myaccount.google.com/security

    Then created the another permission:

    https://accounts.google.com/b/0/DisplayUnlockCaptcha

    Hope it helps.

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