使用message_string()函数错误的IMAPClient

时间:2019-02-20 11:37:58

标签: perl

您对如何解决Mail :: IMAPClient库的message_string()函数遇到的问题有一个想法,这是我的代码:

     #!/usr/bin/perl -w
use strict;
use warnings;
use Mail::IMAPClient;
use IO::Socket::SSL;



 # Create the object connexion with socket SSL + LOG ON
my $imap = Mail::IMAPClient->new(
 #Debug    => 1,
  User     => 'xxxxx',
  Password => 'yyyyy',
  Uid      => 1,
  Peek     => 1,  # set \Seen flag
  Socket   => IO::Socket::SSL->new(
                Proto    => 'tcp',
                PeerAddr => 'zzzzzzz',
                PeerPort => 993,
              )
);
   die "$0: connect: $@" if defined $@;


my $nm=$imap->unseen_count("INBOX") ;
# Select INBOX dossier
$imap->select("INBOX");




      my $msg = $imap->message_string('47') or die " $@\n";

获得的错误如下:

message_string() expected 304627 bytes but received 304718 you may need the IgnoreSizeErrors option

1 个答案:

答案 0 :(得分:4)

错误消息告诉您确切的处理方法。一些IMAP服务器错误地计算了邮件大小-特别是,许多服务器(例如,特别是GMail)检查本地邮件大小,然后在通过IMAP发送邮件时将行终止符更改为CRLF,从而导致实际大小与实际大小略有不同。服务器告诉客户端期望。默认情况下,IMAPClient会在发生这种情况时抛出错误,但是您可以在创建实例时说IgnoreSizeErrors => 1来告诉自己不要这样做。

my $imap = Mail::IMAPClient->new(
 #Debug    => 1,
  User     => 'xxxxx',
  Password => 'yyyyy',
  Uid      => 1,
  Peek     => 1,  # set \Seen flag
  Socket   => IO::Socket::SSL->new(
                Proto    => 'tcp',
                PeerAddr => 'zzzzzzz',
                PeerPort => 993,
              ),
  # See here
  IgnoreSizeErrors => 1
);