- 论坛徽章:
- 0
|
用net::pop3写邮件客户端,取得的邮件主题等显示乱码?
《perl网络编程》中的一段代码,
#!c:\perl\bin\perl
use strict;
use Net: OP3;
use MIME::Entity;
use MIME: arser;
my $file = 'D:\example\11.txt';
open F,$file or die "can't open $file !\n";
my $pop = Net: OP3->;new($host) or die "Can't connect to $host !\n";
my $message = $pop->;login($user=>;$passwd) or die "Can't log in:",$pop->;message,"\n";
my $last = $pop->;last;
$message +=0;
print "inbox has $message message(",$message-$last,"new)\n";
my $parser =new MIME: arser;
$parser->;output_dir("d:\\mail" ;
my $entity = $parser->;parse(\*F);
print "From = ",$entity->;head->;get('From'),"\n";
print "Subject = ",$entity->;head->;get('Subject'),"\n";
print "MIME type = ",$entity->;mime_type,"\n";
print " arts = ",scalar $entity->;parts,"\n";
for my $part ($entity->;parts) {
print "\t",$part->;mime_type,"\t",$part->;bodyhandle->;path,"\n";
}
$entity->;purge;
想试试用MIME: arser对mail头进行解析是怎样,但是解析出来的除了MIME type都是空,这是为什么?
执行一次,在d:\\mail下会有一个空的文本文件,是不是因为my $file = 'D:\example\11.txt'中的11.txt的问题?书上说应该是一个包含MIME编码的消息。但是我不知道这个文件应该是怎样的。
请教大家! |
|