[求助]发送邮件时出现乱码

[求助]发送邮件时出现乱码

用net::smtp编写的邮件发送
发送中文时出现一堆乱码,如"脰脨鹿煤脡煤脦茂脗脹脤鲁"
用gkb,gb2312,uft8都解决不了,要用base64来解决吗,怎么解决?
谢谢
把代码放上来


[Copy to clipboard] [ - ]
CODE:
use Net::SMTP;
use Authen::SASL;
use Encode qw/from_to encode decode/;
my $mailhost = 'localhost';
my $mailfrom = 'XXXXXXXX';
my $subject = "这里是中文出现的地方";
my $text = <<EOF;
这里也是中文出现的地方
EOF

#from_to($subject,"gbk","utf8");
#from_to($text,"gbk","utf8");

my $smtp = Net::SMTP->new($mailhost, Timeout => 60, Debug => 1, Hello => 'XXXXX',);
$sasl =Authen::SASL->new(mechanism => 'LOGIN', callback=>{user => "XXXXX", pass => "XXXXXXX"} );
$smtp->auth($sasl);
my $mailto = 'XXXXXXXX';
$smtp->mail($mailfrom);
$smtp->to($mailto);
$smtp->data();
$smtp->datasend("Content-Type: text/plain; charset=gb2312 \n");
$smtp->datasend("Content-Transfer-Encoding: 8bit\n");
$smtp->datasend("To: $mailto \n");
$smtp->datasend("From: $mailfrom \n");
$smtp->datasend("Subject: $subject \n");
$smtp->datasend("Text: $text \n\n");
$smtp->datasend("\n");
$smtp->quit;

顶上去
datasend的內容需要用
MIME::Entity ;之類的模組編碼一下.