diff --git a/mail/e-mail-backend.c b/mail/e-mail-backend.c
index a0453a9..b2e22e3 100644
--- a/mail/e-mail-backend.c
+++ b/mail/e-mail-backend.c
@@ -335,7 +335,7 @@ mail_backend_folder_changed_cb (MailFolderCache *folder_cache,
 	gint folder_type;
 	gint flags = 0;
 
-	if (!mail_folder_cache_get_folder_from_uri (folder_cache, folder_uri, &folder))
+	if (mail_folder_cache_get_folder_from_uri (folder_cache, folder_uri, &folder))
 		if (folder && !mail_folder_cache_get_folder_info_flags (folder_cache, folder, &flags))
 			g_return_if_reached ();
 
diff --git a/mail/mail-folder-cache.c b/mail/mail-folder-cache.c
index a9726ea..094a046 100644
--- a/mail/mail-folder-cache.c
+++ b/mail/mail-folder-cache.c
@@ -301,7 +301,8 @@ folder_changed_cb (CamelFolder *folder,
                    CamelFolderChangeInfo *changes,
                    MailFolderCache *self)
 {
-	static time_t last_newmail = 0;
+	static GHashTable *last_newmail_per_folder = NULL;
+	time_t latest_received;
 	CamelFolder *local_drafts;
 	CamelFolder *local_outbox;
 	CamelFolder *local_sent;
@@ -318,6 +319,12 @@ folder_changed_cb (CamelFolder *folder,
 	full_name = camel_folder_get_full_name (folder);
 	parent_store = camel_folder_get_parent_store (folder);
 
+	if (!last_newmail_per_folder)
+		last_newmail_per_folder = g_hash_table_new (g_direct_hash, g_direct_equal);
+
+	/* it's fine to hash them by folder pointer here */
+	latest_received = GPOINTER_TO_INT (g_hash_table_lookup (last_newmail_per_folder, folder));
+
 	local_drafts = e_mail_local_get_folder (E_MAIL_FOLDER_DRAFTS);
 	local_outbox = e_mail_local_get_folder (E_MAIL_FOLDER_OUTBOX);
 	local_sent = e_mail_local_get_folder (E_MAIL_FOLDER_SENT);
@@ -336,7 +343,8 @@ folder_changed_cb (CamelFolder *folder,
 				if (((flags & CAMEL_MESSAGE_SEEN) == 0) &&
 				    ((flags & CAMEL_MESSAGE_JUNK) == 0) &&
 				    ((flags & CAMEL_MESSAGE_DELETED) == 0) &&
-				    (camel_message_info_date_received (info) > last_newmail)) {
+				    (camel_message_info_date_received (info) > latest_received)) {
+					latest_received = camel_message_info_date_received (info);
 					new++;
 					if (new == 1) {
 						uid = g_strdup (camel_message_info_uid (info));
@@ -357,8 +365,8 @@ folder_changed_cb (CamelFolder *folder,
 		}
 	}
 
-	if (new > 0 || !last_newmail)
-		time (&last_newmail);
+	if (new > 0)
+		g_hash_table_insert (last_newmail_per_folder, folder, GINT_TO_POINTER (latest_received));
 
 	g_mutex_lock (self->priv->stores_mutex);
 	if (self->priv->stores != NULL
