Wrong format of Subject with raw: =?utf-8 for NON ASCII characters

Indunil Jayasooriya indunil75 at gmail.com
Fri Jul 6 10:33:10 CEST 2018


Dear list,


I use below line in amavisd.conf file to get the Subject of the mail. It
shows MAIL FROM (with display name) as well.

$log_templ = $log_verbose_templ;

Some times, when I get mais with NON ASCII charactors, amavisd-new shows
subjects of the mails incorectly. this happens sometimes.(NOT always)

A few examples. Pls look at below 2 subjects

Subject: "Last Day To Enjoy Extra 15% OFF On Everything For NDB Credit
Cards (raw:
=?utf-8?Q?Last=20Day=20To=20Enjoy=20Extra=2015%=20OFF=20On=20Everything=20For=20NDB=20Credit=20Cards)

Subject: "Sing Along and Dance with Desmond De Silva at Pegasus Reef Hotel!
(raw:
=?utf-8?Q?Sing=20Along=20and=20Dance=20with=20Desmond=20De=20Silva=20at=20Pegasus=20Reef=20Hotel=21?)"

These above subects parts are NOT properly terminated.

they don't end with ?=


These are 2 Proper Subject having ?=

Subject: "Big Data & Data Driven Marketing (raw:
=?utf-8?Q?Big=20Data=20&=20Data=20Driven=20Marketing?=)"

Subject: "Room Rush \303\242\302\200\302\223 Enjoy 25% off on your stay.
(raw: Room Rush =?utf-8?b?4oCT?= Enjoy 25% off on your stay.)


So, I can't use "encode decode" in perl, when subject contains wrong raw:
=?utf-8

my amavisd version is amavisd-new-2.9.1-3.el6.noarch on CentOS 6.9 64 bit

Is there anyway to get it displayed properly?

looking for your answers.

Hope to hear from you.


here's my perl code.

#!/usr/bin/perl
use CGI ':standard';
use strict;
use warnings;
use CGI::Carp 'fatalsToBrowser'; # use only for testing
use Encode qw(encode decode);
no warnings 'utf8';

print "Content-Type: text/html; charset=utf-8\n\n";

#my $subject =
"\303\251\302\203\302\255\303\250\302\265\302\236\303\250\302\276\302\21120180804-20180828\303\244\302\274\302\221\303\245\302\201\302\207\303\247\302\224\302\263\303\250\302\257\302\267\303\250\302\241\302\250
(raw:
=?utf-8?B?6YOt6LWe6L6JMjAxODA4MDQtMjAxODA4MjjkvJHlgYfnlLPor7fooag=?=)";
my $subject = "Throwback to Choe Peng Sum & Michael Issenberg Interviews |
HOSI: A few days away... (raw:
=?utf-8?Q?Throwback=20to=20Choe=20Peng=20Sum=20&=20Michael=20Issenberg=20Interviews=20|=20HOSI=3A=20)";
#my $subject = "Room Rush \303\242\302\200\302\223 Enjoy 25% off on your
stay. (raw: Room Rush =?utf-8?b?4oCT?= Enjoy 25% off on your stay.)";

#$subject =~ s/[^[:ascii:]]+//g;  # get rid of non-ASCII characters

my $subject_decoded = decode("MIME-Header", $subject);
#my $subject_decoded = decode("MIME-B", $subject);
#my $subject_decoded = decode("MIME-Q", $subject);

print "\n";
print "<br/>";
print "subject: $subject \n\n";
print "<br/>";
print "subject_decoded: $subject_decoded \n\n";






-- 
cat /etc/motd

Thank you
Indunil Jayasooriya
http://www.theravadanet.net/
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.amavis.org/pipermail/amavis-users/attachments/20180706/496b6a46/attachment.html>


More information about the amavis-users mailing list