I'm trying to see why my base64 email subject isn't decoding. I use this Perl code to create it:
use MIME::Base64;
use Encode;
$subject = "=?UTF-8?B?" . encode_base64(encode("utf8", $subject), "") . "?=";
Which gives me:
=?UTF-8?B?w63DsyBEZW1hbmRlIGRlIHJlc2VydmF0aW9uIGR1IHd3dy5jaGFtYnJlc2Rob3Rlcy5vcmcgLSBSZXNlcnZhdGlvbiByZXF1ZXN0IGZyb20gd3d3LmNoYW1icmVzZGhvdGVzLm9yZyBbI10=?=
If I copy and paste:
w63DsyBEZW1hbmRlIGRlIHJlc2VydmF0aW9uIGR1IHd3dy5jaGFtYnJlc2Rob3Rlcy5vcmcgLSBSZXNlcnZhdGlvbiByZXF1ZXN0IGZyb20gd3d3LmNoYW1icmVzZGhvdGVzLm9yZyBbI10=
...into this site to decode it:
http://www.webatic.com/run/convert/base64.php
..then it comes out fine!
The full email header looks like:
Subject: =?UTF-8?B?w63DsyBEZW1hbmRlIGRlIHJlc2VydmF0aW9uIGR1IHd3dy5jaGFtYnJlc2Rob3Rlcy5vcmcgLSBSZXNlcnZhdGlvbiByZXF1ZXN0IGZyb20gd3d3LmNoYW1icmVzZGhvdGVzLm9yZyBbI10=?=
This is how it comes out in my email client:
...and this is how I see it when converting it via an online tool:
UPDATE: This is actually how Email::MIME is creating the email:
From: "Andy chambresdhotes.org" <test@foo.org>
To: andynewby@bar.com
Subject: =?UTF-8?B?PT9VVEYtOD9CP3c2M0RzeUJFWlcxaGJtUmxJR1JsSUhKbGMyVnlk?=
=?UTF-8?B?bUYwYVc5dUlHUjFJSGQzZHk1amFHRnRZbkpsYzJSb2IzUmxjeTV2Y21jZ0xT?=
=?UTF-8?B?QlNaWE5sY25aaGRHbHZiaUJ5WlhGMVpYTjBJR1p5YjIwZ2QzZDNMbU5vWVcx?=
=?UTF-8?B?aWNtVnpaR2h2ZEdWekxtOXlaeUJiSTEwPT89?=
Date: Thu, 11 Jan 2018 14:46:05 +0000
MIME-Version: 1.0
Content-Type: multipart/alternative; boundary="15156819650.22DF651.1990"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline
The full Perl code I used to make the header, is:
my $email = Email::MIME->create(
header_str => [
From => $from,
To => [ $to ],
Subject => $subject,
],
parts => \@parts,
attributes => {
encoding => 'base64', # this was the trick
charset => "UTF-8",
content_type => "multipart/alternative",
disposition => "inline",
}
);