http://www.geego.com.tw/technical-discussion-forum/tech-tips-sendmail-sending-utf8-characters-%E5%82%B3%E9%80%81-%E5%AD%97%E5%85%83-%E7%B7%A8%E7%A2%BC
Perl Mail::Sendmail 傳送 utf8字元
作者:Ben哥|發布日期:2012/03/23
當看到錯誤訊息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;
當看到錯誤訊息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;
沒有留言:
張貼留言