#!/usr/bin/python2 # copy and paste this script and # save as addheader.py import sys while 1: # read stdin one line at a time line = sys.stdin.readline() # if no more input, or end of headers # exit the loop if not line or line == '\n': break # if there is a non-blank line of input # write it to stdout sys.stdout.write(line) # print the custom header print 'X-comment: This is my custom header' # print a blank line to separate the headers # from the email message body, per RFCs print # for data past the end of the original # mail headers while 1: line = sys.stdin.readline() if not line: break sys.stdout.write(line)