title: My php script is unable to send email on my vps (using PHPMailer)
body: <p>I've copied the script to my shared host provider and it worked. I also ran the script in my local computer and it also worked. Something that I think worthy mentioning is that the email server is from the shared host provider and my application is running on a vps (I changed only the dns records relating to connecting to my web site through a web browser).</p>
  
  <pre><code>use PHPMailer;
         $mail = new PHPMailer;
  
  
  
  $mail-&gt;isSMTP(); 
  $mail-&gt;SMTPAuth = true;  
  $mail-&gt;SMTPDebug = 1;  
  $mail-&gt;Host = 'smtp.uhsevico.com';
  $mail-&gt;SMTPAuth = true;
  $mail-&gt;Username = "adm@mydomain.com.br";
  $mail-&gt;Password = "mypassoword";
  //$mail-&gt;SMTPSecure = 'tls';  
  
  $mail-&gt;Port = 587;                                  
  
  $mail-&gt;setFrom('sender@mydomain.com.br', 'contato imotur');
  mail-&gt;addAddress('receiver@yahoo.com', 'Diego Alves');    
  
  
  $mail-&gt;Subject = 'Here is the subject';
  
  
  $mail-&gt;Body    = "ImoTur no contato das atividades";
  //$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>The Error:</p>
  
  <p>2017-02-21 18:30:03 SMTP ERROR: Failed to connect to server: Connection timed out (110) 2017-02-21 18:30:03 SMTP connect() failed. <a href="https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting" rel="nofollow noreferrer">https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting</a> Message could not be sent.Mailer Error: SMTP connect() failed. <a href="https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting" rel="nofollow noreferrer">https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting</a></p>