title: Python smtplib sending mail using docmd
body: <p>I currently have an smtplib client using sendmail. I need to trap the message id given to the sent message by the receiving server - and from what I've read <a href="https://stackoverflow.com/questions/3820603/how-to-get-server-reply-after-sending-a-mail-using-smtplib-smtp-sendmail">here</a> I need to use smtplib's <code>docmd</code> command. What I've worked out so far is fairly easy:</p>
  
  <pre><code>import smtplib
  svr = smtplib.SMTP("localhost",26)
  r = svr.docmd("ehlo", "me")
  r = svr.docmd("mail from:","me@home.com")
  r = svr.docmd("rcpt to:","you@work.com")
  r = svr.docmd("data","")
  </code></pre>
  
  <p>But now when I try to do <code>svr.docmd("send","Hello there")</code> it just hangs? Similarly, I assume I should do <code>r = svr.docmd("send",".")</code> to send the terminating "." character to send the mail, and get the server response (in theory including msg id!) as part of the returned tuple?</p>
  
  <p>Would really appreciate it if someone could point me at where I'm going wrong in these final steps?</p>
  
  <p>Or am I completely misunderstanding - is using docmd NOT the way to get the server response when the mail is sent? If I am wrong, what should I be doing instead?</p>