Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FEATURE REQUEST: honor imap- and maildir-flags #133

Open
herrsimon opened this issue Oct 24, 2023 · 1 comment
Open

FEATURE REQUEST: honor imap- and maildir-flags #133

herrsimon opened this issue Oct 24, 2023 · 1 comment

Comments

@herrsimon
Copy link

First of all, thank you very much for this very nice tool, I partially replaced a combination of mbsync/maildrop with it a couple of days ago and it works like a charm, simplifying my email workflow a lot.

In the manual, an explicitly stated purpose of fdm is filtering and archiving. Here, it is a bit problematic that email delivered to maildirs is always categorized as new, without any flags. In particular, when archiving an existing maildir or filtering mailinglist-messages from the inbox to a dedicated folder, those flags will be lost, resulting in all mail to be marked as new (even though they have been read or bounced before, replied to etc.). For me, this unfortunately renders fdm unusable for this purpose, that's why I wrote “partially“ in the first paragraph. The same problem occurs when fetching mail which has been read/replied to before from an imap server.

Therefore, two feature requests:

1. Add standard flags to messages fetched from maildir or imap

When fetching from an imap or maildir source, fdm adds the flags of a message as tags flag_seen, flag_answered, flag_flagged, flag_deleted flag_draft, flag_recent, flag_passed (flag_recent is imap-specific, flag_passed maildir-specific). For reference: maildir flags (at the bottom) and imap-flags (RFC3501, Section 2.3.2).

2. Optionally honor flags when delivering to a maildir

A global configuration option honor-flags is introduced. Upon setting this option, when delivering to a maildir, fdm honors the presence (in the case of flag_recent absence) of at least one of the flag-tags described in the first feature request to decide whether to place a message into cur or new and altering the filename of the respective message to indicate the presence of the respective flags according to the specification.

@herrsimon
Copy link
Author

herrsimon commented Oct 28, 2023

In case you decide that the proposed functionality is beyond the scope of fdm (or somebody else reads this and wants to have a quick solution for the maildir-case):

How about simply adding a tag, say source_file, containing the name (including full path) of the source file when reading from a maildir? Then one could first deliver to a maildir and then use the source_file and mail_file tags to do the necessary renaming via an action.

The change to have fdm add the tag is of course trivial, one just needs to add

add_tag(&m->tags, "source_file", "%s", name);

at line 399 of fetch-maildir.c.

Then the action

action "sync_flags" exec
"FLAGS=$(perl -e '\"%[source_file]\" =~ /:2,(D?F?P?R?S?T?)$/; print $1;') ;" +
"if [ -n \"\${FLAGS}\" ] ; then " +
"mf=\"%[mail_file]\" ;" +
"mv \"\${mf}\"  \"\${mf%%/*}\"/../cur/\"\${mf##*/}:2,\${FLAGS}\" ;" +
"fi"

will do the trick (adopted from the maildir-mark-as-read-action found in EXAMPLES/f-terbeck.conf). Full flag synchronization is a bit cumbersome to configure this way and it also doesn't solve the issue when fetching from an IMAP-server, but for me it's good enough.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant