I am trying to make a simple Python filter for postfix, to add in a 'Reply-to' header to certain messages.
What I've done so far is to take the email from stdin, and parse it into an email object like so:
raw = sys.stdin.readlines()
msg = email.message_from_string(''.join(raw))
Then I've played with headers etc.
msg.add_header('Reply-to', 'foo@bar.com')
And now want to re-inject that back into postfix. Reading the filter readme 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()'?
What would be the 'correct' method?
Thanks