Perl批量下载Gmail附件的代码_技术学院_宜昌市隼壹珍商贸有限公司

您好,欢迎访问宜昌市隼壹珍商贸有限公司

400 890 5375
当前位置: 主页 > 新闻动态 > 技术学院

Perl批量下载Gmail附件的代码

发布时间:2026-01-17  |  点击率:

最近在写一个从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();

全国统一服务电话

400 890 5375

电子邮箱:879577@qq.com

公司地址:宜昌市西陵区黄河路5号三峡明珠10栋1051室

咨询微信

TEL:13680874598