Notice: This tutorial presents advanced topics. Prerequisite knowledge of server configuration, how to work with scripts, and file permissions is assumed. The examples presented here are presented with NO WARRANTY and without direct support. USE AT YOUR OWN RISK. For further assistance you may visit the Community Forums.
Date: 22 Oct 2002 05:10:39 -0000 Message-ID: <20021022175100@example.com> From: user@example.com Subject: Sales question
This is the message body. This is the second line. This is the last line.
#!/usr/local/bin/perl # name of file where text for footer # tag is stored $filename = "tag.txt";
# read the original email message from # STDIN one line at a time and # print each line to STDOUT while (<STDIN>) { print; }
# open the file with the contents # for the tag open(TAGFILE, "<$filename");
# read in the contents of the tag # file a line at a time and # print each line to STDOUT while (<TAGFILE>) { print; } close(TAGFILE);
-- Here is my footer tag.Ta-da!
#!/usr/bin/python import sys, os # open the file to which data will be written outfile = open("./outmessage.txt", "a") while 1: # read in the message 1000 bytes at a time message_data = sys.stdin.read(1000) # if no data to read, exit loop if not message_data: break # if data, write it to the file outfile.write(message_data) outfile.close()