我是靠谱客的博主 重要哈密瓜,这篇文章主要介绍Perl的Mail::POP3Client模块和Gmail通信实例,现在分享给大家,希望可以做个参考。

一、前言

最近在写一个从gmail批量下载附件的程序,用到了 Mail::POP3Client 和 MIME::Parser 2 个模块

二、相关文档

CPAN:
Mail::POP3Client模块
MIME::Parser模块
StrawberryPerl模块的安装、卸载与查看

三、实现

use Mail::POP3Client;
use MIME::Parser;
 
my $U = 'User.Name@gmail.com';
my $P = 'uSeR.pAsSwORd';
my $X = new MIME::Parser;
$X -> output_dir('C:\\download');  #directory to save attachment
 
my $G = Mail::POP3Client -> new (
      USER    => $U,
      PASSWORD  => $P,
      HOST    => 'pop.gmail.com',
      PORT    => 995,
      USESSL   => 'true') or die "Can't Connect The Server.\n";
 
for $i (1 .. $G->Count())
{
  my $C = $G->HeadAndBody($i);
  my $R = $X->parse_data($C);
}
$G->Close();

最后

以上就是重要哈密瓜最近收集整理的关于Perl的Mail::POP3Client模块和Gmail通信实例的全部内容,更多相关Perl内容请搜索靠谱客的其他文章。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(230)

评论列表共有 0 条评论

立即
投稿
返回
顶部