User Tools

Site Tools


doc:appunti:linux:sa:sieve_filtering_tnef

This is an old revision of the document!


Filtering TNEF (winmail.dat) attachments with Sieve

Microsoft Outlook uses the proprietary TNEF format to send attachments. With non-Microsoft email clients you will see the infamous winmail.dat attachment, which generally remains as a black box that you cannot open.

Here I explain a recipe to filter such mails at Local Delivery Agent stage, i. e. the mail is filtered before it arrives into the user mailbox, the MIME part of type Application/MS-TNEF is parsed and every file contained herein, is attached again as a standard MIME part.

The original TNEF attachment is retained, so the size of the email is roughly doubled.

The Sieve filter

require ["fileinto", "vnd.dovecot.filter", "mime", "foreverypart"];

# Filter with /usr/local/lib/dovecot/sieve-filter/tnef-filter.sh
# if there is an attachment of type Application/MS-TNEF (e.g. winmail.dat).
foreverypart
{
    if header :mime :anychild :contenttype "Content-Type" "application/ms-tnef"
    {
        filter "tnef-filter.sh";
    }
}

You need to include the mime and foreverypart plugins. I create the shell script tnef-filter.sh into the /usr/local/lib/dovecot/sieve-filter/ directry, because that directory is the one declared to contains filters.

doc/appunti/linux/sa/sieve_filtering_tnef.1621852624.txt.gz · Last modified: 2021/05/24 12:37 by niccolo