piping an email message

Alessio Pace puccio_13 at yahoo.it
Fri May 16 13:08:09 EDT 2003


Hi, I am writing a filter for the emails, I need it to pass through stdin
and then go via stdout.

Would this piece of code be okay to let just pass the message through the
pipe correctly?

# file 'pipe.py'
import email
import sys

def main():
    stdin_message = sys.stdin.read()
    msg = email.message_from_string(stdin_message)
    sys.stdout.write(str(msg))  

if __name__ == '__main__':
    main()

I would like it to work on Unix and non Unix machines.
Does someone have a better approach to suggest?
Thanks for the help as usual.

-- 
bye
Alessio Pace




More information about the Python-list mailing list