title: Connection failed. Error #2: stream_socket_client(): php_network_getaddresses:getaddrinfo failed: The requested name is valid but no data
body: <p>Error message received:</p>
  
  <pre><code>Connection failed. Error #2: stream_socket_client(): php_network_getaddresses: getaddrinfo failed: The requested name is valid, but no data of the requested type was found
  </code></pre>
  
  <p>My code:</p>
  
  <pre><code>require_once("PHPMailer/PHPMailerAutoload.php");
  require_once("PHPMailer/class.phpmailer.php");
  require_once("PHPMailer/class.smtp.php");
  header('HTTP/1.1 420 Enhance Your Calm');
  $mail = new PHPMailer;
  
  $to = "x@gmail.com"
  $uname="rex";
  $body="Some valid Text /r/n some valid text";
  $mail-&gt;SMTPDebug = 3;    
  $mail-&gt;isSMTP();  
  $mail-&gt;Host =  'smtp.google.com'; 
  $mail-&gt;SMTPAuth = true; 
  $mail-&gt;Username = 'me@gmail.com'; 
  $mail-&gt;Password = '*******'; 
  $mail-&gt;SMTPSecure = 'ssl';
  $mail-&gt;Port = 465; 
  $mail-&gt;setFrom('me@gmail.com', 'username');
  $mail-&gt;addAddress($to, $uname); 
  $mail-&gt;isHTML(true); 
  $mail-&gt;Subject = 'Forgot Password';
  $mail-&gt;Body    = $body;
  if(!$mail-&gt;send()) {
    echo 'Message could not be sent.';
    echo 'Mailer Error: ' . $mail-&gt;ErrorInfo;
  } else {
    echo 'Message has been sent';
  }
  </code></pre>