mhearse has asked for the wisdom of the Perl Monks concerning the following question:

I'm trying to send an email, which is html with utf8 encoded text. The following method workds for all mail clients except Microsoft Outlook. In outlook, I get the usual garbage where French accents should be. Does anyone know what could be wrong?
use strict; use MIME::Lite; my $contents = <<EOT; Hello there! EOT my $msg = MIME::Lite->new( From => 'test@mydomain.com', To => 'test@yourdomain.com', Subject => 'Test Message', Type => 'text/html', Data => $contents, ); $msg->attr('content-type.charset' => 'UTF8'); $msg->send();

Replies are listed 'Best First'.
Re: Send utf8 encoded messages to MS Outlook
by almut (Canon) on May 05, 2008 at 23:49 UTC

    Have you also tried "UTF-8" (with a dash)?  Normally, applications are rather forgiving as to the spelling, but who knows... (Just a wild guess.)

      Wow! That worked. I should have expected as much from Outlook. Thanks for your post.
        uh? Outlook actually did it right. The encoding is called UTF-8, not UTF8.
Re: Send utf8 encoded messages to MS Outlook
by pc88mxer (Vicar) on May 05, 2008 at 23:26 UTC
    Update: Ok, I've read your question a little more carefully, and realize that you are only having problems with MS Outlook, so maybe this doesn't apply. Still, my recollection is that MIME::Lite is not what I call 'Unicode clean' - you need to pass it a byte string that contains the message encoded in the desired character set.

    Original response:

    I bet $content contain code-points and not a UTF8 byte stream. Try this:

    use Encode; my $msg = MIME::Lite->new( ... Data => encode('utf8', $contents), );
    My recollection is that MIME::Lite doesn't perform any character encoding of the message even when you specify the content-type.charset attribute.
      I bet $content contain code-points and not a UTF8 byte stream.

      But why would that work with all mail clients except Outlook, then?

      (Note: I hadn't seen your update before I posted...)