Reference:
使用 perl 发送中文邮件标题乱码
Email主旨亂碼 =?Big5?(Q|B)?xxxxxxxxxx ?=
狀況:
用 MIME:LITE 發信,中文標題變成亂碼
解法:
use MIME::Lite;
use MIME::Base64;
$mail_host = "My_SMTP_server";
$mail_from = 'from_address';
$mail_to = 'to_address';
$mail_subject = '=?big5?B?'. encode_base64("繁體中文標題") .'?=';
$mail_body = "Test";
mail_notify();
sub mail_notify {
MIME::Lite->send('smtp', $mail_host, Debug=>0, Timeout=>60);
$msg = MIME::Lite->new(
From => $mail_from,
To => $mail_to,
Subject => $mail_subject,
Type =>'multipart/mixed',
);
$msg->attach (
Type => 'TEXT',
Data => $mail_body,
) or die "Error adding the text message part: $!\n";
$msg->send();
}
沒有留言:
張貼留言