Home » Development » PHP 5.6 + phpMailer + WordPress + Connection Errors
Since version 5.6+ PHP is verifying peer certificates and host names by default when using SSL/TLS. This is causing problems on some servers / websites, where the config has not been setup correctly. If you can not fix the setup yourself, make sure to talk to your server host to fix that issue.
For PHPMailer (Github) there is a workaround:
This should only be a workaround until your configuration has been fixed. You are suppressing certificate verification and compromising your security!
As WordPress is using PHPMailer as its main email library, this can be tweaked by using the phpmailer_init hook:
Add this to your themes functions.php.
And here is how phpmailer->smtpOptions should be used, on a properly configured server:
SSL changes in PHP 5.6: http://php.net/manual/en/migration56.openssl.php SSL context options in PHP: http://php.net/manual/en/context.ssl.php
Enjoy coding…
You code is not correct, one “->” is to mutch :) $phpmailer->->SMTPOptions should be $phpmailer->SMTPOptions
Thanks Michael, has been fixed. Regards Alex
thanks a lot, finally a good and full explanation for WP!
Glad i could help :)
Alexander Gräf
Portfolio
Book Me
Get in touch
Live Chat
I am a full-stack developer. My expertise include:
I love programming, design and know my way around server architecture as well. I would never feel complete, with one of these missing.
I have a broad range of interests, that’s why I constantly dive into new technologies and expand my knowledge where ever required. Technologies are evolving fast and I enjoy using the latest.
Apart from that, I am a peace loving guy who tries to have people around him that think the same. I truly believe in the principle: “If you help someone, someone will help you, when you need it."