我決定在他們的網站上用一些初學者腳本深入Perl。我從http://learn.perl.org/examples/email.html開始嘗試一個基本的電子郵件發送腳本。Perl電子郵件腳本 - 內容編碼問題
下面是實際的代碼:
#!/usr/bin/perl
use strict;
use warnings;
#Character encoding var
my $encoding='text/plain; charset="iso-8859-5"';
#Create the message
use Email::MIME;
my $message = Email::MIME->create(
header_str => [
From => '[email protected]',
To => '[email protected]',
Subject => 'I sent you this message using Perl.',
],
body_str => 'I sent you this message using Perl. One of those languages that would\' would\'ve been helpful much sooner in my life...',
);
use Email::Sender::Simple qw(sendmail);
sendmail($message);
我所得到的,當我做perl script.pl
是我做的電子郵件:: MIME模塊周圍一些搜索,發現body_str的
body_str was given, but no charset is defined at /usr/local/share/perl/5.10.1/Email/MIME.pm line 243
Email::MIME::create('Email::MIME', 'header_str', 'ARRAY(0x9a04818)', 'body_str', 'I sent you this message using Perl. One ...') called at script.pl line 10
的錯誤信息部分,但沒有揭示錯誤信息。我假設我需要設置編碼,但我不知道如何去做。
感謝@cjm這個例子現在已經修復了,感謝你提出這個例子! – 2012-02-13 06:17:10