title: Python filter for postfix
body: <p>I am trying to make a simple Python filter for postfix, to add in a 'Reply-to' header to certain messages.</p>
  
  <p>What I've done so far is to take the email from stdin, and parse it into an email object like so:</p>
  
  <pre><code>raw = sys.stdin.readlines()
  msg = email.message_from_string(''.join(raw))
  </code></pre>
  
  <p>Then I've played with headers etc.</p>
  
  <pre><code>msg.add_header('Reply-to', 'foo@bar.com')
  </code></pre>
  
  <p>And now want to re-inject that back into postfix. Reading the <a href="http://www.postfix.org/FILTER_README.html" rel="nofollow">filter readme</a> associated with postfix, I should pass it back using the 'sendmail' command. However, I'm not sure how to pass the email object over to sendmail, for example using subprocess's 'call()' or whether I should use the smtplib's 'smtplib.SMTP()'?</p>
  
  <p>What would be the 'correct' method?</p>
  
  <p>Thanks</p>