title: SMTP Telnet and PHP not getting any response from HELO
body: <p>Ok I'm having my first attempt at socket programming with php, something I've been meaning to do for a while but sped up by the fact our bounced e-mail tracking on an application we've done at work did not work, so now I've got to check a whole of e-mail addresses to make sure their valid.</p>
  
  <p>I've learnt how to use telnet through the command line to validate an e-mail address and to send an e-mail address, and i'm having not problem with that. Where I'm falling down is when I go to use the "HELO" command to communicate with the server.</p>
  
  <p>But I might be in complete the wrong area here as I don't even know if this has established a telnet connection, but the var dump at the end suggests there is a connection being made.</p>
  
  <p>The connection response is the same when I made a telnet connection the command line except for "n6si3992361paw.22" but I imagine that is some sort of unique identifier for each connection.</p>
  
  <pre><code>&lt;?php
  
  $target = "aspmx.l.google.com";
  $port = 25;
  $errno = "";
  $errstr = "";
  $timeout = 9;
  $newline = "\n\r";
  $logArray = array();
  
  $connect = fsockopen($target, $port, $errno, $errstr, $timeout);
  $smtpResponse = fgets($connect, 4096);
  if(empty($connect)) {
     $logArray["error"][] = "Failed to connect: $smtpResponse";
     var_dump($logArray);
     exit;
  } else {
     $logArray['connection'][] = "Connected to: $smtpResponse";
  }
  fputs($connect, "HELO" . $newLine);
  $smtpResponse = fgets($connect, 4096);
  $logArray['connection'][] = "$smtpResponse";
  var_dump($logArray);
  </code></pre>
  
  <p>result of $logArray:</p>
  
  <pre><code>array(1) { ["connection"]=&gt; array(2) { [0]=&gt; string(57) "Connected to: 220 mx.google.com ESMTP n6si3992361paw.22 " [1]=&gt; string(0) "" } }
  </code></pre>