我要送用Perl電子郵件,這裏給的是代碼:電子郵件主題用特殊的字符用Perl
my $msg = MIME::Lite->new(
From => $tpl->{'from'},
To => $tpl->{'to'},
Subject => $subject_id_site . Encode::encode('MIME-Header',$subject_label). Encode::encode('MIME-Header', $tpl->{'subject'}),
ReplyTo => $tpl->{'reply_to'},
Encoding => 'quoted-printable',
Type =>'text/html',
Data => Encode::encode('utf8',$tpl->{'body'}),
);
如果主題包含特殊字符,例如:[300584/Yçàéè@test] subject
這裏是我通過perl編碼發送的電子郵件主題:[300584/Yçà éè@test] subject
。
其實我試過Encode::encode('UTF8',$subject_label)
,但它變得更糟。
你有,作爲一個文字字符串在源代碼中的數據或者是'$ subject_label'從外部來源看? – simbabque
@simbadque,是$ subject_label從外部來源讀取 –
請提供'join「|」,(map {sprintf(「%vX」,$ _)} $ subject_id_site,$ subject_label,$ tpl - > { 'subject'}),$ subject_id_site。編碼::編碼( 'MIME標頭',$ subject_label)。 Encode :: encode('MIME-Header',$ tpl - > {'subject'})' – ikegami