java多线程    Java入门    vsftp    ftp    linux配置    centos    FRP教程    HBase    Html5缓存    webp    zabbix    分布式    neo4j图数据库    

perl利用pop3 收取邮件

背景:公司需要开发一套大型客服系统
需求为100个客服同时回复N个用户的邮件,所以找个perl来自动读取一个特定邮箱的邮件比如service@java-er.com

#!/usr/bin/perl -w
use strict;
use Mail::POP3Client;

my $pop;
my $num_mesg;
my $i;
my $username;

our $mail_host  = 'imap.exmail.qq.com';  
our $mail_user  = 'yuexiaosheng@java-er.com';  
our $mail_pass  = '8888899999';  

my $pop = new Mail::POP3Client( $mail_user, $mail_pass, $mail_host );

$num_mesg = $pop->Count;	#How many messages are there?
print ("You have ".$num_mesg." new messages.\n");

exit();
for ($i = 1; $i <= $num_mesg; $i++) {
print $pop->Head($i), "\n";	#print header for each message
}

电脑缺少mail包的同学
perl -MCPAN -eshell
cpan> install Mail::POP3Client

参考我的perl另外一个文章 https://java-er.com/blog/perl-read-url-connect-lwp/


This entry was posted in Linux, Perl and tagged , , , . Bookmark the permalink.
月小升QQ 2651044202, 技术交流QQ群 178491360
首发地址:月小升博客https://java-er.com/blog/perl-pop3-receive-mail/
无特殊说明,文章均为月小升原创,欢迎转载,转载请注明本文地址,谢谢
您的评论是我写作的动力.

Leave a Reply