CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Intermediate:
mail: Using MIME::Lite with utf-8

 



andi25
New User

Jul 23, 2010, 4:50 AM

Post #1 of 2 (1081 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:


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


Zhris
Enthusiast

Jul 23, 2010, 11:36 AM

Post #2 of 2 (1068 views)
Re: [andi25] mail: Using MIME::Lite with utf-8 [In reply to] Can't Post

Try setting the content type charset, e.g.:


Code
$msg->attr('content-type.charset' => 'UTF-8');


Chris

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives