背景:公司需要开发一套大型客服系统
需求为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/