2009年3月16日星期一

[PerlChina] Re: 用mail::pop3client收取gmail邮件

gmail不是要通过ssl登录吗

2009/3/12 xu zhou <redicaps@gmail.com>:
>
> 我用下面这个脚本来收取gmai邮件
> 但是发现获得的邮件数目总是和实际web gmail里面的不一样,少了很多
> 有人知道怎么回事么?
> 或者能提供更好的方法?
>
>
>
> #!/usr/bin/perl -w
> use strict;
> use warnings;
> use Term::ReadKey;
> use DB_File;
> use Mail::POP3Client;
> use Env qw/$HOME/;
> use IO::Socket::SSL;
>
> my $conf = $HOME."/.gmail";
> my %config;
> tie %config, 'DB_File',$conf,0700 or die "$!";
>
> my $mailhost  = 'pop.gmail.com';
> my $port      = '995';
>
> &read_stdin() unless (defined $config{username} && defined $config{password});
> my $pop = new Mail::POP3Client( USER     => $config{username},
>                                PASSWORD => $config{password},
>                                HOST     => $mailhost,
>                                PORT     => $port,
>                                USESSL   => 'true',
>                                DEBUG    => 0,
>                             );
>
> if (($pop->Count()) < 1) {
>        print "No messages...\n";
>        exit;
> }
>
> print $pop->Count() . " messages found!\n";
> for($i = 1; $i <= $pop->Count(); $i++) {
>
>        print $pop->Head($i) . "\n";
>        print $pop->Body($i) . "\n";
>        print "\n";
> }
> $pop->Close();
>
> sub read_stdin() {
>    ReadMode 'normal';
>    print "username:";
>    $config{username} = ReadLine 0;
>    chomp $config{username};
>    print "password:";
>    ReadMode 'noecho';
>    $config{password} = ReadLine 0;
>    chomp $config{password};
>    ReadMode 'normal';
>    print "\n";
> }
>
> >
>

--~--~---------~--~----~------------~-------~--~----~
您收到此信息是由于您订阅了 Google 论坛"PerlChina Mongers 讨论组"论坛。
要在此论坛发帖,请发电子邮件到 perlchina@googlegroups.com
要退订此论坛,请发邮件至 perlchina+unsubscribe@googlegroups.com
更多选项,请通过 http://groups.google.com/group/perlchina?hl=zh-CN 访问该论坛
-~----------~----~----~----~------~----~------~--~---

没有评论: