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:

Subject: "Sing Along and Dance with Desmond De Silva at Pegasus Reef Hotel!

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:

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:

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.

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 =
my $subject = "Throwback to Choe Peng Sum & Michael Issenberg Interviews |
HOSI: A few days away... (raw:
#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
-------------- 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