title: SMTP ERROR: Failed to connect to server: Permission denied (13)
body: <p>Good day!</p>
  
  <p>Im trying to make my phpmailer work in my shared hosting <code>(freehostia.com)</code> and I always get this error. The username and password of my gmail is correct, and the rest of the settings is like this:</p>
  
  <pre><code>$mail = new PHPMailer;
  
  $mail-&gt;isSMTP();
  $mail-&gt;SMTPDebug  = 2;
  $mail-&gt;Host       = 'tls://smtp.gmail.com'; // Specify main and backup SMTP servers
  $mail-&gt;SMTPAuth   = true; // Enable SMTP authentication
  $mail-&gt;Username   = 'mymail@gmail.com'; // SMTP username
  $mail-&gt;Password   = 'mypassword'; // SMTP password
  $mail-&gt;SMTPSecure = 'tls'; // Enable TLS encryption, `ssl` also accepted
  $mail-&gt;Port       = 587; // TCP port to connect to
  
  $mail-&gt;setFrom('mymail@gmail.com', 'ASAPHOT Administrator'); // Add a recipient
  $mail-&gt;addAddress('sorianorobertc@gmail.com'); // Name is optional
  $mail-&gt;addReplyTo('mymail@gmail.com', 'ASAPHOT Administrator');
  
  $mail-&gt;isHTML(true); // Set email format to HTML
  
  $mail-&gt;Subject = 'it works';
  $mail-&gt;Body    = 'it works';
  $mail-&gt;AltBody = 'This is the body in plain text for non-HTML mail clients';
  
  if (!$mail-&gt;send()) {
      echo 'Message could not be sent.';
      echo 'Mailer Error: ' . $mail-&gt;ErrorInfo;
  } else {
      echo 'Message has been sent';
  }
  </code></pre>
  
  <p>openssl is uncommented in the <code>php.ini</code> also. Am I missing something here? Thank you.</p>
  
  <p>Complete error message:</p>
  
  <pre><code>Connection: opening to smtp.gmail.com:587, timeout=300, options=array ()
  SMTP ERROR: Failed to connect to server: Permission denied (13)
  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
  </code></pre>