Stuart's Python Page

Python is a simple scripting language (an experienced programmer really can learn the core language in a couple of hours) but it provides both object oriented and functional programming features as well as being a useful tool for general purpose real-world programming projects. See http://www.python.org for more information about Python.

Automated Email File Despatch and Delivery

Here are three UNIX style command-line utilities (which run under both Linux and Window NT/4) designed to automate the dispatch and delivery of files via email:

mailextract - Extract MIME encoded attached files from mail message

mailfiles - Create and send mail message containing MIME encoded files

zcrypt - File encryption compression / decryption decompression

I wrote these utilities because I needed to automate sending multiple files via Email, my requirements were:

Use zcrypt to encrypt and compress files which can be sent using mailfiles. Use mailextract to extract the file from the mail message which is then decrypted and decompressed using the zcrypt -d option.

Under UNIX mail file extraction can be automated using procmail(1). Here's a hypothetical example /etc/procmailrc recipe that extracts, decrypts and decompresses files to /tmp/extract_file in messages to test.user with subject line test_extract:

# Test for mailextract.py, zcrypt.py.
# Lock (:test_extract) and wait till extract completed reporting
errors (w).
:0w:test_extract
*^TOtest.user
*^Subject: test_extract
| /usr/local/sbin/mailextract.py - \
| /usr/local/sbin/zcrypt.py -d 3rgh8s - /tmp/extract_file

You can execute the following command pipe to test the procmail recipe:

/usr/local/sbin/zcrypt.py 3rgh8s test_file \
| /usr/local/sbin/mailfiles.py -s test_extract sender test.user

Copying

Copyright (C) 2002 Stuart Rackham. Free use of Connect is granted under the terms of the GNU General Public License (GPL).