SMTP ERROR: Failed to connect to server: Connection timed out

SMTP ERROR: Failed to connect to server: Connection timed out

I'm using PHPMailer, my website is hosted in a DigitalOcean server and I already requested them to remove, this is their response:

Thanks for providing that extra bit of information. I have enabled mail-related IPv4 traffic for your account. 

But when I try to send e-mail, it keeps showing me this error:

2015-10-14 16:04:49 Connection: opening to ssl://smtp.zoho.com:465, timeout=300, options=array ( ) 2015-10-14 16:05:52 SMTP ERROR: Failed to connect to server: Connection timed out (110) 2015-10-14 16:05:52 SMTP connect() failed. https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting Message could not be sent.Mailer Error: SMTP connect() failed. https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting

This is my PHP code:

  1. public static function sendEmail($email,$title,$body){
  2. require_once __DIR__ . "/../library/PHPMailer/PHPMailerAutoload.php";

  3. $mail = new PHPMailer;

  4. $mail->SMTPDebug = 3;

  5. $mail->isSMTP();
  6. $mail->Host = 'smtp.zoho.com';
  7. $mail->SMTPAuth = true;
  8. $mail->Username = 'acimar@agiliza.me';
  9. $mail->Password = 'mypassword';
  10. $mail->SMTPSecure = 'ssl';
  11. $mail->Port = 465;

  12. $mail->setFrom('acimar@agiliza.me', 'Agiliza.me');
  13. $mail->addAddress($email);
  14. //$mail->addReplyTo('info@example.com', 'Information');
  15. $mail->isHTML(true);
  16. $mail->CharSet = "UTF-8";

  17. $mail->Subject = 'Here is the subject';
  18. $mail->Body    = $body;

  19. if(!$mail->send()) {
  20. echo 'Message could not be sent.';
  21. echo 'Mailer Error: ' . $mail->ErrorInfo;
  22. } else {
  23. echo 'Message has been sent';
  24. }
  25. }