Mails randomly, infrequently not being injected into RT 4.4.4 on Ubuntu 22.04 by app-wsgetmail

I am not sure if this is RT User or developers, as I seem to need more logging than is provided to diagnose my problem. Maybe I just need the right config options.

I am using app-wsgetmail in place of fetchmail to get mails from an Exchange mailbox and inject them into rt-mailgate.

I quite quickly noticed that some mails are being marked as read, but not collected. I can see no mails being collected by app-wsgetmail (processed 0 messages each time), and nothing is logged. I have --debug set for the calls to rt-mailgate in the app-wsgetmail config files, have set and use a wrapper to log every call to it. Initially I just logged non-zero return codes, but as these never happened, even when mails were not collected, I starting logging every mail put through. I log the command line, error code, stderr, stdout and the mail.

Unfortunately the mails marked as read don’t get to the wrapper, at least sometimes. It looks like app-wsgetmail is not calling the given command.

I initiate the pulls with systemd user .timer and one-shot .service units. They happen every 20s or so (AccuracySec is set to 1s).

How to debug this further? I can sit and watch mails get marked as read and not injected, but I have found nothing in the logging I have tried so far.

(1: I am wondering if this relates to the time being wrong on the sender’s computer, and so assumptions about timestamps not holding. There’s no evidence for that yet, just a hunch)

(2: I can see the issue tracker at Active bugs for App-wsgetmail but not how to contribute to it)

Russell

I added logging for when messages were marked (below), and that allowed me to figure out the problem. On the test server I had set up both systemd timer and cron jobs, and I had removed the .timer, but not the cron jobs. The jobs were lower frequency than on live, so mostly live marked as read, but occasionally the test server won the race. The logs on that server correlated with the messages marked for no (previously) apparent reason.

Russell

diff --git a/bin/wsgetmail b/bin/wsgetmail
index d0bc4b7..6b29698 100755
--- a/bin/wsgetmail
+++ b/bin/wsgetmail
@@ -49,6 +49,8 @@
 
 use v5.10;
 use strict;
+use warnings;
 use Fcntl ':flock';
 use FindBin;
 use lib "$FindBin::Bin/../lib";
diff --git a/lib/App/wsgetmail/MS365.pm b/lib/App/wsgetmail/MS365.pm
index d17e30a..d5f0e7a 100644
--- a/lib/App/wsgetmail/MS365.pm
+++ b/lib/App/wsgetmail/MS365.pm
@@ -347,6 +347,8 @@ sub mark_message_as_read {
     unless ($response->is_success) {
         warn "failed to mark message as read " . $response->status_line;
         warn "response from server : " . $response->content if $self->debug;
+    } else {
+       warn "marking message ".$message_id." as read" if $self->debug;
     }
 
     return $response;