
andi25
New User
Jul 23, 2010, 4:50 AM
Post #1 of 2
(867 views)
|
|
mail: Using MIME::Lite with utf-8
|
Can't Post
|
|
Hi all, i'd like to send a simple mail with attachment in perl but i have problems with the characters "ü, ä, ö, ..." (german). Here is my code:
#!/usr/bin/perl use strict; use MIME::Lite; use Time::localtime; use MIME::Words qw(:all); use Encode; my $mailtext=""; mail(); sub mail { my $sendmail = "/usr/sbin/sendmail -t"; my $from = "myadress@email.com"; my $reply_to = "myadress@email.com"; my $subject = "Subject ü ä ö"; my $mail_message = "This is a text with ü ä and ö"; #Subject encoding utf8::decode($subject); # Create new mail my $msg = MIME::Lite->new ( Subject => $subject, From => $from, To => 'mymail@mail.com', Type => 'multipart/mixed', Charset => 'utf-8' ); # Mailtext $mailtext=$mail_message; $msg->attach ( Type => 'TEXT', Data => $mailtext ); # Send mail MIME::Lite->send("sendmail", $sendmail); $msg->send; } exit; When i read this mail with Thunderbird (that uses ISO 8895-15) i can't read ä, ü and ö. But when i change the view in my Thunderbird to "utf-8" it looks fine. Is the code right like i have written it? How can i do that the mail arrives as a utf-8 mail in the mailclients? Thank you for your answers and have a nice weekend... andi
|