Sending emails through SMTP with PHPMailer

前端 未结 8 919
情深已故
情深已故 2020-12-31 07:13

I\'m trying to send SMTP e-mails using PHPMailer, but I keep getting this error message, any ideas how to get rid of it?
I\'m trying to connect via SSL on port 465.

8条回答
  •  一生所求
    2020-12-31 07:42

    As far as I can see everything is right with your code. Your error is:

    SMTP Error: Could not authenticate.

    Which means that the credentials you've sending are rejected by the SMTP server. Make sure the host, port, username and password are good.

    If you want to use STARTTLS, try adding:

    $mail->SMTPSecure = 'tls';
    

    If you want to use SMTPS (SSL), try adding:

    $mail->SMTPSecure = 'ssl';
    

    Keep in mind that:

    • Some SMTP servers can forbid connections from "outsiders".
    • Some SMTP servers don't support SSL (or TLS) connections.

    Maybe this example can help (GMail secure SMTP).

    [Source]

提交回复
热议问题