getmail with davmail

Graham Denham <[email protected]> Fri, 5 Feb 2021 21:07:19 +0000
Newsgroups gmane.mail.getmail.user
Message-ID <[email protected]>
Dear getmail community,

I've been using getmail happily for a couple of years now in a 
single-user setup to fetch mail via IMAP from an Office 365 server, and 
then pass it to dovecot for delivery.  My various mail clients all point 
to dovecot's IMAP server.

Recently, my local O365 administrators (or Microsoft) discontinued 
password-based IMAP authentication.  So I installed davmail to provide an 
interface between Microsoft Exchange and getmail.  Now getmail maintains 
an IMAP idle connection to davmail (on the same machine) instead of with a 
Microsoft server.

Sounds straightforward, except for some unexpected behaviour.  Some emails 
get delivered twice, about a minute apart.  Other messages, when I view 
them, become "new" again after a few seconds.  Sometimes when I reply to a 
message, that message gets delivered again.

I suppose it would be helpful to have the IMAP dialogue between getmail 
and davmail, but I'm not sure how to capture that.  I thought I would 
inquire here just in case someone has come across something similar in 
configuring getmail to read from davmail.

(I might equally well ask the davmail community, of course, but if I point 
my mail client directly at the davmail IMAP service, it behaves as 
expected.)

best wishes,

/Graham Denham

log message showing message 2 getting received a second time, but not 
message 1:

Feb  4 09:10:19  getmail[7772]: IDLE message received
Feb  4 09:10:19  getmail[7772]:   msg 1/2 (9950 bytes) delivered
Feb  4 09:10:20  getmail[7772]:   msg 2/2 (13438 bytes) delivered
Feb  4 09:10:20  getmail[7772]:   2 messages (23388 bytes) retrieved, 0 skipped
Feb  4 09:11:22  getmail[7772]: IDLE message received
Feb  4 09:11:23  getmail[7772]:   msg 2/2 (13438 bytes) delivered
Feb  4 09:11:23  getmail[7772]:   1 messages (13438 bytes) retrieved, 1 skipped
Feb  4 09:16:27  getmail[7772]:   0 messages (0 bytes) retrieved, 2 skipped
Feb  4 09:17:21  getmail[7772]: IDLE message received

Contents of getmailrc follow.  Aside from dropping the SSL, the only 
change I made from my previous configuration (direct to the exchange 
server) was to add "use_peek = false" but this seemed to make no 
difference either way.

[retriever]
type = SimpleIMAPRetriever
server = localhost
port = 1143
username = [email protected]
password = ...
mailboxes = ("INBOX",)  # add more after testing
use_peek = false

[destination]
type = MDA_external
# -e: make dovecot return an error if necessary
path = /usr/lib/dovecot/deliver
arguments = ("-e",)

[options]
# retrieve only new emails
read_all = false
# delete on server after x days
delete_after = 30
# do not add a Delivered-To: header field
delivered_to = false
# do not add a Received: header field
received = false