- 论坛徽章:
- 0
|
- use Net::SMTP;
- use Authen::SASL;
- use Encode qw/from_to encode decode/;
- my $mailhost = 'localhost';
- my $mailfrom = 'XXXXXXXX';
- my $subject = "这里是中文出现的地方";
- my $text = <<EOF;
- 这里也是中文出现的地方
- EOF
- #from_to($subject,"gbk","utf8");
- #from_to($text,"gbk","utf8");
- my $smtp = Net::SMTP->new($mailhost, Timeout => 60, Debug => 1, Hello => 'XXXXX',);
- $sasl =Authen::SASL->new(mechanism => 'LOGIN', callback=>{user => "XXXXX", pass => "XXXXXXX"} );
- $smtp->auth($sasl);
- my $mailto = 'XXXXXXXX';
- $smtp->mail($mailfrom);
- $smtp->to($mailto);
- $smtp->data();
- $smtp->datasend("Content-Type: text/plain; charset=gb2312 \n");
- $smtp->datasend("Content-Transfer-Encoding: 8bit\n");
- $smtp->datasend("To: $mailto \n");
- $smtp->datasend("From: $mailfrom \n");
- $smtp->datasend("Subject: $subject \n");
- $smtp->datasend("Text: $text \n\n");
- $smtp->datasend("\n");
- $smtp->quit;
复制代码
[ 本帖最后由 chenxiam 于 2007-11-10 01:42 编辑 ] |
|