Simple POP 3 Client Ver 1.0
来源:互联网 发布:java javahome 编辑:程序博客网 时间:2024/05/19 03:21
#!/usr/bin/perl -w
use Net::POP3;
# Connect to pop3 server
my $pop3 = Net::POP3->new("10.10.10.10") || die "Error : Couldn't log
+on to server";
# Login to pop3 server
my $Num_Message = $pop3->login("dummy", "dummy");
my $Messages = $pop3->list();
my ($MsgId, $MsgDate, $MsgFrom, $MsgTo, $MsgCc, $MsgSub);
my ($MsgAttach, $MsgSize, $MsgHeader, $MsgHeadFlg, $MsgBody);
foreach $MsgNo (keys %$Messages)
{
my $MsgContent = $pop3->get($MsgNo);
my $count = 0;
$MsgHeadFlg = 0;
$MsgBody = "";
print "Message No : $MsgNo/n";
$MsgSize = $pop3->list($MsgNo);
print "Message Size : $MsgSize Bytes/n";
# Process message data
while()
{
# Exit if last line of mail
if ($count >= scalar(@$MsgContent))
{
print "$MsgBody";
last;
}
# Check if end of mail header
if (@$MsgContent[$count] =~ /^/n/)
{
$MsgHeadFlg = 1;
}
# Proceed if message header not processed
if (not $MsgHeadFlg)
{
# Split the line
my @LineContent = split /: /, @$MsgContent[$count];
# Check Header Info
SWITCH:
{
# Get message date
$LineContent[0] =~ /Date/i && do
{
$MsgDate = $LineContent[1];
print "Date : $MsgDate";
last SWITCH;
};
# Get message id
$LineContent[0] =~ /Message-ID/i && do
{
$MsgId = $LineContent[1];
print "Message ID : $MsgId";
last SWITCH;
};
# Get message from
$LineContent[0] =~ /From/i && do
{
$MsgFrom = $LineContent[1];
print "From : $MsgFrom";
last SWITCH;
};
# Get message to
$LineContent[0] =~ /To/i && do
{
$MsgTo = $LineContent[1];
print "To : $MsgTo";
last SWITCH;
};
# Get message cc
$LineContent[0] =~ /Cc/i && do
{
$MsgCc = $LineContent[1];
print "Cc : $MsgCc";
last SWITCH;
};
# Get message subject
$LineContent[0] =~ /Subject/i && do
{
$MsgSub = $LineContent[1];
print "Subject : $MsgSub";
last SWITCH;
};
}
}
else
{
# Process message body
$MsgBody .= @$MsgContent[$count];
}
$count++;
}
}
# Disconnect from pop3 server
$pop3->quit();
use Net::POP3;
# Connect to pop3 server
my $pop3 = Net::POP3->new("10.10.10.10") || die "Error : Couldn't log
+on to server";
# Login to pop3 server
my $Num_Message = $pop3->login("dummy", "dummy");
my $Messages = $pop3->list();
my ($MsgId, $MsgDate, $MsgFrom, $MsgTo, $MsgCc, $MsgSub);
my ($MsgAttach, $MsgSize, $MsgHeader, $MsgHeadFlg, $MsgBody);
foreach $MsgNo (keys %$Messages)
{
my $MsgContent = $pop3->get($MsgNo);
my $count = 0;
$MsgHeadFlg = 0;
$MsgBody = "";
print "Message No : $MsgNo/n";
$MsgSize = $pop3->list($MsgNo);
print "Message Size : $MsgSize Bytes/n";
# Process message data
while()
{
# Exit if last line of mail
if ($count >= scalar(@$MsgContent))
{
print "$MsgBody";
last;
}
# Check if end of mail header
if (@$MsgContent[$count] =~ /^/n/)
{
$MsgHeadFlg = 1;
}
# Proceed if message header not processed
if (not $MsgHeadFlg)
{
# Split the line
my @LineContent = split /: /, @$MsgContent[$count];
# Check Header Info
SWITCH:
{
# Get message date
$LineContent[0] =~ /Date/i && do
{
$MsgDate = $LineContent[1];
print "Date : $MsgDate";
last SWITCH;
};
# Get message id
$LineContent[0] =~ /Message-ID/i && do
{
$MsgId = $LineContent[1];
print "Message ID : $MsgId";
last SWITCH;
};
# Get message from
$LineContent[0] =~ /From/i && do
{
$MsgFrom = $LineContent[1];
print "From : $MsgFrom";
last SWITCH;
};
# Get message to
$LineContent[0] =~ /To/i && do
{
$MsgTo = $LineContent[1];
print "To : $MsgTo";
last SWITCH;
};
# Get message cc
$LineContent[0] =~ /Cc/i && do
{
$MsgCc = $LineContent[1];
print "Cc : $MsgCc";
last SWITCH;
};
# Get message subject
$LineContent[0] =~ /Subject/i && do
{
$MsgSub = $LineContent[1];
print "Subject : $MsgSub";
last SWITCH;
};
}
}
else
{
# Process message body
$MsgBody .= @$MsgContent[$count];
}
$count++;
}
}
# Disconnect from pop3 server
$pop3->quit();
- Simple POP 3 Client Ver 1.0
- Simple REST Client
- Multi Password Recovery ver. 1.0.3
- ProcHeapViewer ver 1.0 Windows
- BlogBench Ver 1.0 发布
- 虚拟分区 VER 1.0
- 杂记 Ver 0.0.3
- a simple memcached client Demo
- A simple FTP update client
- Simple UDP server and client
- Simple REST Client POST使用方法
- Writing a Simple Action Client
- Simple REST Client POST使用方法
- F-Secure Client Security ver. 7.00 Build 515
- 贪吃蛇 ver 1.0 JavaScript
- FTPRush ver.1.0.0.613 Unicode
- Switcher Vista ver. 1.0.5.1440
- LivaPlayer发布了,Ver 1.0
- 系统自动启动程序之十大藏身之所
- 第一次发表文章,呵呵!!!
- 中国科学技术期刊编辑学会常务理事-李兴昌 教你如何写科技论文(1)
- 愉快的周末
- Linux下简单ftp实现
- Simple POP 3 Client Ver 1.0
- 13G编程电子书开始提供BT下载,下载说明及BT种子下载网址
- 串口编程的问题
- 求救(关于窗体调用的问题)
- Java1.5泛型指南
- 机会绝不容错过
- [转载]MD5算法之C#程序 MD5算法描述
- 又开始了我的blog
- 工作与生活