I am missing a real "New Mail" mail session/folder event



11 years ago
7 years ago


(Reporter: Keno Albrecht, Unassigned)


Firefox Tracking Flags

(Not tracked)




11 years ago
User-Agent:       Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv: Gecko/20061204 Firefox/
Build Identifier: version (20061207)

I am the maintainer of the Spamato spam filter extension. As I have to check incoming emails to detect spam messages, it is necessary to be notified about such events. However, there is just no event that really works!

WHAT I WANT: A "New Mail" event that is triggered exactly once for each incoming email and has the new email as a parameter. It would also be great to know whether the email has already been downloaded and stored on disk or not. So a second parameter might be necessary. In this case, it is ok two fire the event twice, once for "new mail detected" and once for "new mail completely downloaded."

Note that this is almost similar to what the OnItemAdded event is doing. However, as I have explained in more detail in the mozilla.dev.extensions newsgroup:


there are many problems with this event. For instance, the OnItemAdded event is also fired when a mail-thread is update, which is very ugly. And sometimes it is not fired at all (I suppose this is another bug by the way...).

So all I'm asking for is an event that works correctly :-)!


Reproducible: Always

Expected Results:  
Fire "OnNewMailArrived" with parameters "newMail" (nsIMsgDBHdr) and boolean "complete" (mainly for IMAP/POP with "headers only": false if mail has not been downloaded yet, true if stored on disk).

I'm working on Windows XP but think this is a general problem. I've also tested the OnItemAdded issues on TB 2.0b1 with similar results.


11 years ago
Version: unspecified → 1.5

Comment 1

11 years ago
see https://bugzilla.mozilla.org/attachment.cgi?id=251119 in bug 290057

Comment 2

11 years ago
Looks very interesting (although not completely what I was looking for), would like to test it. Is it part of TB 2.0b1?

Comment 3

11 years ago
no, it hasn't been checked in anywhere yet. I'm hoping to get it into beta2

I believe you would just want the deal with the itemAdded notifications, QI the item to make sure it's an nsIMsgDBHdr, and go from there. It should only get called when new headers are added to a db from a mail server, but not by a move. (except IMAP is always special, since we don't know why a new header shows up in an IMAP folder). Checking the "new" flag on the header should also tell you if this is a newly arrived message.

Comment 4

11 years ago
Have you been able to put it into beta2?

Comment 5

11 years ago
Yes, I think it was in beta 2. It's in 2.0 nightly builds for sure.

Comment 6

11 years ago
OK, thanks. I'll give it a try and report back.

Comment 7

11 years ago
I found some time to try it out -- and it works great :-)! I have used the following code to receive "added" events (just for the record):


var myMsgFolderListener = {
  itemAdded: function(item) { 
    if (item instanceof Components.interfaces.nsIMsgDBHdr) {
      if (isMessageNew(item)) {
  itemDeleted: function(item) {},
  itemMoveCopyCompleted: function(isMove,srcItems,destFolder) {},
  folderRenamed: function(origFolder,newFolder) {},
  itemEvent: function(item,event,data) {}

try {
  var msgFolderNotificationService = Components.classes["@mozilla.org/messenger/msgnotificationservice;1"].getService(Components.interfaces.nsIMsgFolderNotificationService);
} catch (ex) {


Is there any reason why the service is not at @mozilla.org/messenger/services/...?

Thanks for the new event :-).


9 years ago
Assignee: mscott → nobody

Comment 8

7 years ago
> I found some time to try it out -- and it works great 

=> WFM per reporter
Last Resolved: 7 years ago
Resolution: --- → WORKSFORME
You need to log in before you can comment on or make changes to this bug.