mail-listener2 icon indicating copy to clipboard operation
mail-listener2 copied to clipboard

How can i delete every email i fetch?

Open gerbil opened this issue 10 years ago • 7 comments
trafficstars

Right now the only option is to set them as SEEN, but i want to flag them as deleted.

gerbil avatar Mar 12 '15 14:03 gerbil

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); });

gerbil avatar Mar 12 '15 14:03 gerbil

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.

chirag04 avatar Mar 12 '15 14:03 chirag04

+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.

Penagwin avatar Apr 13 '15 13:04 Penagwin

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 .

sergio773 avatar Mar 27 '17 13:03 sergio773

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. :-)

Octopus134 avatar Aug 30 '17 21:08 Octopus134

works perfectly :)

giladg1 avatar Jul 25 '18 11:07 giladg1

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

cid333 avatar Aug 25 '21 10:08 cid333