Deprecated: The each() function is deprecated. This message will be suppressed on further calls in /home/zhenxiangba/zhenxiangba.com/public_html/phproxy-improved-master/index.php on line 456
#!/usr/local/bin/perl
# $Id: pop3-client-Net::POP3.pl,v 1.2 2007/07/20 10:59:14 68user Exp $
use Net::POP3; # Net::POP3 モジュールを使う
use Getopt::Std; # オプション解析用
getopts('au:h:p:',\%opts);
$hostname = $opts{'h'} || 'pop3.foo.bar.com';
$username = $opts{'u'} || 'username';
$password = $opts{'p'} || 'password';
$use_apop = $opts{'a'} || 0;
$pop = Net::POP3->new($hostname); # 接続
if ( ! $pop ){
die "接続失敗: $!";
}
if ( $use_apop ){
# APOP コマンド送信
$auth_check = $pop->apop($username,$password);
} else {
# USER・PASS コマンド送信
$pop->user($username);
$auth_check = $pop->pass($password);
}
if ( ! defined $auth_check ){
die "認証失敗: ";
}
$ref_mailsize = $pop->list(); # メール一覧のハッシュのリファレンスを得る
# メールサイズ表示
foreach ( sort {$a<=>$b} keys %{$ref_mailsize} ){
print "Mail NO.$_ $$ref_mailsize{$_}bytes\n";
}
*mailindex = $ref_mailsize; # $ref_mailsize の 別名を作る
foreach ( sort {$a<=>$b } keys %mailindex ){
print "\nMail No.$_ $mailindex{$_}bytes\n";
$ref_lines = $pop->get($_); # メール本文を取得
$line = 1;
foreach ( @$ref_lines ){ # 1行ずつ表示
s/^\.\././; # 行頭の .. を . に変換
print "$line: $_";
$line++;
}
}
$pop->quit(); # ログアウト