mail-listener2
mail-listener2 copied to clipboard
How can i delete every email i fetch?
Right now the only option is to set them as SEEN, but i want to flag them as deleted.
I think i've found a way to do it: add this one after line 127 of index.js ->
self.imap.setFlags(result, 'Deleted', function(err) { console.log(err); });
I would let this be open and wait for more feedback. If more people +1 this i would add this feature.
I'm personally -1 on giving markDeleted as a global option. Use self.imap instance to do that for every mail you want to delete.
+1 I needed it a moment ago.
EDIT: Having it in the docs would still be nice, but I understand it is from a different library.
You can flag it as deleted like this:
this.mailListener.imap.seq.setFlags(seqno, ['\\Deleted', '\\Seen'], function(err) { if(err) { console.error(err); } } );
Be careful the function setFlags overrides all previous set flags .
the solution of sergio773 solution helps me very much (in my protractor-tests): the mail is marked as deleted. But as I still found it in the Inbox, I looked further on and found out, that I have to use the command expunge too.
So I have to add
mailListener.imap.expunge ( function (err) { if (err) { console.error(err); } });
After this the mail is gone.
:-)
works perfectly :)
hi, I'm able to delete an email (after parsing it) with setflag and expunge, but then maillistener will only notify me that a new mail exists and is recent (and so on for new ones) from debug <= '* 1 EXISTS' <= '* 1 RECENT'
it's like the maillistener.on('mail') is not ever being called again.. anyone had this problem?
(context: what im trying to achieve is a node app that stai connected to the mail server, fetch new mail, save em as file and delete them from server)
theanks in advance