title: python - read email from postfix in python on linux
body: <p>I'm very new to postfix and python. I've setup postfix on Ubuntu and have configured the <code>main.cf</code> with <code>mailbox_command = /home/someuser/test.py</code></p>
  
  <p>test.py:</p>
  
  <pre><code>#!/usr/bin/python
  import sys, MySQLdb
  
  email_input = sys.stdin
  db = MySQLdb.connect(host="localhost",
                       user="user", 
                       passwd="password",
                       db="test")
  
  cur = db.cursor()
  
  sql = "insert into postfix (value) values (%s)"
  cur.execute(sql, (email_input,))
  db.commit()
  db.close()
  </code></pre>
  
  <p>I was expecting the content of the email to be inserted into the field but instead I ended up with <code>&lt;open file '&lt;stdin&gt;', mode 'r' at 0x7f018b3b40c0&gt;</code></p>
  
  <p>How do I get the raw email string from what seems to be that memory address?</p>