title: Emailing with php using sockets
body: <p>I'm writing a SMTP class to send mails using sockets with PHP and almost have success. The problem is that is working randomly and sometimes it takes a lot to send the email.</p>
  
  <p>I noticed that once the "." is sent i should get the response that the email was sent but instead of that I'm getting the server is closing the transmission (the same message when i send the "QUIT" command) and then the message that the email was sent.</p>
  
  <p>So the messages are arriving mixed for some reason...but only with the last two commands: "." and "QUIT".</p>
  
  <p>Anyone can give me a hand?</p>
  
  <p>Uploaded Here: <a href="http://pastebin.com/9vweVpe7" rel="nofollow">http://pastebin.com/9vweVpe7</a></p>
  
  <p>PD: I know that i could use phpmailer or swift, but i want to do it by myself to learn.</p>