Request Tracker Wiki


863pages on
this wiki

html2mime Edit

Below are several means of solving the 'This transaction appears to have no content' when users send pure HTML messages.

Procmail Edit

The script at the bottom of the page offers what looks like a very nice solution - I wish it was available when I ran across this problem. Unfortunately I had to roll my own; the result of a bunch of tweaking after running on a production system is presented below, for those interested in an alternative solution. Also uses procmail, along with "html2text" utility that's pretty widely available.

 #Ignore messages>599k
 * <599000
 * ^Content-Type: text/html
   :0 fbw
   | /usr/local/bin/html2text -nobs -style pretty -width 62
   :0 fbw
   | /usr/bin/sed 's/     />/g'
   :0 Afw
   | /usr/bin/sed 's/\(Content-Type: text\/\)html/\1plain/'

Perl script Edit

v2 Edit

A script that provides a text part as multipart/alternative, unlike the other options here, and other optional functionality.

v1 Edit

rt: "|/home/rt/bin/html2mime | /usr/local/rt3/bin/rt-mailgate --queue "General" --action correspond --url http://whatever/"

The script is so small that I put it directly here:

 # 1.0 - XXXX - original version
 use strict;
 use Mail::Field;
 use MIME::Parser;
 use MIME::Entity;
 use HTML::TreeBuilder;
 use HTML::FormatText;
 # because MIME silently writes local files
 my $parser = new MIME::Parser;
 my $entity = $parser->parse(\*STDIN) or die "parse failed\n";
 # Parse only non-multipart text/html mime-type
 if ( ($entity->is_multipart) ||
      ($entity->mime_type ne "text/html") ) {
        exit 0;
 # Decode body
 my $bh = $entity->bodyhandle;
 my $tree = HTML::TreeBuilder->new();
 my $formatter = HTML::FormatText->new(leftmargin => 0, rightmargin => 72);
 my $txt= $formatter->format($tree);
 my $txtEntity=MIME::Entity->build(Data  => $txt,
                                  Type  => "text/plain",
                                  #Encoding => "quoted-printable"
                                  Encoding => "8bit"

Around Wikia's network

Random Wiki