Subject: | Net-IMAP-Client search() method fails against outlook.office365.com imap(s) server |
Date: | Mon, 22 Jun 2020 17:39:42 +0000 (UTC) |
To: | "bug-Net-IMAP-Client [...] rt.cpan.org" <bug-Net-IMAP-Client [...] rt.cpan.org> |
From: | Guy Boyd <gfb.0x08005bffffff [...] yahoo.com> |
bug-Net-IMAP-Client@rt.cpan.org
Net::IMAP::Client
( Net-IMAP-Client-0.9505 ) via cpan
Linux [host] 3.10.0-1127.el7.x86_64 #1 SMP Tue Mar 31 23:36:51 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux
CentOS Linux release 7.8.2003 (Core)
This is perl 5, version 16, subversion 3 (v5.16.3) built for x86_64-linux-thread-multi
Specific to one particular type of (major) IMAP service provider:
Problem:
Net:::IMAP->search() method fails making it apparently impossible to retrieve message UIDs and subsequently message summaries.
begin IMPORTANT NOTE:
Problem appears to be specific to outlook.office365.com(:993).
Works *precisely as expected* with:
gmail
xfinity/comcast
yahoo
imap-uw ( in a test-sandbox on a local air-gapped network )
dovecot ( local build in a test environment )
end IMPORTANT NOTE
How to reproduce:
# -------------- cut here ----------------------
use strict;
no strict "subs";
use Net::IMAP::Client;
use Data::Dumper;
my( @folders ) = $imap->folders; # succeeds
print Dumper(\@folders); # evidence
my $status = $imap->status(@folders); # succeeds
print Dumper($status); # evidence
foreach my $f ( $imap->folders ) {
$imap->select( $f ) || die("$!"); # succeeds
print Dumper($imap); # evidence. the imap object contains the total message count.
# module selects UTF-8 by default anyway
my ($messages) = $imap->search( 'ALL' );
# failure, returns undef
print Dumper ($messages) if defined($messages); # returns undef if test for defined() is omitted
}
# -------------- cut here ----------------------
Additional detail:
# vi /root/perl5/lib/perl5/Net/IMAP/Client.pm
: set number
# add a couple of debug lines at line 317, line 324:
312 my ($ok, $lines) = $self->_tell_imap($cmd => "$sort$charset $criteria", 1);
313 if ($ok) {
314 # it makes no sense to employ the full token parser here
315 # read past progress messages lacking initial '*'
316 foreach my $line (@{$lines->[0]}) {
317 ++ printf("%s\n", $line);
318 if ($line =~ s/^\*\s+(?:SEARCH|SORT)\s+//ig) {
319 $line =~ s/\s*$//g;
320 return [ map { $_ + 0 } split(/\s+/, $line) ];
321 }
322 }
323 }
324 ++ printf("%s %s\n", "search()", "search failed" );
325 return undef;
add one more debug line at line 796:
792 sub _tell_imap {
793 my ($self, $cmd, $args, $do_notf) = @_;
794
795 $cmd = uc $cmd;
796 ++ printf("%s\n", $cmd);
797 my ($lineparts, $ok, $res);
Output of test sample (without sensitive information from Data::Dumper) :
LOGIN
LIST
LIST
SELECT
SEARCH
search() search failed
Effective conclusion: since search() returns no lines,
it would appear that the server returns no response to examine.....
Further debugging suggestions are welcome.