On 06/11/2012 10:19, Gary Stainburn wrote:

I'm writing a mail filter which accepts emails from our 'fax-to-email' gateway
and I'm struggling to handle the input. I'm getting the following:

Subject
=?ISO-8859-1?B?UmVjZWl2ZWQgRnJ...

Before you make a decision, read this from the MIME::Words page
<http://search.cpan.org/~dskoll/MIME-tools-5.503/lib/MIME/Words.pm>

• For other implementations of this or similar functionality
• (particularly, ones with proper UTF8 support), see:
• Encode::MIME::Header, MIME::EncWords, MIME::AltWords
•
• At some future point, one of these implementations will likely
• replace MIME::Words and MIME::Words will become deprecated.

I’d recommend you use the Encode, which is included in the standard installation, is regularly updated and is extremely powerful. ISO... encoding is old hat you will receive more and more UTF-8 encoded headers.

#!/usr/bin/perl
use strict;
use Encode qw/encode decode/;
my $encoded_header = qq~Subject: =?ISO-8859-1?B?UmVjZWl2ZWQgRnJvbSAwMTEzMzk5NzM3MiAgMDYvMTEvMjAx?= =?ISO-8859-1?B?MiAxMDo0OA==?= From: =?ISO-8859-1?B?UmluZ3dheXMgRG9uY2FzdGVy?= =?ISO-8859-1?B?IEtpYSBTaG93cm9vbQ==?=~;
my $decoded_header = decode('MIME-Header', $encoded_header);
print $decoded_header;

#      Subject: Received From 01133997372  06/11/2012 10:48
#      From: Ringways Doncaster Kia Showroom

JD







--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to