diff --git a/camel/camel-object.c b/camel/camel-object.c
index cf1e245..ede155b 100644
--- a/camel/camel-object.c
+++ b/camel/camel-object.c
@@ -224,6 +224,8 @@ object_state_read (CamelObject *object,
 
 			/* Sanity check. */
 			g_warn_if_fail (pspec->flags & CAMEL_PARAM_PERSISTENT);
+			if ((pspec->flags & CAMEL_PARAM_PERSISTENT) == 0)
+				continue;
 
 			g_object_set_property (
 				G_OBJECT (object), pspec->name, &value);
diff --git a/camel/providers/imap/camel-imap-folder.c b/camel/providers/imap/camel-imap-folder.c
index 0b19e25..d1ab781 100644
--- a/camel/providers/imap/camel-imap-folder.c
+++ b/camel/providers/imap/camel-imap-folder.c
@@ -63,7 +63,8 @@
  * It still identifies the property in state files. */
 enum {
 	PROP_0,
-	PROP_CHECK_FOLDER = 0x2500
+	PROP_CHECK_FOLDER = 0x2500,
+	PROP_APPLY_FILTERS
 };
 
 extern gint camel_application_is_exiting;
@@ -137,6 +138,30 @@ static gboolean	imap_transfer_messages		(CamelFolder *source,
 						 GCancellable *cancellable,
 						 GError **error);
 
+static gboolean
+imap_folder_get_apply_filters (CamelImapFolder *folder)
+{
+	g_return_val_if_fail (folder != NULL, FALSE);
+	g_return_val_if_fail (CAMEL_IS_IMAP_FOLDER (folder), FALSE);
+
+	return folder->priv->apply_filters;
+}
+
+static void
+imap_folder_set_apply_filters (CamelImapFolder *folder,
+			       gboolean apply_filters)
+{
+	g_return_if_fail (folder != NULL);
+	g_return_if_fail (CAMEL_IS_IMAP_FOLDER (folder));
+
+	if ((folder->priv->apply_filters ? 1 : 0) == (apply_filters ? 1 : 0))
+		return;
+
+	folder->priv->apply_filters = apply_filters;
+
+	g_object_notify (G_OBJECT (folder), "apply-filters");
+}
+
 #ifdef G_OS_WIN32
 /* The strtok() in Microsoft's C library is MT-safe (but still uses
  * only one buffer pointer per thread, but for the use of strtok_r()
@@ -159,6 +184,12 @@ imap_folder_set_property (GObject *object,
 				CAMEL_IMAP_FOLDER (object),
 				g_value_get_boolean (value));
 			return;
+
+		case PROP_APPLY_FILTERS:
+			imap_folder_set_apply_filters (
+				CAMEL_IMAP_FOLDER (object),
+				g_value_get_boolean (value));
+			return;
 	}
 
 	G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
@@ -176,6 +207,12 @@ imap_folder_get_property (GObject *object,
 				value, camel_imap_folder_get_check_folder (
 				CAMEL_IMAP_FOLDER (object)));
 			return;
+
+		case PROP_APPLY_FILTERS:
+			g_value_set_boolean (
+				value, imap_folder_get_apply_filters (
+				CAMEL_IMAP_FOLDER (object)));
+			return;
 	}
 
 	G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
@@ -308,6 +345,17 @@ camel_imap_folder_class_init (CamelImapFolderClass *class)
 			FALSE,
 			G_PARAM_READWRITE |
 			CAMEL_PARAM_PERSISTENT));
+
+	g_object_class_install_property (
+		object_class,
+		PROP_APPLY_FILTERS,
+		g_param_spec_boolean (
+			"apply-filters",
+			"Apply Filters",
+			_("Apply message filters to this folder"),
+			FALSE,
+			G_PARAM_READWRITE |
+			CAMEL_PARAM_PERSISTENT));
 }
 
 static void
@@ -375,6 +423,12 @@ camel_imap_folder_new (CamelStore *parent,
 	CamelImapFolder *imap_folder;
 	const gchar *short_name;
 	gchar *state_file, *path;
+	CamelService *service;
+	CamelSettings *settings;
+	gboolean filter_all;
+	gboolean filter_inbox;
+	gboolean filter_junk;
+	gboolean filter_junk_inbox;
 
 	if (g_mkdir_with_parents (folder_dir, S_IRWXU) != 0) {
 		g_set_error (
@@ -422,42 +476,29 @@ camel_imap_folder_new (CamelStore *parent,
 		return NULL;
 	}
 
+	service = CAMEL_SERVICE (parent);
+	settings = camel_service_get_settings (service);
+
+	g_object_get (
+		settings,
+		"filter-all", &filter_all,
+		"filter-inbox", &filter_inbox,
+		"filter-junk", &filter_junk,
+		"filter-junk-inbox", &filter_junk_inbox,
+		NULL);
+
 	if (g_ascii_strcasecmp (folder_name, "INBOX") == 0) {
-		CamelService *service;
-		CamelSettings *settings;
-		gboolean filter_inbox;
-		gboolean filter_junk;
-		gboolean filter_junk_inbox;
-
-		service = CAMEL_SERVICE (parent);
-		settings = camel_service_get_settings (service);
-
-		g_object_get (
-			settings,
-			"filter-inbox", &filter_inbox,
-			"filter-junk", &filter_junk,
-			"filter-junk-inbox", &filter_junk_inbox,
-			NULL);
-
-		if (filter_inbox)
+		if (filter_inbox || filter_all)
 			folder->folder_flags |= CAMEL_FOLDER_FILTER_RECENT;
 		if (filter_junk)
 			folder->folder_flags |= CAMEL_FOLDER_FILTER_JUNK;
 		if (filter_junk_inbox)
 			folder->folder_flags |= CAMEL_FOLDER_FILTER_JUNK;
 	} else {
-		CamelService *service;
-		CamelSettings *settings;
-		gboolean filter_junk;
-		gboolean filter_junk_inbox;
-		gboolean folder_is_junk;
-		gboolean folder_is_trash;
+		gboolean folder_is_trash, folder_is_junk;
 		gchar *junk_path;
 		gchar *trash_path;
 
-		service = CAMEL_SERVICE (parent);
-		settings = camel_service_get_settings (service);
-
 		junk_path = camel_imap_settings_dup_real_junk_path (
 			CAMEL_IMAP_SETTINGS (settings));
 
@@ -472,11 +513,6 @@ camel_imap_folder_new (CamelStore *parent,
 		if (trash_path == NULL)
 			trash_path = g_strdup ("");
 
-		filter_junk = camel_imap_settings_get_filter_junk (
-			CAMEL_IMAP_SETTINGS (settings));
-		filter_junk_inbox = camel_imap_settings_get_filter_junk_inbox (
-			CAMEL_IMAP_SETTINGS (settings));
-
 		if (filter_junk && !filter_junk_inbox)
 			folder->folder_flags |= CAMEL_FOLDER_FILTER_JUNK;
 
@@ -494,6 +530,9 @@ camel_imap_folder_new (CamelStore *parent,
 		if (folder_is_junk)
 			folder->folder_flags |= CAMEL_FOLDER_IS_JUNK;
 
+		if (filter_all || imap_folder_get_apply_filters (imap_folder))
+			folder->folder_flags |= CAMEL_FOLDER_FILTER_RECENT;
+
 		g_free (junk_path);
 		g_free (trash_path);
 	}
diff --git a/camel/providers/imap/camel-imap-private.h b/camel/providers/imap/camel-imap-private.h
index 8b485c3..a9710e8 100644
--- a/camel/providers/imap/camel-imap-private.h
+++ b/camel/providers/imap/camel-imap-private.h
@@ -15,6 +15,7 @@ struct _CamelImapFolderPrivate {
 	GStaticRecMutex cache_lock;	/* for locking the cache object */
 	GHashTable *ignore_recent;	/* hash table of UIDs to ignore as recent when updating folder */
 	gboolean check_folder;		/* persistent property */
+	gboolean apply_filters;		/* persistent property */
 };
 
 #define CAMEL_IMAP_FOLDER_LOCK(f, l) \
diff --git a/camel/providers/imap/camel-imap-provider.c b/camel/providers/imap/camel-imap-provider.c
index a1d0cc2..d2a3187 100644
--- a/camel/providers/imap/camel-imap-provider.c
+++ b/camel/providers/imap/camel-imap-provider.c
@@ -62,7 +62,9 @@ static CamelProviderConfEntry imap_conf_entries[] = {
 	  N_("Names_pace:") },
 	{ CAMEL_PROVIDER_CONF_SECTION_END },
 	{ CAMEL_PROVIDER_CONF_SECTION_START, "general", NULL, N_("Options") },
-	{ CAMEL_PROVIDER_CONF_CHECKBOX, "filter-inbox", NULL,
+	{ CAMEL_PROVIDER_CONF_CHECKBOX, "filter-all", NULL,
+	  N_("Apply _filters to new messages in all folders"), "0" },
+	{ CAMEL_PROVIDER_CONF_CHECKBOX, "filter-inbox", "!filter-all",
 	  N_("_Apply filters to new messages in Inbox on this server"), "1" },
 	{ CAMEL_PROVIDER_CONF_CHECKBOX, "filter-junk", NULL,
 	  N_("Check new messages for Jun_k contents"), "0" },
diff --git a/camel/providers/imap/camel-imap-settings.c b/camel/providers/imap/camel-imap-settings.c
index 3b6a3fe..5fd7a4b 100644
--- a/camel/providers/imap/camel-imap-settings.c
+++ b/camel/providers/imap/camel-imap-settings.c
@@ -32,6 +32,7 @@ struct _CamelImapSettingsPrivate {
 
 	gboolean check_all;
 	gboolean check_subscribed;
+	gboolean filter_all;
 	gboolean filter_junk;
 	gboolean filter_junk_inbox;
 	gboolean use_namespace;
@@ -50,6 +51,7 @@ enum {
 	PROP_CHECK_SUBSCRIBED,
 	PROP_FETCH_HEADERS,
 	PROP_FETCH_HEADERS_EXTRA,
+	PROP_FILTER_ALL,
 	PROP_FILTER_JUNK,
 	PROP_FILTER_JUNK_INBOX,
 	PROP_HOST,
@@ -111,6 +113,12 @@ imap_settings_set_property (GObject *object,
 				g_value_get_boxed (value));
 			return;
 
+		case PROP_FILTER_ALL:
+			camel_imap_settings_set_filter_all (
+				CAMEL_IMAP_SETTINGS (object),
+				g_value_get_boolean (value));
+			return;
+
 		case PROP_FILTER_JUNK:
 			camel_imap_settings_set_filter_junk (
 				CAMEL_IMAP_SETTINGS (object),
@@ -247,6 +255,13 @@ imap_settings_get_property (GObject *object,
 				CAMEL_IMAP_SETTINGS (object)));
 			return;
 
+		case PROP_FILTER_ALL:
+			g_value_set_boolean (
+				value,
+				camel_imap_settings_get_filter_all (
+				CAMEL_IMAP_SETTINGS (object)));
+			return;
+
 		case PROP_FILTER_JUNK:
 			g_value_set_boolean (
 				value,
@@ -444,6 +459,18 @@ camel_imap_settings_class_init (CamelImapSettingsClass *class)
 
 	g_object_class_install_property (
 		object_class,
+		PROP_FILTER_ALL,
+		g_param_spec_boolean (
+			"filter-all",
+			"Filter All",
+			"Whether to apply filters in all folders",
+			FALSE,
+			G_PARAM_READWRITE |
+			G_PARAM_CONSTRUCT |
+			G_PARAM_STATIC_STRINGS));
+
+	g_object_class_install_property (
+		object_class,
 		PROP_FILTER_JUNK,
 		g_param_spec_boolean (
 			"filter-junk",
@@ -853,6 +880,44 @@ camel_imap_settings_set_filter_junk (CamelImapSettings *settings,
 }
 
 /**
+ * camel_imap_settings_get_filter_all:
+ * @settings: a #CamelImapSettings
+ *
+ * Returns whether apply filters in all folders.
+ *
+ * Returns: whether to apply filters in all folders
+ *
+ * Since: 3.4
+ **/
+gboolean
+camel_imap_settings_get_filter_all (CamelImapSettings *settings)
+{
+	g_return_val_if_fail (CAMEL_IS_IMAP_SETTINGS (settings), FALSE);
+
+	return settings->priv->filter_all;
+}
+
+/**
+ * camel_imap_settings_set_filter_all:
+ * @settings: a #CamelImapSettings
+ * @filter_all: whether to apply filters in all folders
+ *
+ * Sets whether to apply filters in all folders.
+ *
+ * Since: 3.4
+ **/
+void
+camel_imap_settings_set_filter_all (CamelImapSettings *settings,
+                                    gboolean filter_all)
+{
+	g_return_if_fail (CAMEL_IS_IMAP_SETTINGS (settings));
+
+	settings->priv->filter_all = filter_all;
+
+	g_object_notify (G_OBJECT (settings), "filter-all");
+}
+
+/**
  * camel_imap_settings_get_filter_junk_inbox:
  * @settings: a #CamelImapSettings
  *
diff --git a/camel/providers/imap/camel-imap-settings.h b/camel/providers/imap/camel-imap-settings.h
index 2d1aa7a..f7f185e 100644
--- a/camel/providers/imap/camel-imap-settings.h
+++ b/camel/providers/imap/camel-imap-settings.h
@@ -81,6 +81,11 @@ gchar **	camel_imap_settings_dup_fetch_headers_extra
 void		camel_imap_settings_set_fetch_headers_extra
 					(CamelImapSettings *settings,
 					 const gchar * const *fetch_headers_extra);
+gboolean	camel_imap_settings_get_filter_all
+					(CamelImapSettings *settings);
+void		camel_imap_settings_set_filter_all
+					(CamelImapSettings *settings,
+					 gboolean filter_all);
 gboolean	camel_imap_settings_get_filter_junk
 					(CamelImapSettings *settings);
 void		camel_imap_settings_set_filter_junk
diff --git a/camel/providers/imapx/camel-imapx-folder.c b/camel/providers/imapx/camel-imapx-folder.c
index 81a4a66..24deaf5 100644
--- a/camel/providers/imapx/camel-imapx-folder.c
+++ b/camel/providers/imapx/camel-imapx-folder.c
@@ -38,8 +38,17 @@
 
 #define d(...) camel_imapx_debug(debug, '?', __VA_ARGS__)
 
+/* The custom property ID is a CamelArg artifact.
+ * It still identifies the property in state files. */
+enum {
+	PROP_0,
+	PROP_APPLY_FILTERS = 0x2501
+};
+
 G_DEFINE_TYPE (CamelIMAPXFolder, camel_imapx_folder, CAMEL_TYPE_OFFLINE_FOLDER)
 
+static gboolean imapx_folder_get_apply_filters (CamelIMAPXFolder *folder);
+
 CamelFolder *
 camel_imapx_folder_new (CamelStore *store,
                         const gchar *folder_dir,
@@ -52,6 +61,7 @@ camel_imapx_folder_new (CamelStore *store,
 	CamelIMAPXFolder *ifolder;
 	const gchar *short_name;
 	gchar *state_file;
+	gboolean filter_all;
 	gboolean filter_inbox;
 	gboolean filter_junk;
 	gboolean filter_junk_inbox;
@@ -63,6 +73,7 @@ camel_imapx_folder_new (CamelStore *store,
 
 	g_object_get (
 		settings,
+		"filter-all", &filter_all,
 		"filter-inbox", &filter_inbox,
 		"filter-junk", &filter_junk,
 		"filter-junk-inbox", &filter_junk_inbox,
@@ -115,13 +126,18 @@ camel_imapx_folder_new (CamelStore *store,
 	ifolder->uidnext_on_server = 0;
 
 	if (!g_ascii_strcasecmp (folder_name, "INBOX")) {
-		if (filter_inbox)
+		if (filter_inbox || filter_all)
 			folder->folder_flags |= CAMEL_FOLDER_FILTER_RECENT;
 		if (filter_junk)
 			folder->folder_flags |= CAMEL_FOLDER_FILTER_JUNK;
-	} else if (filter_junk && !filter_junk_inbox)
+	} else {
+		if (filter_junk && !filter_junk_inbox)
 			folder->folder_flags |= CAMEL_FOLDER_FILTER_JUNK;
 
+		if (filter_all || imapx_folder_get_apply_filters (ifolder))
+			folder->folder_flags |= CAMEL_FOLDER_FILTER_RECENT;
+	}
+
 	camel_store_summary_connect_folder_summary (
 		(CamelStoreSummary *) ((CamelIMAPXStore *) store)->summary,
 		folder_name, folder->summary);
@@ -129,6 +145,64 @@ camel_imapx_folder_new (CamelStore *store,
 	return folder;
 }
 
+static gboolean
+imapx_folder_get_apply_filters (CamelIMAPXFolder *folder)
+{
+	g_return_val_if_fail (folder != NULL, FALSE);
+	g_return_val_if_fail (CAMEL_IS_IMAPX_FOLDER (folder), FALSE);
+
+	return folder->apply_filters;
+}
+
+static void
+imapx_folder_set_apply_filters (CamelIMAPXFolder *folder,
+				gboolean apply_filters)
+{
+	g_return_if_fail (folder != NULL);
+	g_return_if_fail (CAMEL_IS_IMAPX_FOLDER (folder));
+
+	if ((folder->apply_filters ? 1 : 0) == (apply_filters ? 1 : 0))
+		return;
+
+	folder->apply_filters = apply_filters;
+
+	g_object_notify (G_OBJECT (folder), "apply-filters");
+}
+
+static void
+imapx_folder_set_property (GObject *object,
+			   guint property_id,
+			   const GValue *value,
+			   GParamSpec *pspec)
+{
+	switch (property_id) {
+		case PROP_APPLY_FILTERS:
+			imapx_folder_set_apply_filters (
+				CAMEL_IMAPX_FOLDER (object),
+				g_value_get_boolean (value));
+			return;
+	}
+
+	G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+}
+
+static void
+imapx_folder_get_property (GObject *object,
+			   guint property_id,
+			   GValue *value,
+			   GParamSpec *pspec)
+{
+	switch (property_id) {
+		case PROP_APPLY_FILTERS:
+			g_value_set_boolean (
+				value, imapx_folder_get_apply_filters (
+				CAMEL_IMAPX_FOLDER (object)));
+			return;
+	}
+
+	G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+}
+
 static void
 imapx_folder_dispose (GObject *object)
 {
@@ -643,6 +717,8 @@ camel_imapx_folder_class_init (CamelIMAPXFolderClass *class)
 	CamelFolderClass *folder_class;
 
 	object_class = G_OBJECT_CLASS (class);
+	object_class->set_property = imapx_folder_set_property;
+	object_class->get_property = imapx_folder_get_property;
 	object_class->dispose = imapx_folder_dispose;
 	object_class->finalize = imapx_folder_finalize;
 
@@ -661,6 +737,17 @@ camel_imapx_folder_class_init (CamelIMAPXFolderClass *class)
 	folder_class->synchronize_sync = imapx_synchronize_sync;
 	folder_class->synchronize_message_sync = imapx_synchronize_message_sync;
 	folder_class->transfer_messages_to_sync = imapx_transfer_messages_to_sync;
+
+	g_object_class_install_property (
+		object_class,
+		PROP_APPLY_FILTERS,
+		g_param_spec_boolean (
+			"apply-filters",
+			"Apply Filters",
+			_("Apply message filters to this folder"),
+			FALSE,
+			G_PARAM_READWRITE |
+			CAMEL_PARAM_PERSISTENT));
 }
 
 static void
diff --git a/camel/providers/imapx/camel-imapx-folder.h b/camel/providers/imapx/camel-imapx-folder.h
index efe0af7..885640f 100644
--- a/camel/providers/imapx/camel-imapx-folder.h
+++ b/camel/providers/imapx/camel-imapx-folder.h
@@ -68,6 +68,8 @@ struct _CamelIMAPXFolder {
 
 	GMutex *search_lock;
 	GMutex *stream_lock;
+
+	gboolean apply_filters;		/* persistent property */
 };
 
 struct _CamelIMAPXFolderClass {
diff --git a/camel/providers/imapx/camel-imapx-provider.c b/camel/providers/imapx/camel-imapx-provider.c
index 6179e84..05a93de 100644
--- a/camel/providers/imapx/camel-imapx-provider.c
+++ b/camel/providers/imapx/camel-imapx-provider.c
@@ -70,7 +70,9 @@ CamelProviderConfEntry imapx_conf_entries[] = {
 #endif
 	{ CAMEL_PROVIDER_CONF_SECTION_END },
 	{ CAMEL_PROVIDER_CONF_SECTION_START, "general", NULL, N_("Options") },
-	{ CAMEL_PROVIDER_CONF_CHECKBOX, "filter-inbox", NULL,
+	{ CAMEL_PROVIDER_CONF_CHECKBOX, "filter-all", NULL,
+	  N_("Apply _filters to new messages in all folders"), "0" },
+	{ CAMEL_PROVIDER_CONF_CHECKBOX, "filter-inbox", "!filter-all",
 	  N_("_Apply filters to new messages in Inbox on this server"), "1" },
 	{ CAMEL_PROVIDER_CONF_CHECKBOX, "filter-junk", NULL,
 	  N_("Check new messages for Jun_k contents"), "0" },
diff --git a/camel/providers/imapx/camel-imapx-settings.c b/camel/providers/imapx/camel-imapx-settings.c
index 2b4c333..2f1c3a8 100644
--- a/camel/providers/imapx/camel-imapx-settings.c
+++ b/camel/providers/imapx/camel-imapx-settings.c
@@ -35,6 +35,7 @@ struct _CamelIMAPXSettingsPrivate {
 
 	gboolean check_all;
 	gboolean check_subscribed;
+	gboolean filter_all;
 	gboolean filter_junk;
 	gboolean filter_junk_inbox;
 	gboolean use_idle;
@@ -55,6 +56,7 @@ enum {
 	PROP_CHECK_SUBSCRIBED,
 	PROP_CONCURRENT_CONNECTIONS,
 	PROP_FETCH_ORDER,
+	PROP_FILTER_ALL,
 	PROP_FILTER_JUNK,
 	PROP_FILTER_JUNK_INBOX,
 	PROP_HOST,
@@ -121,6 +123,12 @@ imapx_settings_set_property (GObject *object,
 				g_value_get_enum (value));
 			return;
 
+		case PROP_FILTER_ALL:
+			camel_imapx_settings_set_filter_all (
+				CAMEL_IMAPX_SETTINGS (object),
+				g_value_get_boolean (value));
+			return;
+
 		case PROP_FILTER_JUNK:
 			camel_imapx_settings_set_filter_junk (
 				CAMEL_IMAPX_SETTINGS (object),
@@ -258,6 +266,13 @@ imapx_settings_get_property (GObject *object,
 				CAMEL_IMAPX_SETTINGS (object)));
 			return;
 
+		case PROP_FILTER_ALL:
+			g_value_set_boolean (
+				value,
+				camel_imapx_settings_get_filter_all (
+				CAMEL_IMAPX_SETTINGS (object)));
+			return;
+
 		case PROP_FILTER_JUNK:
 			g_value_set_boolean (
 				value,
@@ -461,6 +476,18 @@ camel_imapx_settings_class_init (CamelIMAPXSettingsClass *class)
 
 	g_object_class_install_property (
 		object_class,
+		PROP_FILTER_ALL,
+		g_param_spec_boolean (
+			"filter-all",
+			"Filter All",
+			"Whether to apply filters in all folders",
+			FALSE,
+			G_PARAM_READWRITE |
+			G_PARAM_CONSTRUCT |
+			G_PARAM_STATIC_STRINGS));
+
+	g_object_class_install_property (
+		object_class,
 		PROP_FILTER_JUNK,
 		g_param_spec_boolean (
 			"filter-junk",
@@ -824,6 +851,44 @@ camel_imapx_settings_set_fetch_order (CamelIMAPXSettings *settings,
 }
 
 /**
+ * camel_imapx_settings_get_filter_all:
+ * @settings: a #CamelIMAPXSettings
+ *
+ * Returns whether apply filters in all folders.
+ *
+ * Returns: whether to apply filters in all folders
+ *
+ * Since: 3.4
+ **/
+gboolean
+camel_imapx_settings_get_filter_all (CamelIMAPXSettings *settings)
+{
+	g_return_val_if_fail (CAMEL_IS_IMAPX_SETTINGS (settings), FALSE);
+
+	return settings->priv->filter_all;
+}
+
+/**
+ * camel_imapx_settings_set_filter_all:
+ * @settings: a #CamelIMAPXSettings
+ * @filter_all: whether to apply filters in all folders
+ *
+ * Sets whether to apply filters in all folders.
+ *
+ * Since: 3.4
+ **/
+void
+camel_imapx_settings_set_filter_all (CamelIMAPXSettings *settings,
+                                     gboolean filter_all)
+{
+	g_return_if_fail (CAMEL_IS_IMAPX_SETTINGS (settings));
+
+	settings->priv->filter_all = filter_all;
+
+	g_object_notify (G_OBJECT (settings), "filter-all");
+}
+
+/**
  * camel_imapx_settings_get_filter_junk:
  * @settings: a #CamelIMAPXSettings
  *
diff --git a/camel/providers/imapx/camel-imapx-settings.h b/camel/providers/imapx/camel-imapx-settings.h
index bffa560..fbd1084 100644
--- a/camel/providers/imapx/camel-imapx-settings.h
+++ b/camel/providers/imapx/camel-imapx-settings.h
@@ -81,6 +81,11 @@ CamelSortType	camel_imapx_settings_get_fetch_order
 void		camel_imapx_settings_set_fetch_order
 						(CamelIMAPXSettings *settings,
 						 CamelSortType fetch_order);
+gboolean	camel_imapx_settings_get_filter_all
+						(CamelIMAPXSettings *settings);
+void		camel_imapx_settings_set_filter_all
+						(CamelIMAPXSettings *settings,
+						 gboolean filter_all);
 gboolean	camel_imapx_settings_get_filter_junk
 						(CamelIMAPXSettings *settings);
 void		camel_imapx_settings_set_filter_junk
diff --git a/camel/providers/nntp/camel-nntp-folder.c b/camel/providers/nntp/camel-nntp-folder.c
index 7681b0a..2133b1e 100644
--- a/camel/providers/nntp/camel-nntp-folder.c
+++ b/camel/providers/nntp/camel-nntp-folder.c
@@ -37,8 +37,73 @@
 #include "camel-nntp-store.h"
 #include "camel-nntp-summary.h"
 
+/* The custom property ID is a CamelArg artifact.
+ * It still identifies the property in state files. */
+enum {
+	PROP_0,
+	PROP_APPLY_FILTERS = 0x2501
+};
+
 G_DEFINE_TYPE (CamelNNTPFolder, camel_nntp_folder, CAMEL_TYPE_DISCO_FOLDER)
 
+static gboolean
+nntp_folder_get_apply_filters (CamelNNTPFolder *folder)
+{
+	g_return_val_if_fail (folder != NULL, FALSE);
+	g_return_val_if_fail (CAMEL_IS_NNTP_FOLDER (folder), FALSE);
+
+	return folder->priv->apply_filters;
+}
+
+static void
+nntp_folder_set_apply_filters (CamelNNTPFolder *folder,
+			       gboolean apply_filters)
+{
+	g_return_if_fail (folder != NULL);
+	g_return_if_fail (CAMEL_IS_NNTP_FOLDER (folder));
+
+	if ((folder->priv->apply_filters ? 1 : 0) == (apply_filters ? 1 : 0))
+		return;
+
+	folder->priv->apply_filters = apply_filters;
+
+	g_object_notify (G_OBJECT (folder), "apply-filters");
+}
+
+static void
+nntp_folder_set_property (GObject *object,
+			  guint property_id,
+			  const GValue *value,
+			  GParamSpec *pspec)
+{
+	switch (property_id) {
+		case PROP_APPLY_FILTERS:
+			nntp_folder_set_apply_filters (
+				CAMEL_NNTP_FOLDER (object),
+				g_value_get_boolean (value));
+			return;
+	}
+
+	G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+}
+
+static void
+nntp_folder_get_property (GObject *object,
+			  guint property_id,
+			  GValue *value,
+			  GParamSpec *pspec)
+{
+	switch (property_id) {
+		case PROP_APPLY_FILTERS:
+			g_value_set_boolean (
+				value, nntp_folder_get_apply_filters (
+				CAMEL_NNTP_FOLDER (object)));
+			return;
+	}
+
+	G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+}
+
 static void
 nntp_folder_dispose (GObject *object)
 {
@@ -180,7 +245,7 @@ nntp_folder_sync (CamelFolder *folder,
 		g_ptr_array_free (changed, TRUE);
 		camel_folder_summary_touch (folder->summary);
 	}
-	success = !camel_folder_summary_save_to_db (folder->summary, error);
+	success = camel_folder_summary_save_to_db (folder->summary, error);
 	camel_service_unlock (CAMEL_SERVICE (parent_store), CAMEL_SERVICE_REC_CONNECT_LOCK);
 
 	return success;
@@ -653,6 +718,8 @@ camel_nntp_folder_class_init (CamelNNTPFolderClass *class)
 	g_type_class_add_private (class, sizeof (CamelNNTPFolderPrivate));
 
 	object_class = G_OBJECT_CLASS (class);
+	object_class->set_property = nntp_folder_set_property;
+	object_class->get_property = nntp_folder_get_property;
 	object_class->dispose = nntp_folder_dispose;
 	object_class->finalize = nntp_folder_finalize;
 
@@ -679,6 +746,17 @@ camel_nntp_folder_class_init (CamelNNTPFolderClass *class)
 	disco_folder_class->expunge_uids_online = nntp_folder_expunge_uids_offline;
 	disco_folder_class->expunge_uids_offline = nntp_folder_expunge_uids_offline;
 	disco_folder_class->expunge_uids_resyncing = nntp_folder_expunge_uids_offline;
+
+	g_object_class_install_property (
+		object_class,
+		PROP_APPLY_FILTERS,
+		g_param_spec_boolean (
+			"apply-filters",
+			"Apply Filters",
+			_("Apply message filters to this folder"),
+			FALSE,
+			G_PARAM_READWRITE |
+			CAMEL_PARAM_PERSISTENT));
 }
 
 static void
@@ -702,13 +780,21 @@ camel_nntp_folder_new (CamelStore *parent,
 	CamelNNTPFolder *nntp_folder;
 	gchar *root;
 	CamelService *service;
+	CamelSettings *settings;
 	CamelStoreInfo *si;
 	const gchar *user_cache_dir;
 	gboolean subscribed = TRUE;
+	gboolean filter_all;
 
 	service = CAMEL_SERVICE (parent);
+	settings = camel_service_get_settings (service);
 	user_cache_dir = camel_service_get_user_cache_dir (service);
 
+	g_object_get (
+		settings,
+		"filter-all", &filter_all,
+		NULL);
+
 	folder = g_object_new (
 		CAMEL_TYPE_NNTP_FOLDER,
 		"display-name", folder_name,
@@ -730,6 +816,9 @@ camel_nntp_folder_new (CamelStore *parent,
 
 	folder->summary = (CamelFolderSummary *) camel_nntp_summary_new (folder);
 
+	if (filter_all || nntp_folder_get_apply_filters (nntp_folder))
+		folder->folder_flags |= CAMEL_FOLDER_FILTER_RECENT;
+
 	camel_folder_summary_load_from_db (folder->summary, NULL);
 
 	si = camel_store_summary_path ((CamelStoreSummary *) ((CamelNNTPStore *) parent)->summary, folder_name);
@@ -738,15 +827,15 @@ camel_nntp_folder_new (CamelStore *parent,
 		camel_store_summary_info_free ((CamelStoreSummary *) ((CamelNNTPStore *) parent)->summary, si);
 	}
 
+	camel_store_summary_connect_folder_summary (
+		(CamelStoreSummary *) ((CamelNNTPStore *) parent)->summary,
+		folder_name, folder->summary);
+
 	if (subscribed && !camel_folder_refresh_info_sync (
 			folder, cancellable, error)) {
 		g_object_unref (folder);
 		folder = NULL;
 	}
 
-	camel_store_summary_connect_folder_summary (
-		(CamelStoreSummary *) ((CamelNNTPStore *) parent)->summary,
-		folder_name, folder->summary);
-
 	return folder;
 }
diff --git a/camel/providers/nntp/camel-nntp-private.h b/camel/providers/nntp/camel-nntp-private.h
index 1ed654c..206adbe 100644
--- a/camel/providers/nntp/camel-nntp-private.h
+++ b/camel/providers/nntp/camel-nntp-private.h
@@ -38,6 +38,8 @@ G_BEGIN_DECLS
 struct _CamelNNTPFolderPrivate {
 	GMutex *search_lock;	/* for locking the search object */
 	GMutex *cache_lock;     /* for locking the cache object */
+
+	gboolean apply_filters;		/* persistent property */
 };
 
 #define CAMEL_NNTP_FOLDER_LOCK(f, l) (g_mutex_lock(((CamelNNTPFolder *)f)->priv->l))
diff --git a/camel/providers/nntp/camel-nntp-provider.c b/camel/providers/nntp/camel-nntp-provider.c
index f0d8997..9b4a724 100644
--- a/camel/providers/nntp/camel-nntp-provider.c
+++ b/camel/providers/nntp/camel-nntp-provider.c
@@ -38,6 +38,10 @@ static gint check_equal (gchar *s1, gchar *s2);
 static gint nntp_url_equal (gconstpointer a, gconstpointer b);
 
 static CamelProviderConfEntry nntp_conf_entries[] = {
+	{ CAMEL_PROVIDER_CONF_SECTION_START, "general", NULL, N_("Options") },
+	{ CAMEL_PROVIDER_CONF_CHECKBOX, "filter-all", NULL,
+	  N_("Apply _filters to new messages in all folders"), "0" },
+	{ CAMEL_PROVIDER_CONF_SECTION_END },
 	{ CAMEL_PROVIDER_CONF_SECTION_START, "folders", NULL,
 	  N_("Folders") },
 	{ CAMEL_PROVIDER_CONF_CHECKBOX, "short-folder-names", NULL,
diff --git a/camel/providers/nntp/camel-nntp-settings.c b/camel/providers/nntp/camel-nntp-settings.c
index 7990655..7c66449 100644
--- a/camel/providers/nntp/camel-nntp-settings.c
+++ b/camel/providers/nntp/camel-nntp-settings.c
@@ -23,6 +23,7 @@
 	((obj), CAMEL_TYPE_NNTP_SETTINGS, CamelNNTPSettingsPrivate))
 
 struct _CamelNNTPSettingsPrivate {
+	gboolean filter_all;
 	gboolean folder_hierarchy_relative;
 	gboolean short_folder_names;
 };
@@ -30,6 +31,7 @@ struct _CamelNNTPSettingsPrivate {
 enum {
 	PROP_0,
 	PROP_AUTH_MECHANISM,
+	PROP_FILTER_ALL,
 	PROP_FOLDER_HIERARCHY_RELATIVE,
 	PROP_HOST,
 	PROP_PORT,
@@ -58,6 +60,12 @@ nntp_settings_set_property (GObject *object,
 				g_value_get_string (value));
 			return;
 
+		case PROP_FILTER_ALL:
+			camel_nntp_settings_set_filter_all (
+				CAMEL_NNTP_SETTINGS (object),
+				g_value_get_boolean (value));
+			return;
+
 		case PROP_FOLDER_HIERARCHY_RELATIVE:
 			camel_nntp_settings_set_folder_hierarchy_relative (
 				CAMEL_NNTP_SETTINGS (object),
@@ -112,6 +120,13 @@ nntp_settings_get_property (GObject *object,
 				CAMEL_NETWORK_SETTINGS (object)));
 			return;
 
+		case PROP_FILTER_ALL:
+			g_value_set_boolean (
+				value,
+				camel_nntp_settings_get_filter_all (
+				CAMEL_NNTP_SETTINGS (object)));
+			return;
+
 		case PROP_FOLDER_HIERARCHY_RELATIVE:
 			g_value_set_boolean (
 				value,
@@ -222,6 +237,18 @@ camel_nntp_settings_class_init (CamelNNTPSettingsClass *class)
 		object_class,
 		PROP_USER,
 		"user");
+
+	g_object_class_install_property (
+		object_class,
+		PROP_FILTER_ALL,
+		g_param_spec_boolean (
+			"filter-all",
+			"Filter All",
+			"Whether to apply filters in all folders",
+			FALSE,
+			G_PARAM_READWRITE |
+			G_PARAM_CONSTRUCT |
+			G_PARAM_STATIC_STRINGS));
 }
 
 static void
@@ -231,6 +258,44 @@ camel_nntp_settings_init (CamelNNTPSettings *settings)
 }
 
 /**
+ * camel_nntp_settings_get_filter_all:
+ * @settings: a #CamelNNTPSettings
+ *
+ * Returns whether apply filters in all folders.
+ *
+ * Returns: whether to apply filters in all folders
+ *
+ * Since: 3.4
+ **/
+gboolean
+camel_nntp_settings_get_filter_all (CamelNNTPSettings *settings)
+{
+	g_return_val_if_fail (CAMEL_IS_NNTP_SETTINGS (settings), FALSE);
+
+	return settings->priv->filter_all;
+}
+
+/**
+ * camel_nntp_settings_set_filter_all:
+ * @settings: a #CamelNNTPSettings
+ * @filter_all: whether to apply filters in all folders
+ *
+ * Sets whether to apply filters in all folders.
+ *
+ * Since: 3.4
+ **/
+void
+camel_nntp_settings_set_filter_all (CamelNNTPSettings *settings,
+                                    gboolean filter_all)
+{
+	g_return_if_fail (CAMEL_IS_NNTP_SETTINGS (settings));
+
+	settings->priv->filter_all = filter_all;
+
+	g_object_notify (G_OBJECT (settings), "filter-all");
+}
+
+/**
  * camel_nntp_settings_get_folder_hierarchy_relative:
  * @settings: a #CamelNNTPSettings
  *
diff --git a/camel/providers/nntp/camel-nntp-settings.h b/camel/providers/nntp/camel-nntp-settings.h
index 0634c9f..34e1c1c 100644
--- a/camel/providers/nntp/camel-nntp-settings.h
+++ b/camel/providers/nntp/camel-nntp-settings.h
@@ -57,6 +57,11 @@ struct _CamelNNTPSettingsClass {
 
 GType		camel_nntp_settings_get_type
 					(void) G_GNUC_CONST;
+gboolean	camel_nntp_settings_get_filter_all
+					(CamelNNTPSettings *settings);
+void		camel_nntp_settings_set_filter_all
+					(CamelNNTPSettings *settings,
+					 gboolean filter_all);
 gboolean	camel_nntp_settings_get_folder_hierarchy_relative
 					(CamelNNTPSettings *settings);
 void		camel_nntp_settings_set_folder_hierarchy_relative
diff --git a/camel/providers/nntp/camel-nntp-summary.c b/camel/providers/nntp/camel-nntp-summary.c
index f2997d8..38f8573 100644
--- a/camel/providers/nntp/camel-nntp-summary.c
+++ b/camel/providers/nntp/camel-nntp-summary.c
@@ -178,9 +178,12 @@ add_range_xover (CamelNNTPSummary *cns,
 	guint len;
 	gint ret;
 	guint n, count, total, size;
+	gboolean folder_filter_recent;
 	struct _xover_header *xover;
 
 	s = (CamelFolderSummary *) cns;
+	folder_filter_recent = camel_folder_summary_get_folder (s) &&
+		(camel_folder_summary_get_folder (s)->folder_flags & CAMEL_FOLDER_FILTER_RECENT) != 0;
 
 	service = CAMEL_SERVICE (store);
 	settings = camel_service_get_settings (service);
@@ -262,6 +265,8 @@ add_range_xover (CamelNNTPSummary *cns,
 					mi->size = size;
 					cns->high = n;
 					camel_folder_change_info_add_uid (changes, camel_message_info_uid (mi));
+					if (folder_filter_recent)
+						camel_folder_change_info_recent_uid (changes, camel_message_info_uid (mi));
 				}
 			}
 		}
@@ -299,8 +304,11 @@ add_range_head (CamelNNTPSummary *cns,
 	CamelMessageInfo *mi;
 	CamelMimeParser *mp;
 	gchar *host;
+	gboolean folder_filter_recent;
 
 	s = (CamelFolderSummary *) cns;
+	folder_filter_recent = camel_folder_summary_get_folder (s) &&
+		(camel_folder_summary_get_folder (s)->folder_flags & CAMEL_FOLDER_FILTER_RECENT) != 0;
 
 	mp = camel_mime_parser_new ();
 
@@ -353,6 +361,8 @@ add_range_head (CamelNNTPSummary *cns,
 				}
 				cns->high = i;
 				camel_folder_change_info_add_uid (changes, camel_message_info_uid (mi));
+				if (folder_filter_recent)
+					camel_folder_change_info_recent_uid (changes, camel_message_info_uid (mi));
 			}
 			if (cns->priv->uid) {
 				g_free (cns->priv->uid);
