Chinaunix
标题:
求助 谁用过Net::SMTP帮忙写个简单的例子
[打印本页]
作者:
搬砖工作者
时间:
2012-01-16 16:08
标题:
求助 谁用过Net::SMTP帮忙写个简单的例子
求帮忙
作者:
兰花仙子
时间:
2012-01-16 16:44
sample code already exists in the official manual:
http://search.cpan.org/~gbarr/libnet-1.22/Net/SMTP.pm
作者:
wxlfh
时间:
2012-01-17 09:13
建议用MIME::Lite,比较方便。
作者:
andy20008
时间:
2012-01-17 12:36
论坛里有一个很全面的帖子,楼主可以搜索一下
作者:
malon111
时间:
2012-01-19 16:36
本帖最后由 zhlong8 于 2012-01-19 17:31 编辑
#!/usr/bin/perl -w
#receive email using Mail::POP3Client
use strict;
use IO::File;
use MIME::Parser;
use Mail::POP3Client;
my $dir = 'email';
my $file = new IO::File;
my $parser = new MIME::Parser;
$parser->output_dir( $dir );
my $pop = new Mail::POP3Client( USER => "xxx",
PASSWORD => "yyy",
HOST => "zzz.zzz.zzz.zzz" );
my $j = $pop->Count();
for ( my $i = 1; $i <= $j; $i++ ) {
print "Now saving raw-message.$i...\n";
if ( $file->open( "> $dir/raw-message.$i" ) ) {
$pop->HeadAndBodyToFile( $file, $i );
$file->close();
}
}
$pop->Reset();
$pop->Close();
for ( my $i = 1; $i <= $j; $i++ ) {
print "Now parsing raw-message.$i...\n";
$parser->parse( IO::File->new( "$dir/raw-message.$i") );
}
#eof
欢迎光临 Chinaunix (http://bbs.chinaunix.net/)
Powered by Discuz! X3.2