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

Moving mails tagged as deleted #309

Open
vikasrawal opened this issue Sep 26, 2021 · 9 comments
Open

Moving mails tagged as deleted #309

vikasrawal opened this issue Sep 26, 2021 · 9 comments

Comments

@vikasrawal
Copy link

I use mbsync to sync emails, and afew is used to move mails tagged as "deleted" to the Trash folders. But this seems to create the problem that mbsync does not correctly identify mails and propagate mail deletion.

Is this a known problem? Should I not use afew to deal with deleted mails?

@mjg
Copy link
Contributor

mjg commented Oct 22, 2021

Can you describe in more detail what you expect to happen and what in fact does happen when you move your (per tag) deleted mail with afew and sync it with mbsync?

@GuillaumeSeren
Copy link
Collaborator

Hey,
what I do is a custom query with xarg like this (probably stolen from arch wiki https://wiki.archlinux.org/title/Notmuch#Permanently_delete_emails)

notmuch search --output=files --format=text0 --limit=1 date:..1Y and not tag:unread and not tag:inbox and not tag:to-me and not tag:flagged and not tag:replied | xargs -0 rm

@mjg
Copy link
Contributor

mjg commented Oct 24, 2021

@GuillaumeSeren sure, that's how you delete locally in a notmuch set-up. Alternatively, have "afew" move those files to a folder where the server deletes them after some time.

I understood @vikasrawal 's question differently, as if afew's move would clear a trash flag or such. notmuch syncs some maildir flags with tags but explicitely excludes the trash flag. mbsync syncs the flags, but the exact handling depends on a couple of mbsync config choices.

@anarcat
Copy link
Contributor

anarcat commented Nov 22, 2021

I use mbsync to sync emails, and afew is used to move mails tagged as "deleted" to the Trash folders. But this seems to create the problem that mbsync does not correctly identify mails and propagate mail deletion.

is it possible that you forgot the "rename" option to the move plugin?

@ecocode
Copy link

ecocode commented May 27, 2022

Is it even possible to move all mail tagged "deleted" to a Trash folder? As I understand from the docs, you would need to setup a rule for every single maildir.. I happen to have 1000+ maildirs, so that is kind of unusable ;)

@GuillaumeSeren
Copy link
Collaborator

Hello,
sorry for the delay.

In afew, you can tag / move mails (see https://afew.readthedocs.io/en/latest/move_mode.html?highlight=mailmover#configuration-section),
but afew does talk directly to the imap server this usually done with mbsync or other sync tool.

So here to propagate a mail deletion, you just delete the file and then sync again (mbsync).

@mjg
Copy link
Contributor

mjg commented May 30, 2022

Hello, sorry for the delay.

In afew, you can tag / move mails (see https://afew.readthedocs.io/en/latest/move_mode.html?highlight=mailmover#configuration-section), but afew does talk directly to the imap server this usually done with mbsync or other sync tool.

So here to propagate a mail deletion, you just delete the file and then sync again (mbsync).

Yes, that's when you delete them locally using notmuch/xarg/rm.

An alternative would be moving them to a trash/30dtrash folder and let the imap server do the purging. And this is where @ecocode 's question comes in: Is it possible to move all mail tagged trash to a trash folder, using afew? And the answer is "no" (unless you set up config for all folders).

But I think for this and similar purposes it would be beneficial to have a "slow/manual" mode of the mover, something like:

afew -M <folder> <query>

which moves all mail matching <query> to <folder>. afew has all the logic already (searching, file renaming, moving). This mode can be slow depending on the scope of the query but would cover the mentioned use case as well as all cases where you do a one-off reorganisation of your local mail store (to be synced up in a follow-up step).

@ecocode
Copy link

ecocode commented May 30, 2022 via email

@GuillaumeSeren
Copy link
Collaborator

GuillaumeSeren commented May 30, 2022

Hey,

Is it possible to move all mail tagged trash to a trash folder, using afew? And the answer is "no" (unless you set up config for all folders).

Yes but that would be a nice optimisation of the move filter.

if you consider a small config like:

MyMail/INBOX = 'tag:spam':MyMail/spam 'tag:sent':MyMail/sent 'not tag:inbox':MyMail/archive 'tag:trash':MyMail/trash
MyMail/archive = 'tag:inbox':MyMail/INBOX 'tag:spam':MyMail/spam 'tag:sent':MyMail/sent 'tag:trash':MyMail/trash
MyMail/spam = 'NOT tag:spam':MyMail/INBOX 'tag:sent':MyMail/sent 'tag:trash':MyMail/trash
MyMail/sent = 'NOT tag:sent':MyMail/INBOX 'tag:spam':MyMail/spam 'tag:trash':MyMail/trash
MyMail/trash = 'tag:inbox':MyMail/INBOX 'tag:spam and not tag:trash':MyMail/spam 'tag:sent and not tag:trash':MyMail/sent

Would become

MyMail/* = 'tag:spam':MyMail/spam 'tag:sent':MyMail/sent 'not tag:inbox':MyMail/archive 'tag:trash':MyMail/trash
MyMail/archive = 'tag:inbox':MyMail/INBOX
MyMail/spam = 'NOT tag:spam':MyMail/INBOX
MyMail/sent = 'NOT tag:sent':MyMail/INBOX
MyMail/trash = 'tag:spam and not tag:trash':MyMail/spam 'tag:sent and not tag:trash':MyMail/sent

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

5 participants