If you get a message like:
Warning: stream_socket_enable_crypto(): Peer certificate did not match expected
And you are using DreamHost take a look at the following DreamHost support article:
https://help.dreamhost.com/hc/en-us/articles/215306748-Certificate-domain-mismatch-error-when-connecting-to-a-DreamHost-mail-server