[MlMt] How can I save the HTML part of an email so that I can open in a browser or text editor?

Bill Cole mmlist-20120120 at billmail.scconsult.com
Thu Mar 3 01:26:07 EST 2022


On 2022-03-01 at 21:20:51 UTC-0500 (Tue, 01 Mar 2022 20:20:51 -0600)
Quinn Comendant <mailmate at lists.freron.com>
is rumored to have said:

> Thanks for both of your suggestions:
>
>> Not direct save but you could change view to “Show HTML Source”, 
>> […]
>
> Bill's correct, that won't give me access to the raw HTML.
>
>> To get the HTML part of a multipart (or pure HTML) message, you need 
>> to use "Show Raw Message" […]
>
> That's what I've been doing, but it's not convenient because the raw 
> email part will be either base64 or quoted-printable encoded, which is 
> not easy to decode. Base64 is easy to decode, but it seems to be less 
> common. I'm not sure how to decode quoted-printable correctly.

A tiny Perl script I call 'decode-qp':

	#!/usr/bin/perl
	
	eval 'exec /usr/bin/perl  -S $0 ${1+"$@"}'
	    if 0; # not running under some shell

	use MIME::QuotedPrint qw(decode_qp);

	while (<>) {
	    print decode_qp($_);
	}

> The reason I want to extract HTML messages is to analyze them to 
> improve the spam filtering on the mail servers I manage, and it's 
> really useful to be able to access the html.

If you're friendly with Perl, there is a tool called mimeexplode in the 
examples collection distributed with the MIME::Tools package which 
explodes a MIME message into a directory tree containing its constituent 
parts.

-- 
Bill Cole
bill at scconsult.com or billcole at apache.org
(AKA @grumpybozo and many *@billmail.scconsult.com addresses)
Not Currently Available For Hire


More information about the mailmate mailing list