in reply to Read and manage IMAP mails for me

I'm having difficulty getting this code of Discipulus' to work--actually, I think his code is fine and wonder about my dovecot instance--and have stripped things down to a test case:
#!/usr/bin/perl use strict; use warnings; use Mail::IMAPClient; my $now = time; print "Now is $now\n"; (my $username, my $password) = ('re','dacted'); my $imap = Mail::IMAPClient->new(Server => 'localhost', User => $username, Password => $password, Port => '143'); die "failed to instantiate $@." unless defined $imap; my $select = $imap->select('INBOX'); my @messages = $imap->messages('INBOX'); print "All @messages\n"; sleep 15; #<---Here's where I generate fresh mail, during the sleep $select = $imap->select('INBOX'); @messages = $imap->sentsince($now); print "Some @messages\n"; print "Now then was $now\n"; $now = time; print "Now now is $now\n";
Which gives me these results:
Now is 1752071233 All 3443 3444 3445 3446 3447 3448 3449 3450 3451 3452 3453 3454 3455 3 +456 3457 3458 3459 3460 3461 3462 3463 3464 3465 3466 3467 3468 3469 Some Now then was 1752071233 Now now is 1752071248
What I expect is for the new mail to show up in the Some line, but it does not.
They laughed at Joan of Arc, but she went right ahead and built it. --Gracie Allen

Replies are listed 'Best First'.
Re^2: Read and manage IMAP mails for me
by NERDVANA (Priest) on Jul 10, 2025 at 17:33 UTC
    I haven't had time to look at the details, but I did check the code I use for work that fetches data from mailboxes and we're using Net::IMAP::Simple. You might try that.