nicm / fdm

fdm source code
269 stars 50 forks source link

deleting messages from server #73

Closed daphniz closed 4 years ago

daphniz commented 4 years ago

sorry if i missed it, but i couldn't find any information about this in the documentation. i would like to keep messages on the server for a while, say 14 days, and then delete them. this will ensure that i will have made a backup of my local files in the meantime.

there was an option for this in getmail, but here there doesn't seem to be any way of doing it. it seems that, unless the -k flag is passed to fdm, messages are immediately deleted from the server after having been (matched and) fetched. or?

nicm commented 4 years ago

You can use the age condition. You will need a cache file to avoid delivering messages multiple times.

On Sat, 14 Dec 2019, 21:34 D, notifications@github.com wrote:

Reopened #73 https://github.com/nicm/fdm/issues/73.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/nicm/fdm/issues/73?email_source=notifications&email_token=AACKI44RRPHCZWWZZCUAJTLQYVGPJA5CNFSM4J24ADLKYY3PNVWWK3TUL52HS4DFWZEXG43VMVCXMZLOORHG65DJMZUWGYLUNFXW5KTDN5WW2ZLOORPWSZGOVPQJOOA#event-2883622712, or unsubscribe https://github.com/notifications/unsubscribe-auth/AACKI43ZXPZA3FANPFCBFETQYVGPJANCNFSM4J24ADLA .

daphniz commented 4 years ago

does cache work with imap?

nicm commented 4 years ago

It works the same no matter where the mail is fetched from.

On Sat, 14 Dec 2019, 22:38 D, notifications@github.com wrote:

does cache work with imap?

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/nicm/fdm/issues/73?email_source=notifications&email_token=AACKI44X5KZUEYAHJQ2NASDQYVN6PA5CNFSM4J24ADLKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEG4M2GI#issuecomment-565759257, or unsubscribe https://github.com/notifications/unsubscribe-auth/AACKI45RY4F5OFB7YK7WXZDQYVN6PANCNFSM4J24ADLA .

daphniz commented 4 years ago

i did a dirty thing, i made a separate account identical with the normal, except with only-old instead of only-new and disabled it. and then i used

age > %keepdays days action drop

so now i can explicitly purge old msgg from the server every now and then; but this isn't exacly ideal.

daphniz commented 4 years ago

ok, i got the impression from the man page that caching only worked with pop

nicm commented 4 years ago

It will still download the mails of course but you can make it keep them if they age < 30 days and not deliver them if their ID is in the cache file.

On Sat, 14 Dec 2019, 22:39 Nicholas Marriott, nicholas.marriott@gmail.com wrote:

It works the same no matter where the mail is fetched from.

On Sat, 14 Dec 2019, 22:38 D, notifications@github.com wrote:

does cache work with imap?

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/nicm/fdm/issues/73?email_source=notifications&email_token=AACKI44X5KZUEYAHJQ2NASDQYVN6PA5CNFSM4J24ADLKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEG4M2GI#issuecomment-565759257, or unsubscribe https://github.com/notifications/unsubscribe-auth/AACKI45RY4F5OFB7YK7WXZDQYVN6PANCNFSM4J24ADLA .

nicm commented 4 years ago

POP3 requires a cache to do new-only because it has no seen flag, but that is different, you can use add-to-cache/in-cache.

Personally I would keep everything and delete old messages as a separate step every week or month.

On Sat, 14 Dec 2019, 22:44 D, notifications@github.com wrote:

ok, i got the impression from the man page that caching only worked with pop

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/nicm/fdm/issues/73?email_source=notifications&email_token=AACKI42PQLP2GK75VWOYRBLQYVOT5A5CNFSM4J24ADLKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEG4M4YA#issuecomment-565759584, or unsubscribe https://github.com/notifications/unsubscribe-auth/AACKI47FJIDY54EAXHHMLN3QYVOT5ANCNFSM4J24ADLA .

daphniz commented 4 years ago

i see. but how do i get the message id?

nicm commented 4 years ago

Look at MANUAL file there is an example.

On Sat, 14 Dec 2019, 23:20 D, notifications@github.com wrote:

i see. but how do i get the message id?

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/nicm/fdm/issues/73?email_source=notifications&email_token=AACKI474HLILQNSJUVUXMELQYVS25A5CNFSM4J24ADLKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEG4NNPY#issuecomment-565761727, or unsubscribe https://github.com/notifications/unsubscribe-auth/AACKI42IYXGBWAQO3LK3N7LQYVS25ANCNFSM4J24ADLA .

daphniz commented 4 years ago

this doesn't seem to be a very good solution, since some messages have no id. also, doesn't fdm have to download the messages first to check their id?

the solution i mentioned about works, but i wish i didn't have to define the same account twice.

daphniz commented 4 years ago

something like getmail's delete_after option would be ideal.

nicm commented 4 years ago

All email messages have a message ID. It doesn't have to download them twice, it has to download them every time you run it, but that is what fdm does, it is a mail fetch program - it does not process them on the server.

On Sun, 15 Dec 2019, 00:32 D, notifications@github.com wrote:

this doesn't seem to be a very good solution, since some messages have no id. also, doesn't fdm have to download the messages first to check their id?

the solution i mentioned about works, but i wish i didn't have to define the same account twice.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/nicm/fdm/issues/73?email_source=notifications&email_token=AACKI42LGYJ2TQMOLO43A7TQYV3JLA5CNFSM4J24ADLKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEG4OM7I#issuecomment-565765757, or unsubscribe https://github.com/notifications/unsubscribe-auth/AACKI4ZBB46BBEVITXPHBQ3QYV3JLANCNFSM4J24ADLA .

daphniz commented 4 years ago

but some have a msg id = "", right? i tried "keeping" all msgg with non-empty ids whose id were already in the cache, but there was one message with no id in the header, which reappeared in my spool every time i ran fdm.

i don't know how only-new works, or getmail's delete_after, but it would seem that something there could be exploited.

nicm commented 4 years ago

Hmm valid emails should have Message-ID header, are you sure it has none at all? Is it spam?

On Sun, 15 Dec 2019, 07:34 D, notifications@github.com wrote:

but some have a msg id = "", right? i tried "keeping" all msgg with non-empty ids whose id were already in the cache, but there was one message with no id in the header, which reappeared in my spool every time i ran fdm.

i don't know how only-new works, or getmail's delete_after, but it would seem that something there could be exploited.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/nicm/fdm/issues/73?email_source=notifications&email_token=AACKI46M4XSMY2YMZBITRWLQYXMY3A5CNFSM4J24ADLKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEG4TFNY#issuecomment-565785271, or unsubscribe https://github.com/notifications/unsubscribe-auth/AACKI46SWGWFQ7JQ5FF4ZG3QYXMY3ANCNFSM4J24ADLA .

daphniz commented 4 years ago

it's a ticket receipt from a metro company.

nicm commented 4 years ago

You could maybe use imap_uid or if you are using Gmail gmail_msgid as well or instead of the message ID.

On Sun, 15 Dec 2019, 07:48 D, notifications@github.com wrote:

it's a ticket receipt from a metro company.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/nicm/fdm/issues/73?email_source=notifications&email_token=AACKI46ANTMXVY3ESVXNAULQYXOM3A5CNFSM4J24ADLKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEG4TLYA#issuecomment-565786080, or unsubscribe https://github.com/notifications/unsubscribe-auth/AACKI46XKBWO47EGSBWYW6LQYXOM3ANCNFSM4J24ADLA .

daphniz commented 4 years ago

all right. this is what i do now. it doesn't have the disadvantage of having to fetch everything every time, but my ocd doesn't like the duplication of account information.

    set unmatched-mail keep

    $base = "%h/mail"
    $eo = "${base}/pr"

    # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #

    action "sus" { maildir "${eo}/sus" keep }

    account "#####"
    imaps server "#####.###"
    user "#####@#####.###"
    pass $(pass #####.###/#####)
    new-only

    match   account "#####" {
    match   "^To:.*#####@#####.###" in headers
            action { maildir "${eo}/dap" keep } 
    match   attachment any-type "text/html" and not
            attachment any-type "text/plain"
            action "sus"
    match   all action { maildir "${eo}/spool" keep }
    }

    # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #

    %keepdays = 14

    account "#####-purge" disabled
    imaps server "#####.###"
    user "#####@#####.###"
    pass $(pass #####.###/#####)
    old-only

    match   account "#####-purge" and
    age > %keepdays days action drop

are you in princple against something like getmail's delete_after?

daphniz commented 4 years ago

i have assumed that only-new doesn't actually download old messages. is that right?
if not --if you have to download to check--, would it be possible to have old condition for use in rules? you could then process the new and delete the old, if sufficiently old.

nicm commented 4 years ago

new-only only checks the seen flag, for actual age I think you would need to either fetch the header or do a search, although I can't remember there might ev another way. I don't have any plans to do it however.

On Mon, 16 Dec 2019, 08:37 D, notifications@github.com wrote:

i have assumed that only-new doesn't actually download old messages. is that right? if not --if you have to download to check--, would it be possible to have old condition for use in rules? you could then process the new and delete the old, if sufficiently old.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/nicm/fdm/issues/73?email_source=notifications&email_token=AACKI46QUGU5S6N6CY4QPVTQY443DA5CNFSM4J24ADLKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEG55XQI#issuecomment-565959617, or unsubscribe https://github.com/notifications/unsubscribe-auth/AACKI4ZXT7D3TCFP6ENNLWTQY443DANCNFSM4J24ADLA .