subjectlines = []
for num in data[0].split():
    typ, msgdata = sess.fetch(num,
        '(RFC822.SIZE BODY[HEADER.FIELDS (SUBJECT)])')
subject = msgdata[0][1].lstrip('Subject: ').strip()
subjectlines.append(subject)
Integrate postfix mail into my (python)webapp