SSL error when using phpMailer with smtp
I get the following error message when I'm trying to use phpMailer with Zoho mail:
2016-09-04 09:31:19 Connection: opening to ssl://smtp.zoho.com:587, timeout=300, options=array ( ) 2016-09-04 09:31:20 Connection: Failed to connect to server. Error number 2. "Error notice: stream_socket_client() [
function.stream-socket-client]: SSL operation failed with code 1. OpenSSL Error messages: error:140770FC:SSL routines:SSL23_GET_SERVER_HELLO:unknown protocol 2016-09-04 09:31:20 Connection: Failed to connect to server. Error number 2. "Error notice: stream_socket_client() [
function.stream-socket-client]: Failed to enable crypto 2016-09-04 09:31:20 Connection: Failed to connect to server. Error number 2. "Error notice: stream_socket_client() [
function.stream-socket-client]: unable to connect to ssl://smtp.zoho.com:587 (Unknown error) 2016-09-04 09:31:20 SMTP ERROR: Failed to connect to server: (0) 2016-09-04 09:31:20 SMTP connect() failed.
https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting
- $mail = new PHPMailer();
- $body = '---Test---';
- $mail->SMTPDebug = 3;
- $mail->IsSMTP();
- $mail->SMTPAuth = true;
- $mail->Host = "smtp.zoho.com";
- $mail->Port = 587;
- $mail->Username = 'example@zoho.com';
- $mail->Password = 'password';
- $mail->SMTPSecure = 'ssl';
- $mail->SetFrom('example@zoho.com', 'Web Page');
- $mail->Subject = "Hello";
- $mail->AltBody = '---Test---';
- $mail->MsgHTML($body);
- $mail->AddAddress('email');
- $mail->Send();
Any ideas what's wrong?