Filtering TNEF Email with TNEFclean and Maildrop

Transport Neutral Encapsulation Format (TNEF) is a Microsoft proprietary format used by Microsoft Outlook and Exchange Server. The format is easily read by people who use those products, the rest of us see the ever annoying winmail.dat which we can not open. This is where TNEFclean and Maildrop come in. Using these programs, you can have the winmail.dat opened and the contents put into a MIME format which is readable by all email clients.

TNEFclean is a Perl script which processes incoming email and cleans up the Microsoft Outlook generated TNEF attachments into a format that other (non-Microsoft) clients can read.

Maildrop is the mail filter/mail delivery agent used by the Courier Mail Server. maildrop reads a mail message from standard input and based on your filtering rules, performs the appropriate action on the message. The maildrop package allows you to perform server side mail filtering. This allows you to write your filters once rather than having to write them for each additional client. I use maildrop to sort my email, report my spam and forward email from my wife to all my accounts. Needless to say it has made my life very easy.


Installation of Maildrop and Multilog

The installation instructions for maildrop can be found here in the INSTALL file in the tarball.

The installation instructions for TNEFclean can be found here


Using TNEFclean with maildrop

The below example is a maildrop filter for a system running qmail and virtual domains with vpopmail.

SHELL="/bin/sh"
import EXT
import HOST
VPOP="="| /home/vpopmail/bin/vdelivermail '' bounce-no-mailbox"
VHOME=`/home/vpopmail/bin/vuserinfo -d $EXT@$HOST`
VDHOME=`dirname "$VHOME"`

`test -f $VDHOME/.qmail-$EXT`
if ( $RETURNCODE == 1 )
{
    EXITCODE=99
    to "$VPOP"
}
else
{
    xfilter "/usr/local/bin/tnefclean.pl -f"
    EXITCODE=99
    to "$VPOP"
}

The filter works as described below.

It is highly recommended before implementing the above filter that you familiarize yourself with the maildropfilter man page. The vpopmail man pages are located here. Lastly, TNEFClean must be run with the -f (filter) option so that it will return the email to STDOUT for further processing.