markguinn / silverstripe-email-helpers

Silverstripe extension containing SMTP mailer class and some other classes for HTML emails
31 stars 22 forks source link

PHP 5.6 issue with PHPmailer #7

Open sanderha opened 8 years ago

sanderha commented 8 years ago

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

markguinn commented 8 years ago

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 8 years ago

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/.

tazzydemon commented 6 years ago

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