-
Notifications
You must be signed in to change notification settings - Fork 48
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
The proper way to delete mails? #236
Comments
Yes, |
Thanks for such a quick reply. I don't think my IMAP server automatically does this (though there's a command at my client, alpine, to "purge")
I suppose that's another good reason for a dedicated command (could be equivalent of rm or even xargs for mails): ensure one message per-line and have a safety check that the filename (and possibly first block of content) looks like a mail message. In the spirit of community, shall I see if I can patch the docs so people don't need to ask again. The existing example:
there's no consideration for pathnames with spaces. So should I just follow in the spirit of it being an example, with a simple xargs again:
Because the full example gets cluttered and is probably only moving the goalposts: `mlist ~/Maildir | mpick -t 'mtime < "-365d"' | xargs -d '\n' -r rm |
You may like my other project https://github.com/leahneukirchen/xe/ which is xargs with reasonable defaults. ;) |
I'll add an |
Brilliant! I was thinking exactly that as I wrote the previous message. |
To give you another idea on how to do it, I wrote a script to automatically move old mails to an "ARCHIVE" mailbox which isn't synced back to the server. This way I don't clutter my inbox while still being able to read them later if needed to. #!/bin/sh
MAILACC="${1}"
MAILINBOX="${HOME}/usr/mls/${MAILACC}/INBOX"
MAILARCHIVE="${HOME}/usr/mls/${MAILACC}/ARCHIVE"
MAILYEAR=$(echo "$(date +%Y) -2" | bc -s)
test -d "${MAILINBOX}" || exit 1
! test -d "${MAILARCHIVE}" && mmkdir "${MAILARCHIVE}"
printf 'Searching for messages older than %s-01-01\n' "${MAILYEAR}"
ml=$(mlist "${MAILINBOX}" | mpick -t 'date <= "'"${MAILYEAR}"'-01-01"' | msort -d)
test -n "${ml}" || { printf 'Nothing found!\n'; exit; }
printf 'Archiving %s messages\n' $(printf '%s\n' "${ml}" | wc -l)
printf '%s\n' "${ml}" | mrefile "${MAILARCHIVE}"
printf 'Creating inbox sequence\n'
mlist "${MAILINBOX}" | msort -r -d > "${HOME}/usr/mls/${MAILACC}/inbox.seq"
printf 'Creating archive sequence\n'
mlist "${MAILARCHIVE}" | msort -r -d > "${HOME}/usr/mls/${MAILACC}/archive.seq" |
I'm very pleased to have discovered mblaze, thank you.
I'd like to automate deletion of some old mails, but no such example is given in the docs.
If this is as simple as "xargs rm", or should it be "mflag -T"?
If I use the latter, is there an mblaze command to actually delete "trashed" mails?
Just a single example of the best practice in the docs would help.
I'm not saying a specific blaze command is needed, but one could have some safety checks. Waving "xargs rm" around makes me nervous...
In my cases, mails are served from Dovecot which keeps its own index, and therefore I'm assuming it's its own responsibility to deal with changes to the underlying Maildir.
The text was updated successfully, but these errors were encountered: