title: Error sending e-mail using Gmail SMTP
body: <p>I'm trying to send e-mail using Gmail SMTP and <code>PHPmailer</code>. </p>
  
  <p>The problem is that i have this Error:    </p>
  
  <pre><code>SMTP -&gt; ERROR: Failed to connect to server: php_network_getaddresses: getaddrinfo   failed: No such host is known. (0) 
  
  SMTP Error: Could not connect to SMTP host. Mailer Error: SMTP Error: Could not connect to SMTP host.
  </code></pre>
  
  <p>Here's the code I am using:</p>
  
  <pre><code>?php
  
      require_once($_SERVER['DOCUMENT_ROOT'].'/FreeUni/Kiosk/class.phpmailer.php');
  
      $mail  = new PHPMailer();   
      $mail-&gt;IsSMTP();
  
      //GMAIL config
      $mail-&gt;SMTPAuth   = true;                  // enable SMTP authentication
      $mail-&gt;SMTPSecure = "ssl";                 // sets the prefix to the server
      $mail-&gt;Host       = "ssl://smtp.gmail.com:465";      // sets GMAIL as the SMTP server
  
      $mail-&gt;Username   = "XXXX@gmail.com";  // GMAIL username
      $mail-&gt;Password   = "XXXXXX";            // GMAIL password
      $mail-&gt;SMTPDebug = 1;
      //End Gmail
  
      $mail-&gt;From       = "gvakh10@gmail.com";
      $mail-&gt;FromName   = "you name";
      $mail-&gt;Subject    = "some subject";
      $mail-&gt;MsgHTML("the message");
  
      //$mail-&gt;AddReplyTo("reply@email.com","reply name");//they answer here, optional
      $mail-&gt;AddAddress("XXXX@gmail.com","name to");
      $mail-&gt;IsHTML(true); // send as HTML
  
      if(!$mail-&gt;Send()) {//to see if we return a message or a value bolean
          echo "Mailer Error: " . $mail-&gt;ErrorInfo;
      } else  echo "Message sent!";
  
  ?&gt;
  </code></pre>
  
  <p>I've already searched the web but couldn't find the solution</p>