nicm / fdm

fdm source code
268 stars 50 forks source link

Fetching only new mail #80

Closed salotz closed 4 years ago

salotz commented 4 years ago

I'm trying to run both a task that only fetches the new mail (via cron every 15 minutes) like:

fdm -kv -a account@example.com_new fetch

And one for all the mail every night:

fdm -kv -a account@example.com fetch

The problem is that the only solution I could come up with uses separate accounts using the new-only option e.g.:

account "account@example.com_new"
imaps server "mail.example.com"
port 993
user "user"
pass ...
new-only

This has the effect of giving my duplicate mail because the "Received: " header is different:

  --> diff 1593148327.17714_0.ostrich 1593135907.18272_0.ostrich

  3,4c3,4
  < Received: by ostrich (fdm 1.7, account "account@example.com");
  <     Fri, 26 Jun 2020 01:12:07 -0400
  ---
  > Received: by ostrich (fdm 1.7, account "account@example.com_new");
  >     Thu, 25 Jun 2020 21:45:07 -0400

What can I do?

I'm assuming there is a more elegant way to do this but after reading the man page I couldn't find it.

nicm commented 4 years ago

If you get rid of duplicates won't the "all mail" fetch get no mail because the new-only fetch will get it all?

You can use the no-received option so fdm doesn't add a Received header.

Or use a cache with the message ID to make fdm ignore duplicate mails.

salotz commented 4 years ago

If you get rid of duplicates won't the "all mail" fetch get no mail because the new-only fetch will get it all?

I use other clients that mark things as read and so the 'new-only' won't get those (at least it looked like this was happening, not an expert in IMAP). The "all mail" fetch is for backups so I want to make sure I get those.

You can use the no-received option so fdm doesn't add a Received header.

That works thanks. Ya the cache prolly would work but I couldn't wrap my head around it.