Bug 295051 - Filters are not applied to newly received messages (IMAP)
Summary: Filters are not applied to newly received messages (IMAP)
Status: RESOLVED FIXED
Alias: None
Product: kmail2
Classification: Applications
Component: general (show other bugs)
Version: 1.99.0
Platform: Unlisted Binaries Linux
: NOR normal
Target Milestone: ---
Assignee: kdepim bugs
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-02-29 08:54 UTC by Albert Astals Cid
Modified: 2013-10-02 11:40 UTC (History)
8 users (show)

See Also:
Latest Commit:
Version Fixed In: 4.12


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Albert Astals Cid 2012-02-29 08:54:33 UTC
Version:           1.99.0 (using KDE 4.8.0) 
OS:                Linux

Seems newly received emails in IMAP accounts are not sent through the filtering agent

Reproducible: Always

Steps to Reproduce:
Have an imap account
Setup a filter
Get a new mail that matches the filter

Actual Results:  
The mail ends up in the inbox

Expected Results:  
The mail should end up in the folder i said in the filter

OS: Linux (x86_64) release 3.2.0-17-generic
Compiler: gcc
Comment 1 comet.friend 2012-04-08 10:16:15 UTC
Same here, and also with POP3, not only IMAP. Steps to reproduce are otherwise the same as for IMAP.

ALWAYS:
E. g., I want to have emails from a mailing list sorted into a dedicated local folder immediately when fetching them from my POP3 account, based on the "To:" header. However, the files are left in inbox.

SOMETIMES:
Also annoying: Sometimes the filter refuses to work, when I select multiple emails. Then I have to apply it on all relevant messages one-by-one, which is no better than just moving them to the target folder manually. Not sure, yet, how to reliably reproduce this.

With the above deficiencies, filters are practically useless, currently. So I hope for a fix in one of the next versions!

Best regards

  Alex
Comment 2 Neil Skrypuch 2012-05-30 04:10:38 UTC
I can confirm this (for IMAP, POP untested) with KDE 4.8.1. Filters are not applied to incoming mail, new mail is always left in inbox. The filter itself works properly, if I manually select the mail and apply all filters, it ends up where it should be.
Comment 3 PhobosK 2012-06-25 21:17:06 UTC
I confirm it on KDE 4.8.4 (Ubuntu).
What happens is that after every change of any filter a restart of Akonadi is needed in order the filters to start working.
So a kinda workaround is to:
1. Change/add the filter
2. Close KMail
3. Restart Akonadi (through Akonadi Tray for example)
4. Open KMail
5. When new mail arrives, filters work
I guess it is some kinda problem of the Mail Filter Agent informing Akonadi for the changes
Comment 4 Neil Skrypuch 2012-06-25 23:06:48 UTC
It's not quite that simple, I was seeing no filters being applied initially. Since then, I've completely closed and reopened Kmail, and I started seeing filters being applied. However, right now I'm seeing filters being applied to *some* incoming mail but not *all* of it.

For example, right now I'm subscribed to the wine-patches mailing list (in digest form), and I see volume 83, issue 179, 180 and 182-189 in my wine-patches folder, but issue 181 is still in my inbox. If I apply the filter manually to issue 181, it will get moved into wine-patches as I would expect. This has happened a few times in the past, but I haven't found a pattern yet.
Comment 5 Lari Natri 2012-09-14 12:27:38 UTC
For me, automatic applying of filters used to work in KDE 4.8.x, but since upgrading to KDE 4.9.0 and 4.9.1, the filters do not get applied automatically. Manual applying  (Ctrl-J) works.
Comment 6 Lari Natri 2012-10-12 11:44:16 UTC
The problem seems to exist only when filtering by List-id (possibly others, haven't tried them all). To, from and subject filters get applied automatically without problem. List-id filters work only when applied manually.
Comment 7 Jacopo De Simoi 2013-09-26 02:16:08 UTC
The problem also arises with the Delivered-To field
Comment 8 Daniel Vrátil 2013-09-30 17:38:51 UTC
wilder on IRC discovered that the problem is, that the IMAP resource fetches only very limited subset of headers (To, From, Message-Id, References, In-Reply-To, Subject and Date), so filters using other headers than these won't work.

Patch is already on reviewboard, but will be available in 4.12 due to new API.

As a workaround, you can enable disconnected IMAP, which will fetch the entire message with all headers.
Comment 9 Jacopo De Simoi 2013-09-30 22:08:19 UTC
yay, patch on reviewboard, can you give us a link? I can't find it apparently.

And sorry for disappearing from IRC earlier. Had to run to a seminar
Comment 10 Daniel Vrátil 2013-10-01 09:19:09 UTC
First part of the patch for KIMAP: https://git.reviewboard.kde.org/r/113010/ 
Second part will be for then IMAP resource to use the new flag introduced in the first part.

(the review does not work right now due to some problems with reviewboard, so try later)
Comment 11 Daniel Vrátil 2013-10-02 11:31:01 UTC
Git commit bf16f7d21d9af28e2269d8812956c2610d84fc5a by Dan Vrátil.
Committed on 02/10/2013 at 11:28.
Pushed by dvratil into branch 'master'.

Add FullHeaders scope to KIMAP::FetchJob

The Header scope fetches only a limited subset of mail headers, but
Sometimes we need to fetch all mail headers, and that's what FullHeaders
scope does.

REVIEW: 113010

M  +1    -1    CMakeLists.txt
M  +6    -1    kimap/fetchjob.cpp
M  +11   -1    kimap/fetchjob.h
M  +11   -0    kimap/tests/fetchjobtest.cpp

http://commits.kde.org/kdepimlibs/bf16f7d21d9af28e2269d8812956c2610d84fc5a
Comment 12 Daniel Vrátil 2013-10-02 11:40:43 UTC
Git commit f8fca7759e548cf9fa3acea3a13ba4810b0f0ca3 by Dan Vrátil.
Committed on 02/10/2013 at 11:38.
Pushed by dvratil into branch 'master'.

Fetch full mail headers when not using disconnected IMAP

Using Headers scope will fetch only limited subset of mail headers, which
means that filters using headers not included in this set (like List-Id)
won't work, until the message is opened in KMail and full body is fetched
from the server.

Fetching all mail headers during RetrieveItemsTask will download slightly
more data, on the other hand we get perfectly working mail filters.
FIXED-IN: 4.12

M  +1    -1    CMakeLists.txt
M  +1    -1    resources/imap/retrieveitemstask.cpp
M  +2    -2    resources/imap/tests/testretrieveitemstask.cpp

http://commits.kde.org/kdepim-runtime/f8fca7759e548cf9fa3acea3a13ba4810b0f0ca3