PHPMailer - SSL3_GET_SERVER_CERTIFICATE:certificate verify failed

PHP 5.6 introduces SSL certificate verification, so if your config is broken, it will fail with this error. You should fix your SSL, but you can revert to the old behaviour by setting the SMTPOptions property to not verify certificates:

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

Editing the library defeats the entire point of libraries - and if you do as Kaf's answer suggests, your code will break when you upgrade. Really, don't do that.

Editor's note: disabling SSL verification has security implications. Without verification of the authenticity of SSL/HTTPS connections, a malicious attacker can impersonate a trusted endpoint (such as GitHub or some other remote Git host), and you'll be vulnerable to a Man-in-the-Middle Attack. Be sure you fully understand the security issues before using this as a solution.


I have the same problem. So i changed the file class.smtp.php in line 238:

public function connect($host, $port = null, $timeout = 30, $options = array()) {
       if (count($options) == 0) {
           $options['ssl'] = array('verify_peer' => false, 'verify_peer_name' => false, 'allow_self_signed' => true);
       }

now it works fine!

Editor's note: disabling SSL verification has security implications. Without verification of the authenticity of SSL/HTTPS connections, a malicious attacker can impersonate a trusted endpoint (such as GitHub or some other remote Git host), and you'll be vulnerable to a Man-in-the-Middle Attack. Be sure you fully understand the security issues before using this as a solution.


I had the same problem. It turned out that my Postfix config was missing the intermediates and root certificates setting:

smtpd_tls_CAfile=/etc/ssl/certs/intermediate-root-bundle.crt

Even though this Postfix config has worked for years with Outlook and Thunderbird, PHP was more picky and failed the SSL check.

So even though you might be tempted to hack PHPMailer, please don't, and fix the underlying problem.