Email Error

Email Error

Sir
I am able to connect to outlook very easily but not able to connect with php only.


  1. $mail=new PHPMailer();
  2. $mail->isSMTP();
  3. $mail->Host='smtp.zoho.com';
  4. $mail->SMTPAuth=true;
  5. $mail->Username='help@odekh.com';
  6. $mail->Password='password';
  7. $mail->SMTPSecure='tls';
  8. $mail->SMTPDebug=3;
  9. $mail->Port=587;
  10. $mail->From='help@odekh.com';
  11. $mail->FromName='Help Help';
  12. $mail->addAddress('anyaddress@gmail.com');
  13. $mail->Subject='Testing';
  14. $mail->Body='Testing body';
  15. if($mail->send()){
  16. var_dump('mail is sent');
  17. }
Please help me as the error is: 

2017-07-21 18:15:52 Connection: opening to smtp.zoho.com:587, timeout=300, options=array ( ) 2017-07-21 18:15:53 Connection failed. Error #2: stream_socket_client(): unable to connect to smtp.zoho.com:587 (Connection refused) [/home/rshbhchauhan/vendor/phpmailer/class.smtp.php line 294] 2017-07-21 18:15:53 SMTP ERROR: Failed to connect to server: Connection refused (111) 2017-07-21 18:15:53 SMTP connect() failed. https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting