mail-received hook only triggers for active account

Hi, thanks for this awesome software.
I encounter a trouble.
I've enabled a trigger for new mail :

new-email=exec notify-send "New email from %n" "%s"

activated a duration between check in all my accounts :

check-mail = 10m

aerc works fine and notifies me for new mail, but only for the current displayed account tab.

All my accounts are standard imaps mailboxes (dovecot server).

Is there a way to force it to check and notify incoming emails of all mailboxes ?



Assigned to
1 year, 3 months ago
10 months ago

~rjarry 11 months ago

Note: this may be cumbersome and/or impossible to implement. We would need one IMAP connection per watched mailbox. Some servers limit the number of active connections.

~jpfox 11 months ago

Some servers limit the number of active connections.

my mailboxes are on different servers ;-)

~rjarry 11 months ago

My bad, I thought you wanted notifications for every mailbox of a single account. In that case, did you try the latest master? I don't see what could prevent notifications from being sent for all accounts regardless of which tab is selected.

Unfortunately, I cannot test since I have no imap server that reports the \recent flag.

~jpfox 11 months ago*

I use Archlinux package (0.15.1). Should it work on this version ?

notifications work only on the currently displayed account.

And when I switch to another account tab (Ctrl+N), I get a notification for this account if there are unread mails. (check-mail = 10m is set for all my accounts)

~rjarry 11 months ago

I have read the code extensively and can finally explain why the notifications only fire for the selected account.

  1. An IMAP IDLE command is running and the server notifies that there is a new message in the selected mailbox.
  2. Aerc performs a CheckMail action on the selected mailbox only.
  3. CheckMail triggers a FetchDirectoryContents action.
  4. FetchDirectoryContents returns the list of message UIDs for the selected mailbox to the UI message store. At that point, the message store contains a new UID for which it does not have headers nor flags.
  5. When the message list is redrawn, every visible message UID is listed and if it does not have any associated header info, a FetchHeaders action is posted to the IMAP backend.
  6. The IMAP backend sends a request to the server and returns the missing message headers to the UI message store.
  7. When the message store receives headers, for each message that has the recent and unread flags, the mail-received hook is triggered.

None of the steps starting from 5. will occur unless the message list tab of that account is selected and therefore redrawn.

Changing this behaviour would require tracking what messages are visible to avoid fetching headers for every UID in the message store if they are not displayed (mailboxes can be quite large). And then, move the FetchHeaders action directly into the message store, upon FetchDirectoryContents response if UIDs would be displayed.

~jpfox 11 months ago

OK ~rjarry I see you got the problem !

It seems to break many things to get it working.

Maybe, the notification system should be moved to a completely different part of the code and manage its own list of knows messages (or last known ID). I don't know if it is possible ??

Many thanks to have had a look to it.

~jpfox 11 months ago

Do you need a temporary mailbox on a dovecot IMAP server to do some test ? Let me know by email : jp at f0x dot fr

~rjarry 11 months ago

The extent of changes is not that big. I think it should be easy to incorporate the "visible UIDs" into the message store to allow fetching headers in the background. From a design point of view, it would be better than rely on the UI to ask for backend updates when drawing. I will have a look soon-ish.

No need for a test server. I managed to do that with fastmail IMAP. Thanks though :)

~rjarry 11 months ago

I just sent a patch for you to test: https://lists.sr.ht/~rjarry/aerc-devel/patches/42733

~jpfox 11 months ago

Ok Robin, I've applied these both patches to the master branch and rebuild. I've changed the mail-received=notify-send line in my aerc.conf. However, it always works as previously: notifications display only for current displayed account. Notification arrives when I switch to the concerned account with Ctrl+N

Patch is applied correctly because notification message is ok with account and folder name.

sorry, something is missing to correct the problem.

~rjarry 11 months ago

Can you copy your message as a reply to the patch on the mailing list? It will be better to have a discussion there.


~rjarry REPORTED FIXED 10 months ago

Robin Jarry referenced this ticket in commit 24eab0f.

Register here or Log in to comment, or comment via email.