markguinn/silverstripe-email-helpers

PHP 5.6 issue with PHPmailer

Opened this issue · 3 comments

Hello

Running this module on a PHP5.6 project, will give an error concerning certificates. The issue and the fix for it is decribed here:
https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting#php-56-certificate-verification-failure

I fixed it by adding the following to your initMailer() method:

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

It is of course better to get a real certificate, although in my case this was an alright solution.

Cheers

This would need to be configurable as I doubt it's a very common use case. As long as it was configurable I'd merge a PR though.

xini commented

I assume you are running the site on Windows? On Windows PHP comes without root certificates installed. You can solve this by adding the root certs to your curl.cainfo in php.ini, see http://snippets.webaware.com.au/howto/stop-turning-off-curlopt_ssl_verifypeer-and-fix-your-php-config/.

Its because in calss.phpmailer.php there is a variable $SMTPAutoTLS = true. The emailhelper class needs and option to make it false. I had the same issue after switching to 5.6