#!/usr/bin/perl -w # For correct results, use on a terminal expecting utf-8 use strict; use Email::MIME; sub new_part ($$) { my ($type, $body) = @_; my ($part) = Email::MIME->create( attributes => { content_type => $type, charset => 'utf-8', encoding => '8bit', }, body_str => $body, ); do { $part->header_set($_) } foreach qw/Date MIME-Version/; return $part; } # Normally, this would be actual utf-8 under "use utf8" my $text = "Not latin: \x{30ab}\x{30bf}\x{30ab}\x{30ca}"; my $html = "

$text

"; my $m = Email::MIME->create(header_str => [ To => 'a@example.com', From => 'b@example.com', Subject => 'Test', ], attributes => { content_type => 'multipart/alternative', }, parts => [ new_part('text/html', $html), new_part('text/plain', $text) ]); print $m->as_string;