title: SMTP with Auth doesnt work
body: <p>I am trying to send emails, with this PHP Script, but for some reason, I am not receiving the emails.</p>
  
  <pre><code>$to = my email;  
  $nameto = "Who To";
  $from = my second email;
  $namefrom = "Who From";  
  $subject = "Hello World Again!";
  $message = "World, Hello!";  
  authSendEmail($from, $namefrom, $to, $nameto, $subject, $message);  
  
  function authSendEmail($from, $namefrom, $to, $nameto, $subject, $message) {  
  $smtpServer = my smtp server  
  $port = "25";  
  $timeout = "30";  
  $username = my second email;
  $password = my password 
  $localhost = my smtp server
  $newLine = "\r\n";  
  
  $smtpConnect = fsockopen($smtpServer, $port, $errno, $errstr, $timeout);  
  $smtpResponse = fgets($smtpConnect, 515);  
  if(empty($smtpConnect))   
  {  
    $output = "Failed to connect: $smtpResponse";  
    return $output;  
  }  
  else 
  {  
    $logArray['connection'] = "Connected: $smtpResponse";  
  }  
  
  fputs($smtpConnect,"AUTH LOGIN" . $newLine);  
  $smtpResponse = fgets($smtpConnect, 515);  
  $logArray['authrequest'] = "$smtpResponse";  
  
  fputs($smtpConnect, base64_encode($username) . $newLine);  
  $smtpResponse = fgets($smtpConnect, 515);  
  $logArray['authusername'] = "$smtpResponse";  
  
  fputs($smtpConnect, base64_encode($password) . $newLine);  
  $smtpResponse = fgets($smtpConnect, 515);  
  $logArray['authpassword'] = "$smtpResponse";  
  
  //fputs($smtpConnect, "EHLO $localhost" . $newLine);  
  fputs($smtpConnect, "EHLO" . $newLine); 
  $smtpResponse = fgets($smtpConnect, 515);  
  $logArray['heloresponse'] = "$smtpResponse";  
  
  fputs($smtpConnect, "MAIL FROM: $from" . $newLine);  
  $smtpResponse = fgets($smtpConnect, 515);  
  $logArray['mailfromresponse'] = "$smtpResponse";  
  
  fputs($smtpConnect, "RCPT TO: $to" . $newLine);  
  $smtpResponse = fgets($smtpConnect, 515);  
  $logArray['mailtoresponse'] = "$smtpResponse";  
  
  fputs($smtpConnect, "DATA" . $newLine);  
  $smtpResponse = fgets($smtpConnect, 515);  
  $logArray['data1response'] = "$smtpResponse";  
  
  $headers = "MIME-Version: 1.0" . $newLine;  
  $headers .= "Content-type: text/html; charset=iso-8859-1" . $newLine;  
  $headers .= "To: $nameto &lt;$to&gt;" . $newLine;  
  $headers .= "From: $namefrom &lt;$from&gt;" . $newLine;  
  
  fputs($smtpConnect, "To: $to\nFrom: $from\nSubject: $subject\n$headers\n\n$message\n.\n");  
  $smtpResponse = fgets($smtpConnect, 515);  
  $logArray['data2response'] = "$smtpResponse";  
  
  fputs($smtpConnect,"QUIT" . $newLine);   
  $smtpResponse = fgets($smtpConnect, 515);  
  $logArray['quitresponse'] = "$smtpResponse";   
  </code></pre>
  
  <p>And i am getting this:</p>
  
  <pre>
  array(10) { 
      ["connection"]=> string(84) "Connected: 220-vm01.masterd.pt ESMTP Exim 4.84 #2 Thu, 13 Nov 2014 10:29:17 -0500 " 
      ["authrequest"]=> string(75) "220-We do not authorize the use of this system to transport unsolicited, " 
      ["authusername"]=> string(25) "220 and/or bulk e-mail. " 
      ["authpassword"]=> string(43) "503 AUTH command used when not advertised " 
      ["heloresponse"]=> string(26) "500 unrecognized command " 
      ["mailfromresponse"]=> string(26) "500 unrecognized command " 
      ["mailtoresponse"]=> string(43) "250-vm01.masterd.pt Hello [109.71.45.39] " 
      ["data1response"]=> string(19) "250-SIZE 52428800 " 
      ["data2response"]=> string(14) "250-8BITMIME " 
      ["quitresponse"]=> string(16) "250-PIPELINING " 
  }
  </pre>
  
  <p>But the email never come to my inbox!</p>