1. cliveportman
  2. /code
  3. /fix-for-stream-socket-enable-crypto-error-when-using-craft-cms-and-sendgrid

Fix for stream_socket_enable_crypto() error when using Craft CMS and SendGrid

Using Craft CMS with a third-party email service called SendGrid to improve email reliability and the sites I've put on recent servers have been returning the following error: 

stream_socket_enable_crypto(): Peer certificate CN=`server1.theportman.co' did not match expected CN=`smtp.sendgrid.net'

I wanted to avoid hacking PHPMailer within Craft CMS, as recommended here and after a lot of experimentation found changing to port 2525 did the trick.