PHPMailer dont work with Self Signed SSL Certificate

I have a problem with PHPMailer, SMTP and my self signed SSL Certificate. I obtain the next message when i use PHPMailer:

SMTP Error: Could not connect to SMTP host. SMTP connect() failed.

To solve it, i found the SMTPOptions. If i add:

$mail->SMTPOptions = array(                                 
    'ssl' => array(
        'verify_peer' => false,
        'verify_peer_name' => false,
        'allow_self_signed' => true

My emails are sended, but i am losing the SSL security. In fact, if i try to send an gmail email address by this way, i receive the email in Spam Folder.

How can I solve this problem?


1 answer

  • answered 2021-07-27 12:47 Synchro

    Make sure you are clear about which certificate you are talking about. A certificate used for your web site has nothing to do with sending email. The certificate that matters is the one that is presented by the remote mail server that you connect to, not your web server.

    If you are connecting to gmail, they will not be providing a self-signed certificate. What is more likely is, as the troubleshooting guide describes in great detail, that your server's CA certificate bundle is outdated. Alternatively, if you do appear to be getting a self-signed cert, double-check that the domain matches too, in case your traffic is being redirected. The openssl tests in the guide should help you diagnose what the problem is. Disabling certificate verification is a very bad sign; you should aim to solve the cause of the problem, rather than hiding the symptom.

How many English words
do you know?
Test your English vocabulary size, and measure
how many words do you know
Online Test
Powered by Examplum