title: SMTP ERROR: Failed to connect to server: With PHPMAILER in Dreamhost
body: <pre><code>I can not send mail using the PHPMailer lib. My site is hosted on dreamhost, 
  </code></pre>
  
  <p>with SMTP gmail I can send more properly to the configuration provided by the hosting  the only return is:
        SMTP ERROR: Failed to connect to server: php_network_getaddresses:                 getaddrinfo failed: Name or service not known (0)
        SMTP connect() failed.
      My code:</p>
  
  <pre><code>&lt;?php
  
  date_default_timezone_set('Etc/UTC');
  
  require 'vendor/phpmailer/phpmailer/PHPMailerAutoload.php';
  
  $mail = new PHPMailer;
  
  $name       = trim(stripslashes($_POST['name']));   
  $from       = trim(stripslashes($_POST['email']));
  $subject    = trim(stripslashes($_POST['subject']));
  $message    = trim(stripslashes($_POST['message']));
  
  $mail-&gt;isSMTP();
  $mail-&gt;SMTPDebug = 2;
  $mail-&gt;Host = 'mail.example.com.br';
  $mail-&gt;Port = 587;
  $mail-&gt;SMTPAuth = true;
  $mail-&gt;Username = 'e-mail@example.com';
  $mail-&gt;Password = 'password';
  $mail-&gt;SMTPSecure = 'tls';
  $mail-&gt;Debugoutput = 'html';
  
  $mail-&gt;isHTML(true);
  $mail-&gt;setFrom($from, $name);
  $mail-&gt;addReplyTo($from, $name);
  $mail-&gt;addAddress('email@example.com');
  $mail-&gt;Subject = $subject;
  $mail-&gt;Body = $message;
  
   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>`</p>