用户登录
用户注册

分享至

Perl批量下载Gmail附件的代码

  • 作者: 南角先生
  • 来源: 51数据库
  • 2020-08-07
这篇文章主要介绍了Perl批量下载Gmail附件的代码,本文重点在使用Mail::POP3Client模块和Gmail通信的方法,需要的朋友可以参考下

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

实现代码:

复制代码 代码如下:

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();

软件
前端设计
程序设计
Java相关