Home: Perl Programming Help: Intermediate:
charset problem on sending email with Mime::Lite



mario99ukdw
New User

Oct 18, 2016, 11:24 PM


Views: 4989
charset problem on sending email with Mime::Lite

I have code that need to send email with attachment. But on thunderbird the character is broken (umlaut character is not show properly). On outlook, the umlaut character is show correctly

here are the code


Code
my $msg = MIME::Lite->new( 
From => $self->{from},
To => $self->{to},
Cc => $self->{cc},
Subject => $self->{subject},
Type => 'multipart/mixed',
Charset => 'utf8',
);

$msg->attach(Type => 'TEXT', Data => 'I hope you can use this! ');

foreach my $attachment (@{$self->{attachments}}) {
my ($name, $path, $suffix) = fileparse($attachment, '\.[^\.]*');

my $attachment_type = 'text/plain';
if ($suffix eq '.idoc') {
$attachment_type = 'application/octet-stream';
} elsif ($suffix eq '.pdf') {
$attachment_type = 'application/pdf';
} elsif ($suffix eq '.p7s') {
$attachment_type = 'application/pkcs7-mime';
}
$msg->attach(
Type => $attachment_type,
Path => $attachment,
Filename => $name . $suffix,
Disposition => 'attachment'
);
}

$msg->send ('smtp', $mail_smtp_server);


do we have certain setting for thunderbird?
Attachments: Screenshot_3.png (6.16 KB)


Laurent_R
Veteran / Moderator

Oct 19, 2016, 5:10 AM


Views: 4985
Re: [mario99ukdw] charset problem on sending email with Mime::Lite

You probably need to configure Thunderbird for UTF-8 encoding.


mario99ukdw
New User

Oct 20, 2016, 2:40 AM


Views: 4968
Re: [mario99ukdw] charset problem on sending email with Mime::Lite

It is work now

I changed this line code

Code
$msg->attach(Type => 'TEXT', Data => 'I hope you can use this! ');


into this code


Code
$msg->attach(Type => 'text/html; charset=UTF-8', Data => 'I hope you can use this! ');


and the umlaut chars is show correctly on thunderbird