<更多Perl相關資訊請參考以下聯結>

http://www.geego.com.tw/edm/progm_perl_programming_fundamental/index.php?v=pixnet&c=blog&k=perl&p=progm&t=programming_fundamental

當看到錯誤訊息Wide character in subroutine entry at /usr/share/perl5/Mail/Sendmail.pm line 237.
原因可能為使用perl的Mail::Sendmail模組寄送中文時會出現的問題,請使用 use Encode把內容編碼後,
再寄信時把信件表頭中加入 Content-type = 'text/plain; charset="utf-8"' 即可

程式範例:

#!/usr/bin/perl

use Mail::Sendmail;

use utf8;
use Encode;


$email = 'perl.mail::sendmail@geego.com.tw';
$course = "test course";

my $message = "這是一封用來測試perl的Mail::Sendmail模組可否成功寄送utf8字元.\n";

$message = encode( "utf8", $message );

my %mail = ( To => "$email",
From => 'GeeGo Customer Service<customers@geego.com.tw>',
'Content-type' => 'text/plain; charset="utf-8"',
Subject => "Perl’s Mail::Sendmail sending text body with utf8 encoding",
Message => "$message" );

sendmail(%mail) or die $Mail::Sendmail::error;

 



arrow
arrow
    文章標籤
    Perl UTF8 sendmail
    全站熱搜

    台灣 富捷IT培訓 發表在 痞客邦 留言(0) 人氣()