<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://rt-wiki.bestpractical.com/index.php?action=history&amp;feed=atom&amp;title=Html2mime</id>
	<title>Html2mime - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://rt-wiki.bestpractical.com/index.php?action=history&amp;feed=atom&amp;title=Html2mime"/>
	<link rel="alternate" type="text/html" href="https://rt-wiki.bestpractical.com/index.php?title=Html2mime&amp;action=history"/>
	<updated>2026-08-22T08:35:30Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.41.1</generator>
	<entry>
		<id>https://rt-wiki.bestpractical.com/index.php?title=Html2mime&amp;diff=1635&amp;oldid=prev</id>
		<title>Admin: 2 revisions imported</title>
		<link rel="alternate" type="text/html" href="https://rt-wiki.bestpractical.com/index.php?title=Html2mime&amp;diff=1635&amp;oldid=prev"/>
		<updated>2016-04-06T20:11:24Z</updated>

		<summary type="html">&lt;p&gt;2 revisions imported&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;= html2mime =&lt;br /&gt;
&lt;br /&gt;
Below are several means of solving the &amp;#039;This transaction appears to have no content&amp;#039; when users send pure HTML messages.&lt;br /&gt;
&lt;br /&gt;
== Procmail ==&lt;br /&gt;
&lt;br /&gt;
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 &amp;quot;html2text&amp;quot; utility that&amp;#039;s pretty widely available.&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;:0&lt;br /&gt;
 #Ignore messages&amp;amp;gt;599k&lt;br /&gt;
 * &amp;amp;lt;599000&lt;br /&gt;
 * ^Content-Type: text/html&lt;br /&gt;
 {&lt;br /&gt;
   :0 fbw&lt;br /&gt;
   | /usr/local/bin/html2text -nobs -style pretty -width 62&lt;br /&gt;
 &lt;br /&gt;
   :0 fbw&lt;br /&gt;
   | /usr/bin/sed &amp;#039;s/     /&amp;amp;gt;/g&amp;#039;&lt;br /&gt;
 &lt;br /&gt;
   :0 Afw&lt;br /&gt;
   | /usr/bin/sed &amp;#039;s/\(Content-Type: text\/\)html/\1plain/&amp;#039;&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 &amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
== Perl script ==&lt;br /&gt;
&lt;br /&gt;
=== v2 ===&lt;br /&gt;
&lt;br /&gt;
A script that provides a text part as multipart/alternative, unlike the other options here, and other optional functionality.&lt;br /&gt;
&lt;br /&gt;
http://pthbb.org/manual/software/mailfilter&lt;br /&gt;
&lt;br /&gt;
=== v1 ===&lt;br /&gt;
&lt;br /&gt;
 rt: &amp;quot;|/home/rt/bin/html2mime | /usr/local/rt3/bin/rt-mailgate --queue &amp;quot;General&amp;quot; --action correspond --url http://whatever/&amp;quot;&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
The script is so small that I put it directly here:&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;#!/usr/bin/perl&lt;br /&gt;
 # 1.0 - XXXX - original version&lt;br /&gt;
 &lt;br /&gt;
 use strict;&lt;br /&gt;
 use Mail::Field;&lt;br /&gt;
 use MIME::Parser;&lt;br /&gt;
 use MIME::Entity;&lt;br /&gt;
 use HTML::TreeBuilder;&lt;br /&gt;
 use HTML::FormatText;&lt;br /&gt;
 &lt;br /&gt;
 # because MIME silently writes local files&lt;br /&gt;
 chdir(&amp;quot;/tmp/&amp;quot;);&lt;br /&gt;
 &lt;br /&gt;
 my $parser = new MIME::Parser;&lt;br /&gt;
 my $entity = $parser-&amp;amp;gt;parse(\*STDIN) or die &amp;quot;parse failed\n&amp;quot;;&lt;br /&gt;
 &lt;br /&gt;
 # Parse only non-multipart text/html mime-type&lt;br /&gt;
 if ( ($entity-&amp;amp;gt;is_multipart) ||&lt;br /&gt;
      ($entity-&amp;amp;gt;mime_type ne &amp;quot;text/html&amp;quot;) ) {&lt;br /&gt;
        $entity-&amp;amp;gt;print(\*STDOUT);&lt;br /&gt;
        exit 0;&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 # Decode body&lt;br /&gt;
 my $bh = $entity-&amp;amp;gt;bodyhandle;&lt;br /&gt;
 &lt;br /&gt;
 my $tree = HTML::TreeBuilder-&amp;amp;gt;new();&lt;br /&gt;
 $tree-&amp;amp;gt;utf8_mode();&lt;br /&gt;
 $tree-&amp;amp;gt;parse($bh-&amp;amp;gt;as_string);&lt;br /&gt;
 &lt;br /&gt;
 my $formatter = HTML::FormatText-&amp;amp;gt;new(leftmargin =&amp;amp;gt; 0, rightmargin =&amp;amp;gt; 72);&lt;br /&gt;
 my $txt= $formatter-&amp;amp;gt;format($tree);&lt;br /&gt;
 &lt;br /&gt;
 my $txtEntity=MIME::Entity-&amp;amp;gt;build(Data  =&amp;amp;gt; $txt,&lt;br /&gt;
                                  Type  =&amp;amp;gt; &amp;quot;text/plain&amp;quot;,&lt;br /&gt;
                                  #Encoding =&amp;amp;gt; &amp;quot;quoted-printable&amp;quot;&lt;br /&gt;
                                  Encoding =&amp;amp;gt; &amp;quot;8bit&amp;quot;&lt;br /&gt;
                                );&lt;br /&gt;
 &lt;br /&gt;
 $entity-&amp;amp;gt;make_multipart;&lt;br /&gt;
 $entity-&amp;amp;gt;add_part($txtEntity,0);&lt;br /&gt;
 &lt;br /&gt;
 $entity-&amp;amp;gt;print(\*STDOUT);&lt;br /&gt;
 &amp;lt;/nowiki&amp;gt;&lt;/div&gt;</summary>
		<author><name>Admin</name></author>
	</entry>
</feed>