How to encode mail subject in perl ?
Now I finally found something but it's still not working :
use MIME::Words qw/encode_mimewords/;
$recipientsubject = encode_mimewords('Votre fichier a bien été envoyé');
But the (bugged) result is :
Subject: Votre fichier a bien =?ISO-8859-1?Q?=E9t=E9?= =?ISO-8859-1?Q?envoy=E9?=
Which displays :
Votre fichier a bien étéenvoyé
(It eats some spaces)
Use Encode, it is a core module.
perl -Mutf8 -MEncode -E 'say encode("MIME-Header", "Votre fichier a bien été envoyé")'
… will output either one of:
=?UTF-8?Q?Votre=20fichier=20a=20bien=20?= =?UTF-8?Q?=C3=A9t=C3=A9=20envoy=C3=A9?=
=?UTF-8?B?Vm90cmUgZmljaGllciBhIGJpZW4gw6l0w6kgZW52b3nDqQ==?=
And decode with:
perl -C -MEncode -E 'say decode("MIME-Header", "=?UTF-8?Q?Votre=20fichier=20a=20bien=20?= =?UTF-8?Q?=C3=A9t=C3=A9=20envoy=C3=A9?=")'
perl -C -MEncode -E 'say decode("MIME-Header", "=?UTF-8?B?Vm90cmUgZmljaGllciBhIGJpZW4gw6l0w6kgZW52b3nDqQ==?=")'
Which will print:
Votre fichier a bien été envoyé
If you still have the same results, you should give more information on your Perl environment. The version is a good starter.