[evolution/account-mgmt: 20/52] Adapt mail to the new ESource API.



commit f29fcab8c8455aa72f7cf1199af1f494e0ded3c7
Author: Matthew Barnes <mbarnes redhat com>
Date:   Wed Apr 13 10:30:40 2011 -0400

    Adapt mail to the new ESource API.

 libemail-engine/Makefile.am            |    2 +
 libemail-engine/e-mail-authenticator.c |  267 ++
 libemail-engine/e-mail-authenticator.h |   76 +
 libemail-engine/e-mail-session-utils.c |   38 +-
 libemail-engine/e-mail-session.c       |  984 ++++---
 libemail-engine/e-mail-session.h       |   30 +-
 libemail-engine/e-mail-utils.c         |  544 +++-
 libemail-engine/e-mail-utils.h         |   38 +-
 libemail-engine/mail-config.c          |   21 -
 libemail-engine/mail-config.h          |    1 -
 libemail-engine/mail-folder-cache.c    |   11 +-
 libemail-engine/mail-ops.c             |  371 ++-
 libemail-engine/mail-ops.h             |    1 -
 libemail-utils/Makefile.am             |    8 -
 mail/Makefile.am                       |   36 +-
 mail/e-mail-account-manager.c          |   23 +-
 mail/e-mail-account-manager.h          |    6 +-
 mail/e-mail-account-store.c            |  298 +-
 mail/e-mail-backend.c                  |  242 +-
 mail/e-mail-config-assistant.c         |  789 +++++
 mail/e-mail-config-assistant.h         |   80 +
 mail/e-mail-config-auth-check.c        |  505 +++
 mail/e-mail-config-auth-check.h        |   76 +
 mail/e-mail-config-confirm-page.c      |  199 ++
 mail/e-mail-config-confirm-page.h      |   75 +
 mail/e-mail-config-defaults-page.c     |  854 +++++
 mail/e-mail-config-defaults-page.h     |   79 +
 mail/e-mail-config-identity-page.c     |  733 ++++
 mail/e-mail-config-identity-page.h     |   91 +
 mail/e-mail-config-notebook.c          |  676 ++++
 mail/e-mail-config-notebook.h          |   95 +
 mail/e-mail-config-page.c              |  158 +
 mail/e-mail-config-page.h              |   69 +
 mail/e-mail-config-provider-page.c     |  660 ++++
 mail/e-mail-config-provider-page.h     |   75 +
 mail/e-mail-config-receiving-page.c    |   69 +
 mail/e-mail-config-receiving-page.h    |   69 +
 mail/e-mail-config-security-page.c     |  667 ++++
 mail/e-mail-config-security-page.h     |   73 +
 mail/e-mail-config-sending-page.c      |   69 +
 mail/e-mail-config-sending-page.h      |   68 +
 mail/e-mail-config-service-backend.c   |  139 +
 mail/e-mail-config-service-backend.h   |   97 +
 mail/e-mail-config-service-page.c      |  775 +++++
 mail/e-mail-config-service-page.h      |   95 +
 mail/e-mail-config-sidebar.c           |  415 +++
 mail/e-mail-config-sidebar.h           |   72 +
 mail/e-mail-config-summary-page.c      |  816 +++++
 mail/e-mail-config-summary-page.h      |   89 +
 mail/e-mail-config-welcome-page.c      |  197 ++
 mail/e-mail-config-welcome-page.h      |   75 +
 mail/e-mail-config-window.c            |  500 +++
 mail/e-mail-config-window.h            |   71 +
 mail/e-mail-folder-pane.c              |   17 +-
 mail/e-mail-migrate.c                  |  250 +--
 mail/e-mail-paned-view.c               |    8 +-
 mail/e-mail-reader-utils.c             |   27 +-
 mail/e-mail-reader.c                   |   52 +-
 mail/e-mail-ui-session.c               |  321 +-
 mail/e-mail-ui-session.h               |    8 +-
 mail/e-mail.h                          |    1 +
 mail/em-account-editor.c               | 5737 --------------------------------
 mail/em-account-editor.h               |  124 -
 mail/em-composer-utils.c               |  317 ++-
 mail/em-composer-utils.h               |    3 +-
 mail/em-filter-source-element.c        |  114 +-
 mail/em-folder-tree-model.c            |   56 +-
 mail/em-format-html.c                  |   21 +-
 mail/em-subscription-editor.c          |   12 +-
 mail/em-utils.c                        |   48 +-
 mail/em-utils.h                        |    6 -
 mail/mail-config.ui                    |   50 -
 mail/mail-send-recv.c                  |  293 +--
 mail/mail.error.xml                    |   28 -
 74 files changed, 12117 insertions(+), 7943 deletions(-)
---
diff --git a/libemail-engine/Makefile.am b/libemail-engine/Makefile.am
index 4c64ea8..103a9d5 100644
--- a/libemail-engine/Makefile.am
+++ b/libemail-engine/Makefile.am
@@ -22,6 +22,7 @@ libemail_engine_la_CPPFLAGS = \
 libmailengineincludedir = $(privincludedir)/libemail-engine
 libmailengineinclude_HEADERS =  \
 	camel-null-store.h \
+	e-mail-authenticator.h \
 	e-mail-enums.h \
 	e-mail-enumtypes.h \
 	e-mail-folder-utils.h \
@@ -40,6 +41,7 @@ libmailengineinclude_HEADERS =  \
 libemail_engine_la_SOURCES =  \
 	$(libmailengineinclude_HEADERS) \
 	camel-null-store.c \
+	e-mail-authenticator.c \
 	e-mail-enumtypes.c \
 	e-mail-folder-utils.c \
 	e-mail-junk-filter.c \
diff --git a/libemail-engine/e-mail-authenticator.c b/libemail-engine/e-mail-authenticator.c
new file mode 100644
index 0000000..9729d35
--- /dev/null
+++ b/libemail-engine/e-mail-authenticator.c
@@ -0,0 +1,267 @@
+/*
+ * e-mail-authenticator.c
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) version 3.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with the program; if not, see <http://www.gnu.org/licenses/>
+ *
+ */
+
+#include "e-mail-authenticator.h"
+
+#include <config.h>
+#include <glib/gi18n-lib.h>
+
+#define E_MAIL_AUTHENTICATOR_GET_PRIVATE(obj) \
+	(G_TYPE_INSTANCE_GET_PRIVATE \
+	((obj), E_TYPE_MAIL_AUTHENTICATOR, EMailAuthenticatorPrivate))
+
+struct _EMailAuthenticatorPrivate {
+	CamelService *service;
+	gchar *mechanism;
+};
+
+enum {
+	PROP_0,
+	PROP_MECHANISM,
+	PROP_SERVICE
+};
+
+/* Forward Declarations */
+static void	e_mail_authenticator_interface_init
+				(ESourceAuthenticatorInterface *interface);
+
+G_DEFINE_TYPE_WITH_CODE (
+	EMailAuthenticator,
+	e_mail_authenticator,
+	G_TYPE_OBJECT,
+	G_IMPLEMENT_INTERFACE (
+		E_TYPE_SOURCE_AUTHENTICATOR,
+		e_mail_authenticator_interface_init))
+
+static void
+mail_authenticator_set_mechanism (EMailAuthenticator *auth,
+                                  const gchar *mechanism)
+{
+	g_return_if_fail (auth->priv->mechanism == NULL);
+
+	auth->priv->mechanism = g_strdup (mechanism);
+}
+
+static void
+mail_authenticator_set_service (EMailAuthenticator *auth,
+                                CamelService *service)
+{
+	g_return_if_fail (CAMEL_IS_SERVICE (service));
+	g_return_if_fail (auth->priv->service == NULL);
+
+	auth->priv->service = g_object_ref (service);
+}
+
+static void
+mail_authenticator_set_property (GObject *object,
+                                 guint property_id,
+                                 const GValue *value,
+                                 GParamSpec *pspec)
+{
+	switch (property_id) {
+		case PROP_MECHANISM:
+			mail_authenticator_set_mechanism (
+				E_MAIL_AUTHENTICATOR (object),
+				g_value_get_string (value));
+			return;
+
+		case PROP_SERVICE:
+			mail_authenticator_set_service (
+				E_MAIL_AUTHENTICATOR (object),
+				g_value_get_object (value));
+			return;
+	}
+
+	G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+}
+
+static void
+mail_authenticator_get_property (GObject *object,
+                                 guint property_id,
+                                 GValue *value,
+                                 GParamSpec *pspec)
+{
+	switch (property_id) {
+		case PROP_MECHANISM:
+			g_value_set_string (
+				value,
+				e_mail_authenticator_get_mechanism (
+				E_MAIL_AUTHENTICATOR (object)));
+			return;
+
+		case PROP_SERVICE:
+			g_value_set_object (
+				value,
+				e_mail_authenticator_get_service (
+				E_MAIL_AUTHENTICATOR (object)));
+			return;
+	}
+
+	G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+}
+
+static void
+mail_authenticator_dispose (GObject *object)
+{
+	EMailAuthenticatorPrivate *priv;
+
+	priv = E_MAIL_AUTHENTICATOR_GET_PRIVATE (object);
+
+	if (priv->service != NULL) {
+		g_object_unref (priv->service);
+		priv->service = NULL;
+	}
+
+	/* Chain up to parent's dispose() method. */
+	G_OBJECT_CLASS (e_mail_authenticator_parent_class)->dispose (object);
+}
+
+static void
+mail_authenticator_finalize (GObject *object)
+{
+	EMailAuthenticatorPrivate *priv;
+
+	priv = E_MAIL_AUTHENTICATOR_GET_PRIVATE (object);
+
+	g_free (priv->mechanism);
+
+	/* Chain up to parent's finalize() method. */
+	G_OBJECT_CLASS (e_mail_authenticator_parent_class)->finalize (object);
+}
+
+static ESourceAuthenticationResult
+mail_authenticator_try_password_sync (ESourceAuthenticator *auth,
+                                      const GString *password,
+                                      GCancellable *cancellable,
+                                      GError **error)
+{
+	CamelService *service;
+	EMailAuthenticator *mail_auth;
+	CamelAuthenticationResult camel_result;
+	ESourceAuthenticationResult source_result;
+	const gchar *mechanism;
+
+	mail_auth = E_MAIL_AUTHENTICATOR (auth);
+	service = e_mail_authenticator_get_service (mail_auth);
+	mechanism = e_mail_authenticator_get_mechanism (mail_auth);
+
+	camel_service_set_password (service, password->str);
+
+	camel_result = camel_service_authenticate_sync (
+		service, mechanism, cancellable, error);
+
+	switch (camel_result) {
+		case CAMEL_AUTHENTICATION_ERROR:
+			source_result = E_SOURCE_AUTHENTICATION_ERROR;
+			break;
+		case CAMEL_AUTHENTICATION_ACCEPTED:
+			source_result = E_SOURCE_AUTHENTICATION_ACCEPTED;
+			break;
+		case CAMEL_AUTHENTICATION_REJECTED:
+			source_result = E_SOURCE_AUTHENTICATION_REJECTED;
+			break;
+		default:
+			g_set_error (
+				error, CAMEL_SERVICE_ERROR,
+				CAMEL_SERVICE_ERROR_CANT_AUTHENTICATE,
+				_("Invalid authentication result code (%d)"),
+				camel_result);
+			source_result = E_SOURCE_AUTHENTICATION_ERROR;
+			break;
+	}
+
+	return source_result;
+}
+
+static void
+e_mail_authenticator_class_init (EMailAuthenticatorClass *class)
+{
+	GObjectClass *object_class;
+
+	g_type_class_add_private (class, sizeof (EMailAuthenticatorPrivate));
+
+	object_class = G_OBJECT_CLASS (class);
+	object_class->set_property = mail_authenticator_set_property;
+	object_class->get_property = mail_authenticator_get_property;
+	object_class->dispose = mail_authenticator_dispose;
+	object_class->finalize = mail_authenticator_finalize;
+
+	g_object_class_install_property (
+		object_class,
+		PROP_MECHANISM,
+		g_param_spec_string (
+			"mechanism",
+			"Mechanism",
+			"Authentication mechanism",
+			NULL,
+			G_PARAM_READWRITE |
+			G_PARAM_CONSTRUCT_ONLY |
+			G_PARAM_STATIC_STRINGS));
+
+	g_object_class_install_property (
+		object_class,
+		PROP_SERVICE,
+		g_param_spec_object (
+			"service",
+			"Service",
+			"The CamelService to authenticate",
+			CAMEL_TYPE_SERVICE,
+			G_PARAM_READWRITE |
+			G_PARAM_CONSTRUCT_ONLY |
+			G_PARAM_STATIC_STRINGS));
+}
+
+static void
+e_mail_authenticator_interface_init (ESourceAuthenticatorInterface *interface)
+{
+	interface->try_password_sync = mail_authenticator_try_password_sync;
+}
+
+static void
+e_mail_authenticator_init (EMailAuthenticator *auth)
+{
+	auth->priv = E_MAIL_AUTHENTICATOR_GET_PRIVATE (auth);
+}
+
+ESourceAuthenticator *
+e_mail_authenticator_new (CamelService *service,
+                          const gchar *mechanism)
+{
+	g_return_val_if_fail (CAMEL_IS_SERVICE (service), NULL);
+
+	return g_object_new (
+		E_TYPE_MAIL_AUTHENTICATOR,
+		"service", service, "mechanism", mechanism, NULL);
+}
+
+CamelService *
+e_mail_authenticator_get_service (EMailAuthenticator *auth)
+{
+	g_return_val_if_fail (E_IS_MAIL_AUTHENTICATOR (auth), NULL);
+
+	return auth->priv->service;
+}
+
+const gchar *
+e_mail_authenticator_get_mechanism (EMailAuthenticator *auth)
+{
+	g_return_val_if_fail (E_IS_MAIL_AUTHENTICATOR (auth), NULL);
+
+	return auth->priv->mechanism;
+}
+
diff --git a/libemail-engine/e-mail-authenticator.h b/libemail-engine/e-mail-authenticator.h
new file mode 100644
index 0000000..bcc3299
--- /dev/null
+++ b/libemail-engine/e-mail-authenticator.h
@@ -0,0 +1,76 @@
+/*
+ * e-mail-authenticator.h
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) version 3.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with the program; if not, see <http://www.gnu.org/licenses/>
+ *
+ */
+
+#ifndef E_MAIL_AUTHENTICATOR_H
+#define E_MAIL_AUTHENTICATOR_H
+
+#include <camel/camel.h>
+#include <libedataserver/e-source-authenticator.h>
+
+/* Standard GObject macros */
+#define E_TYPE_MAIL_AUTHENTICATOR \
+	(e_mail_authenticator_get_type ())
+#define E_MAIL_AUTHENTICATOR(obj) \
+	(G_TYPE_CHECK_INSTANCE_CAST \
+	((obj), E_TYPE_MAIL_AUTHENTICATOR, EMailAuthenticator))
+#define E_MAIL_AUTHENTICATOR_CLASS(cls) \
+	(G_TYPE_CHECK_CLASS_CAST \
+	((cls), E_TYPE_MAIL_AUTHENTICATOR, EMailAuthenticatorClass))
+#define E_IS_MAIL_AUTHENTICATOR(obj) \
+	(G_TYPE_CHECK_INSTANCE_TYPE \
+	((obj), E_TYPE_MAIL_AUTHENTICATOR))
+#define E_IS_MAIL_AUTHENTICATOR_CLASS(cls) \
+	(G_TYPE_CHECK_CLASS_TYPE \
+	((cls), E_TYPE_MAIL_AUTHENTICATOR))
+#define E_MAIL_AUTHENTICATOR_GET_CLASS(obj) \
+	(G_TYPE_INSTANCE_GET_CLASS \
+	((obj), E_TYPE_MAIL_AUTHENTICATOR, EMailAuthenticatorClass))
+
+G_BEGIN_DECLS
+
+typedef struct _EMailAuthenticator EMailAuthenticator;
+typedef struct _EMailAuthenticatorClass EMailAuthenticatorClass;
+typedef struct _EMailAuthenticatorPrivate EMailAuthenticatorPrivate;
+
+/**
+ * EMailAuthenticator:
+ *
+ * Contains only private data that should be read and manipulated using the
+ * functions below.
+ **/
+struct _EMailAuthenticator {
+	GObject parent;
+	EMailAuthenticatorPrivate *priv;
+};
+
+struct _EMailAuthenticatorClass {
+	GObjectClass parent_class;
+};
+
+GType		e_mail_authenticator_get_type	(void);
+ESourceAuthenticator *
+		e_mail_authenticator_new	(CamelService *service,
+						 const gchar *mechanism);
+CamelService *	e_mail_authenticator_get_service
+						(EMailAuthenticator *auth);
+const gchar *	e_mail_authenticator_get_mechanism
+						(EMailAuthenticator *auth);
+
+G_END_DECLS
+
+#endif /* E_MAIL_AUTHENTICATOR_H */
diff --git a/libemail-engine/e-mail-session-utils.c b/libemail-engine/e-mail-session-utils.c
index 6aa090e..2b2b94c 100644
--- a/libemail-engine/e-mail-session-utils.c
+++ b/libemail-engine/e-mail-session-utils.c
@@ -23,11 +23,11 @@
 #include "e-mail-session-utils.h"
 
 #include <glib/gi18n-lib.h>
+#include <libedataserver/e-source-mail-submission.h>
 
 #include <libemail-engine/e-mail-folder-utils.h>
 #include <libemail-engine/e-mail-utils.h>
 #include <libemail-engine/mail-tools.h>
-#include <libemail-utils/e-account-utils.h>
 
 /* X-Mailer header value */
 #define X_MAILER ("Evolution " VERSION SUB_VERSION " " VERSION_COMMENT)
@@ -648,7 +648,8 @@ e_mail_session_send_to (EMailSession *session,
 	CamelAddress *recipients;
 	CamelMedium *medium;
 	CamelMessageInfo *info;
-	EAccount *account = NULL;
+	ESourceRegistry *registry;
+	ESource *source = NULL;
 	GPtrArray *post_to_uris;
 	struct _camel_header_raw *xev;
 	struct _camel_header_raw *header;
@@ -661,6 +662,8 @@ e_mail_session_send_to (EMailSession *session,
 	g_return_if_fail (E_IS_MAIL_SESSION (session));
 	g_return_if_fail (CAMEL_IS_MIME_MESSAGE (message));
 
+	registry = e_mail_session_get_registry (session);
+
 	medium = CAMEL_MEDIUM (message);
 
 	camel_medium_set_header (medium, "X-Mailer", X_MAILER);
@@ -669,28 +672,25 @@ e_mail_session_send_to (EMailSession *session,
 
 	/* Extract directives from X-Evolution headers. */
 
-	string = camel_header_raw_find (&xev, "X-Evolution-Account", NULL);
+	string = camel_header_raw_find (&xev, "X-Evolution-Identity", NULL);
 	if (string != NULL) {
-		gchar *account_uid;
-
-		account_uid = g_strstrip (g_strdup (string));
-		account = e_get_account_by_uid (account_uid);
-		g_free (account_uid);
+		gchar *uid = g_strstrip (g_strdup (string));
+		source = e_source_registry_lookup_by_uid (registry, uid);
+		g_free (uid);
 	}
 
-	if (account != NULL) {
-		if (account->transport != NULL) {
+	if (E_IS_SOURCE (source)) {
+		ESourceMailSubmission *extension;
+		const gchar *extension_name;
 
-			/* XXX Transport UIDs are kludgy right now.  We
-			 *     use the EAccount's regular UID and tack on
-			 *     "-transport".  Will be better soon. */
-			transport_uid = g_strconcat (
-				account->uid, "-transport", NULL);
+		extension_name = E_SOURCE_EXTENSION_MAIL_SUBMISSION;
+		extension = e_source_get_extension (source, extension_name);
 
-			/* to reprompt password on sending if needed */
-			account->transport->get_password_canceled = FALSE;
-		}
-		sent_folder_uri = g_strdup (account->sent_folder_uri);
+		string = e_source_mail_submission_get_sent_folder (extension);
+		sent_folder_uri = g_strdup (string);
+
+		string = e_source_mail_submission_get_transport_uid (extension);
+		transport_uid = g_strdup (string);
 	}
 
 	string = camel_header_raw_find (&xev, "X-Evolution-Fcc", NULL);
diff --git a/libemail-engine/e-mail-session.c b/libemail-engine/e-mail-session.c
index 193756f..63ac356 100644
--- a/libemail-engine/e-mail-session.c
+++ b/libemail-engine/e-mail-session.c
@@ -45,15 +45,22 @@
 #include <libedataserver/e-flag.h>
 #include <libedataserver/e-proxy.h>
 #include <libebackend/e-extensible.h>
+#include <libedataserver/e-source-authentication.h>
+#include <libedataserver/e-source-camel.h>
+#include <libedataserver/e-source-mail-account.h>
+#include <libedataserver/e-source-mail-identity.h>
+#include <libedataserver/e-source-mail-submission.h>
+#include <libedataserver/e-source-mail-transport.h>
+#include <libedataserver/e-source-refresh.h>
 #include <libedataserverui/e-passwords.h>
 #include <libedataserver/e-data-server-util.h>
 
-#include "libemail-utils/e-account-utils.h"
 #include "libemail-utils/mail-mt.h"
 
 /* This is our hack, not part of libcamel. */
 #include "camel-null-store.h"
 
+#include "e-mail-authenticator.h"
 #include "e-mail-junk-filter.h"
 #include "e-mail-session.h"
 #include "e-mail-folder-utils.h"
@@ -70,9 +77,13 @@ typedef struct _AsyncContext AsyncContext;
 
 struct _EMailSessionPrivate {
 	MailFolderCache *folder_cache;
+	ESourceRegistry *registry;
 
-	EAccountList *account_list;
-	gulong account_added_handler_id;
+	/* ESource UID -> Timeout ID */
+	GHashTable *auto_refresh_table;
+
+	gulong source_added_handler_id;
+	gulong source_removed_handler_id;
 
 	CamelStore *local_store;
 	CamelStore *vfolder_store;
@@ -101,6 +112,7 @@ enum {
 	PROP_FOLDER_CACHE,
 	PROP_JUNK_FILTER_NAME,
 	PROP_LOCAL_STORE,
+	PROP_REGISTRY,
 	PROP_VFOLDER_STORE
 };
 
@@ -115,6 +127,7 @@ static const gchar *local_folder_names[E_MAIL_NUM_LOCAL_FOLDERS] = {
 
 enum {
 	FLUSH_OUTBOX,
+	REFRESH_SERVICE,
 	STORE_ADDED,
 	STORE_REMOVED,
 	LAST_SIGNAL
@@ -317,21 +330,66 @@ async_context_free (AsyncContext *context)
 }
 
 static gchar *
-mail_session_make_key (CamelService *service,
-                       const gchar *item)
+mail_session_resolve_popb4smtp (ESourceRegistry *registry,
+                                CamelService *smtp_service)
 {
-	gchar *key;
+	GList *list, *link;
+	const gchar *extension_name;
+	const gchar *smtp_uid;
+	gchar *pop_uid = NULL;
 
-	if (service != NULL) {
-		CamelURL *url;
+	/* Find a POP account that uses the given smtp_service as its
+	 * transport.  XXX This isn't foolproof though, since we don't
+	 * check that the POP server is at the same domain as the SMTP
+	 * server, which is kind of the point of POPB4SMTP. */
 
-		url = camel_service_new_camel_url (service);
-		key = camel_url_to_string (url, CAMEL_URL_HIDE_ALL);
-		camel_url_free (url);
-	} else
-		key = g_strdup (item);
+	smtp_uid = camel_service_get_uid (smtp_service);
+
+	extension_name = E_SOURCE_EXTENSION_MAIL_ACCOUNT;
+	list = e_source_registry_list_sources (registry, extension_name);
+
+	for (link = list; link != NULL; link = g_list_next (link)) {
+		ESource *source = E_SOURCE (link->data);
+		ESourceExtension *extension;
+		const gchar *backend_name;
+		const gchar *uid;
+
+		extension_name = E_SOURCE_EXTENSION_MAIL_ACCOUNT;
+		extension = e_source_get_extension (source, extension_name);
+
+		/* We're only interested in POP accounts. */
+
+		backend_name = e_source_backend_get_backend_name (
+			E_SOURCE_BACKEND (extension));
+		if (g_strcmp0 (backend_name, "pop") != 0)
+			continue;
+
+		/* Get the mail account's default mail identity. */
+
+		source = e_source_mail_account_get_identity (
+			E_SOURCE_MAIL_ACCOUNT (extension));
+		if (source == NULL)
+			continue;
+
+		/* Get the mail identity's default mail transport. */
+
+		extension_name = E_SOURCE_EXTENSION_MAIL_SUBMISSION;
+		extension = e_source_get_extension (source, extension_name);
+
+		uid = e_source_mail_submission_get_transport_uid (
+			E_SOURCE_MAIL_SUBMISSION (extension));
+		if (uid == NULL)
+			continue;
 
-	return key;
+		if (g_strcmp0 (uid, smtp_uid) == 0) {
+			pop_uid = g_strdup (uid);
+			break;
+		}
+	}
+
+	g_list_free (list);
+
+	return pop_uid;
 }
 
 static void
@@ -406,135 +464,142 @@ mail_session_set_junk_filter_name (EMailSession *session,
 }
 
 static void
-mail_session_add_by_account (EMailSession *session,
-                             EAccount *account)
-{
-	CamelService *service = NULL;
-	CamelProvider *provider;
-	CamelURL *url = NULL;
-	const gchar *protocol = NULL;
-	gboolean have_source_url;
-	GError *error = NULL;
-
-	have_source_url =
-		(account->source != NULL) &&
-		(account->source->url != NULL);
+mail_session_refresh_cb (ESource *source,
+                         CamelSession *session)
+{
+	CamelService *service;
+	const gchar *uid;
 
-	if (have_source_url)
-		url = camel_url_new (account->source->url, NULL);
+	uid = e_source_get_uid (source);
+	service = camel_session_get_service (session, uid);
+	g_return_if_fail (CAMEL_IS_SERVICE (service));
 
-	protocol = (url != NULL) ? url->protocol : "none";
-	provider = camel_provider_get (protocol, &error);
+	g_signal_emit (session, signals[REFRESH_SERVICE], 0, service);
+}
 
-	if (url != NULL)
-		camel_url_free (url);
+static void
+mail_session_add_from_source (EMailSession *session,
+                              CamelProviderType type,
+                              ESource *source)
+{
+	ESourceBackend *extension;
+	const gchar *uid;
+	const gchar *backend_name;
+	const gchar *display_name;
+	const gchar *extension_name;
+	GError *error = NULL;
 
-	if (error != NULL) {
-		g_warn_if_fail (provider == NULL);
-		g_warning ("%s", error->message);
-		g_error_free (error);
-		return;
+	switch (type) {
+		case CAMEL_PROVIDER_STORE:
+			extension_name = E_SOURCE_EXTENSION_MAIL_ACCOUNT;
+			break;
+		case CAMEL_PROVIDER_TRANSPORT:
+			extension_name = E_SOURCE_EXTENSION_MAIL_TRANSPORT;
+			break;
+		default:
+			g_return_if_reached ();
 	}
 
-	g_return_if_fail (provider != NULL);
+	uid = e_source_get_uid (source);
+	display_name = e_source_get_display_name (source);
 
-	/* Load the service, but don't connect.  Check its provider,
-	 * and if this belongs in the folder tree model, add it. */
+	extension = e_source_get_extension (source, extension_name);
+	backend_name = e_source_backend_get_backend_name (extension);
 
-	service = camel_session_add_service (
-		CAMEL_SESSION (session),
-		account->uid, provider->protocol,
-		CAMEL_PROVIDER_STORE, &error);
+	/* Sanity checks. */
+	g_return_if_fail (uid != NULL);
+	g_return_if_fail (backend_name != NULL);
+
+	/* Our own CamelSession.add_service() method will handle the
+	 * resulting CamelService, so we don't need the return value. */
+	camel_session_add_service (
+		CAMEL_SESSION (session), uid,
+		backend_name, type, &error);
 
 	if (error != NULL) {
 		g_warning (
-			"Failed to add service: %s: %s",
-			account->name, error->message);
+			"Failed to add service '%s' (%s): %s",
+			display_name, uid, error->message);
 		g_error_free (error);
-		return;
 	}
 
-	camel_service_set_display_name (service, account->name);
-
-	/* While we're at it, add the account's transport (if it has one)
-	 * to the CamelSession.  The transport's UID is a kludge for now.
-	 * We take the EAccount's UID and tack on "-transport". */
+	/* Set up auto-refresh. */
+	extension_name = E_SOURCE_EXTENSION_REFRESH;
+	if (e_source_has_extension (source, extension_name)) {
+		guint timeout_id;
 
-	if (account->transport) {
-		GError *transport_error = NULL;
+		/* Transports should not have a refresh extension. */
+		g_warn_if_fail (type != CAMEL_PROVIDER_TRANSPORT);
 
-		url = camel_url_new (
-			account->transport->url,
-			&transport_error);
+		timeout_id = e_source_refresh_add_timeout (
+			source, NULL, (ESourceRefreshFunc)
+			mail_session_refresh_cb, session,
+			(GDestroyNotify) NULL);
 
-		if (url != NULL) {
-			provider = camel_provider_get (
-				url->protocol, &transport_error);
-			camel_url_free (url);
-		} else
-			provider = NULL;
+		g_hash_table_insert (
+			session->priv->auto_refresh_table,
+			g_strdup (uid),
+			GUINT_TO_POINTER (timeout_id));
+	}
+}
 
-		if (provider != NULL) {
-			gchar *transport_uid;
+static void
+mail_session_source_added_cb (ESourceRegistry *registry,
+                              ESource *source,
+                              EMailSession *session)
+{
+	CamelProviderType provider_type;
+	const gchar *extension_name;
 
-			transport_uid = g_strconcat (
-				account->uid, "-transport", NULL);
+	provider_type = CAMEL_PROVIDER_STORE;
+	extension_name = E_SOURCE_EXTENSION_MAIL_ACCOUNT;
 
-			camel_session_add_service (
-				CAMEL_SESSION (session),
-				transport_uid, provider->protocol,
-				CAMEL_PROVIDER_TRANSPORT, &transport_error);
+	if (e_source_has_extension (source, extension_name))
+		mail_session_add_from_source (session, provider_type, source);
 
-			g_free (transport_uid);
-		}
+	provider_type = CAMEL_PROVIDER_TRANSPORT;
+	extension_name = E_SOURCE_EXTENSION_MAIL_TRANSPORT;
 
-		if (transport_error) {
-			g_warning (
-				"%s: Failed to add transport service: %s",
-				G_STRFUNC, transport_error->message);
-			g_error_free (transport_error);
-		}
-	}
+	if (e_source_has_extension (source, extension_name))
+		mail_session_add_from_source (session, provider_type, source);
 }
 
 static void
-mail_session_account_added_cb (EAccountList *account_list,
-                               EAccount *account,
-                               EMailSession *session)
+mail_session_source_removed_cb (ESourceRegistry *registry,
+                                ESource *source,
+                                EMailSession *session)
 {
-	mail_session_add_by_account (session, account);
+	CamelSession *camel_session;
+	CamelService *service;
+	const gchar *uid;
+
+	camel_session = CAMEL_SESSION (session);
+
+	uid = e_source_get_uid (source);
+	service = camel_session_get_service (camel_session, uid);
+
+	if (CAMEL_IS_SERVICE (service))
+		camel_session_remove_service (camel_session, service);
 }
 
 static void
-mail_session_add_local_store (EMailSession *session)
+mail_session_configure_local_store (EMailSession *session)
 {
 	CamelLocalSettings *local_settings;
 	CamelSession *camel_session;
 	CamelSettings *settings;
 	CamelService *service;
 	const gchar *data_dir;
+	const gchar *uid;
 	gchar *path;
 	gint ii;
-	GError *error = NULL;
 
 	camel_session = CAMEL_SESSION (session);
 
-	service = camel_session_add_service (
-		camel_session, E_MAIL_SESSION_LOCAL_UID,
-		"maildir", CAMEL_PROVIDER_STORE, &error);
-
-	/* XXX One could argue this is a fatal error
-	 *     since we depend on it in so many places. */
-	if (error != NULL) {
-		g_critical ("%s: %s", G_STRFUNC, error->message);
-		g_error_free (error);
-		return;
-	}
-
+	uid = E_MAIL_SESSION_LOCAL_UID;
+	service = camel_session_get_service (camel_session, uid);
 	g_return_if_fail (CAMEL_IS_SERVICE (service));
 
-	camel_service_set_display_name (service, _("On This Computer"));
-
 	settings = camel_service_get_settings (service);
 	local_settings = CAMEL_LOCAL_SETTINGS (settings);
 	data_dir = camel_session_get_user_data_dir (camel_session);
@@ -582,6 +647,105 @@ mail_session_add_local_store (EMailSession *session)
 }
 
 static void
+mail_session_force_refresh (EMailSession *session)
+{
+	ESourceRegistry *registry;
+	GHashTableIter iter;
+	GSettings *settings;
+	gboolean unconditionally;
+	gpointer key;
+
+	/* Only refresh when the session is online. */
+	if (!camel_session_get_online (CAMEL_SESSION (session)))
+		return;
+
+	/* FIXME EMailSession should define properties for these. */
+	settings = g_settings_new ("org.gnome.evolution.mail");
+	unconditionally =
+		g_settings_get_boolean (settings, "send-recv-on-start") &&
+		g_settings_get_boolean (settings, "send-recv-all-on-start");
+	g_object_unref (settings);
+
+	registry = e_mail_session_get_registry (session);
+	g_hash_table_iter_init (&iter, session->priv->auto_refresh_table);
+
+	while (g_hash_table_iter_next (&iter, &key, NULL)) {
+		ESource *source;
+		ESourceRefresh *extension;
+		const gchar *extension_name;
+		gboolean refresh_enabled;
+
+		/* The hash table key is the ESource UID. */
+		source = e_source_registry_lookup_by_uid (registry, key);
+
+		if (source == NULL)
+			continue;
+
+		extension_name = E_SOURCE_EXTENSION_REFRESH;
+		extension = e_source_get_extension (source, extension_name);
+		refresh_enabled = e_source_refresh_get_enabled (extension);
+
+		if (refresh_enabled || unconditionally)
+			e_source_refresh_force_timeout (source);
+	}
+}
+
+static void
+mail_session_cancel_refresh (EMailSession *session)
+{
+	ESourceRegistry *registry;
+	GHashTableIter iter;
+	gpointer key, value;
+
+	registry = e_mail_session_get_registry (session);
+	g_hash_table_iter_init (&iter, session->priv->auto_refresh_table);
+
+	while (g_hash_table_iter_next (&iter, &key, &value)) {
+		ESource *source;
+		guint timeout_id;
+
+		/* The hash table key is the ESource UID. */
+		source = e_source_registry_lookup_by_uid (registry, key);
+
+		/* The hash table value is the refresh timeout ID. */
+		timeout_id = GPOINTER_TO_UINT (value);
+
+		if (source == NULL)
+			continue;
+
+		e_source_refresh_remove_timeout (source, timeout_id);
+	}
+
+	/* All timeouts cancelled so clear the auto-refresh table. */
+	g_hash_table_remove_all (session->priv->auto_refresh_table);
+}
+
+static gboolean
+mail_session_idle_refresh_cb (EMailSession *session)
+{
+	/* This only runs once at startup (if settings allow). */
+
+	if (camel_session_get_online (CAMEL_SESSION (session))) {
+		mail_session_force_refresh (session);
+
+		/* Also flush the Outbox. */
+		g_signal_emit (session, signals[FLUSH_OUTBOX], 0);
+	}
+
+	return FALSE;
+}
+
+static void
+mail_session_set_registry (EMailSession *session,
+                           ESourceRegistry *registry)
+{
+	g_return_if_fail (E_IS_SOURCE_REGISTRY (registry));
+	g_return_if_fail (session->priv->registry == NULL);
+
+	session->priv->registry = g_object_ref (registry);
+}
+
+static void
 mail_session_set_property (GObject *object,
                            guint property_id,
                            const GValue *value,
@@ -593,6 +757,12 @@ mail_session_set_property (GObject *object,
 				E_MAIL_SESSION (object),
 				g_value_get_string (value));
 			return;
+
+		case PROP_REGISTRY:
+			mail_session_set_registry (
+				E_MAIL_SESSION (object),
+				g_value_get_object (value));
+			return;
 	}
 
 	G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
@@ -626,6 +796,13 @@ mail_session_get_property (GObject *object,
 				E_MAIL_SESSION (object)));
 			return;
 
+		case PROP_REGISTRY:
+			g_value_set_object (
+				value,
+				e_mail_session_get_registry (
+				E_MAIL_SESSION (object)));
+			return;
+
 		case PROP_VFOLDER_STORE:
 			g_value_set_object (
 				value,
@@ -649,12 +826,19 @@ mail_session_dispose (GObject *object)
 		priv->folder_cache = NULL;
 	}
 
-	if (priv->account_list != NULL) {
+	if (priv->registry != NULL) {
 		g_signal_handler_disconnect (
-			priv->account_list,
-			priv->account_added_handler_id);
-		g_object_unref (priv->account_list);
-		priv->account_list = NULL;
+			priv->registry,
+			priv->source_added_handler_id);
+		g_signal_handler_disconnect (
+			priv->registry,
+			priv->source_removed_handler_id);
+
+		/* This requires the registry. */
+		mail_session_cancel_refresh (E_MAIL_SESSION (object));
+
+		g_object_unref (priv->registry);
+		priv->registry = NULL;
 	}
 
 	if (priv->local_store != NULL) {
@@ -674,27 +858,18 @@ mail_session_dispose (GObject *object)
 }
 
 static void
-mail_session_add_vfolder_store (EMailSession *session)
+mail_session_configure_vfolder_store (EMailSession *session)
 {
 	CamelSession *camel_session;
 	CamelService *service;
-	GError *error = NULL;
+	const gchar *uid;
 
 	camel_session = CAMEL_SESSION (session);
 
-	service = camel_session_add_service (
-		camel_session, E_MAIL_SESSION_VFOLDER_UID,
-		"vfolder", CAMEL_PROVIDER_STORE, &error);
-
-	if (error != NULL) {
-		g_critical ("%s: %s", G_STRFUNC, error->message);
-		g_error_free (error);
-		return;
-	}
-
+	uid = E_MAIL_SESSION_VFOLDER_UID;
+	service = camel_session_get_service (camel_session, uid);
 	g_return_if_fail (CAMEL_IS_SERVICE (service));
 
-	camel_service_set_display_name (service, _("Search Folders"));
 	em_utils_connect_service_sync (service, NULL, NULL);
 
 	/* XXX There's more configuration to do in vfolder_load_storage()
@@ -712,6 +887,7 @@ mail_session_finalize (GObject *object)
 
 	priv = E_MAIL_SESSION_GET_PRIVATE (object);
 
+	g_hash_table_destroy (priv->auto_refresh_table);
 	g_hash_table_destroy (priv->junk_filters);
 	g_object_unref (priv->proxy);
 
@@ -731,79 +907,81 @@ mail_session_notify (GObject *object,
 {
 	/* GObject does not implement this method; do not chain up. */
 
+	/* CamelSession defines this property. */
+	if (g_strcmp0 (pspec->name, "online") == 0)
+		mail_session_force_refresh (E_MAIL_SESSION (object));
+
 	/* XXX Delete this once Evolution moves to GSettings and
 	 *     we're able to get rid of PROP_JUNK_FILTER_NAME. */
 	if (g_strcmp0 (pspec->name, "junk-filter") == 0)
 		g_object_notify (object, "junk-filter-name");
 }
 
-static gboolean
-mail_session_initialize_stores_idle (gpointer user_data)
-{
-	EMailSession *session = user_data;
-	EAccountList *account_list;
-	EAccount *account;
-	EIterator *iter;
-
-	g_return_val_if_fail (session != NULL, FALSE);
-
-	account_list = e_get_account_list ();
-	iter = e_list_get_iterator (E_LIST (account_list));
-
-	while (e_iterator_is_valid (iter)) {
-		/* XXX EIterator misuses const. */
-		account = (EAccount *) e_iterator_get (iter);
-
-		mail_session_add_by_account (session, account);
-
-		e_iterator_next (iter);
-	}
-
-	g_object_unref (iter);
-
-	return FALSE;
-}
-
 static void
 mail_session_constructed (GObject *object)
 {
 	EMailSession *session;
 	EExtensible *extensible;
+	ESourceRegistry *registry;
 	GType extension_type;
 	GList *list, *link;
 	GSettings *settings;
-	EAccountList *account_list;
+	CamelProviderType provider_type;
+	const gchar *extension_name;
 	gulong handler_id;
 
 	session = E_MAIL_SESSION (object);
+	registry = e_mail_session_get_registry (session);
 
 	/* Chain up to parent's constructed() method. */
 	G_OBJECT_CLASS (e_mail_session_parent_class)->constructed (object);
 
-	account_list = e_get_account_list ();
-	session->priv->account_list = g_object_ref (account_list);
+	/* Add available mail accounts. */
 
-	/* This must be created after the account store. */
-	session->priv->folder_cache = mail_folder_cache_new (session);
+	provider_type = CAMEL_PROVIDER_STORE;
+	extension_name = E_SOURCE_EXTENSION_MAIL_ACCOUNT;
 
-	/* Add built-in CamelStores. */
-	mail_session_add_local_store (session);
-	mail_session_add_vfolder_store (session);
+	list = e_source_registry_list_sources (registry, extension_name);
 
-	/* Give it a chance to load user settings, they are not loaded yet.
-	 *
-	 * XXX Is this the case where hiding such natural things like loading
-	 *     user setting into an EExtension strikes back and proves itself
-	 *     being suboptimal?
-	 */
-	g_idle_add (mail_session_initialize_stores_idle, object);
+	for (link = list; link != NULL; link = g_list_next (link)) {
+		ESource *source = E_SOURCE (link->data);
+
+		mail_session_add_from_source (session, provider_type, source);
+	}
+
+	g_list_free (list);
+
+	/* Add available mail transports. */
+
+	provider_type = CAMEL_PROVIDER_TRANSPORT;
+	extension_name = E_SOURCE_EXTENSION_MAIL_TRANSPORT;
+
+	list = e_source_registry_list_sources (registry, extension_name);
 
-	/* Listen for account list updates. */
+	for (link = list; link != NULL; link = g_list_next (link)) {
+		ESource *source = E_SOURCE (link->data);
+
+		mail_session_add_from_source (session, provider_type, source);
+	}
+
+	g_list_free (list);
+
+	/* Built-in stores require extra configuration. */
+
+	mail_session_configure_local_store (session);
+	mail_session_configure_vfolder_store (session);
+
+	/* Listen for registry changes. */
 
 	handler_id = g_signal_connect (
-		account_list, "account-added",
-		G_CALLBACK (mail_session_account_added_cb), session);
-	session->priv->account_added_handler_id = handler_id;
+		registry, "source-added",
+		G_CALLBACK (mail_session_source_added_cb), session);
+	session->priv->source_added_handler_id = handler_id;
+
+	handler_id = g_signal_connect (
+		registry, "source-removed",
+		G_CALLBACK (mail_session_source_removed_cb), session);
+	session->priv->source_removed_handler_id = handler_id;
 
 	extensible = E_EXTENSIBLE (object);
 	e_extensible_load_extensions (extensible);
@@ -852,14 +1030,29 @@ mail_session_constructed (GObject *object)
 
 	g_list_free (list);
 
+	settings = g_settings_new ("org.gnome.evolution.mail");
+
 	/* Bind the "junk-default-plugin" GSettings
 	 * key to our "junk-filter-name" property. */
 
-	settings = g_settings_new ("org.gnome.evolution.mail");
 	g_settings_bind (
 		settings, "junk-default-plugin",
 		object, "junk-filter-name",
 		G_SETTINGS_BIND_DEFAULT);
+
+	/* Initialize the legacy message-passing framework
+	 * before starting the first mail store refresh. */
+	mail_msg_init ();
+
+	/* The application is not yet fully initialized at this point,
+	 * so run the first mail store refresh from an idle callback. */
+	if (g_settings_get_boolean (settings, "send-recv-on-start"))
+		g_idle_add_full (
+			G_PRIORITY_DEFAULT,
+			(GSourceFunc) mail_session_idle_refresh_cb,
+			g_object_ref (session),
+			(GDestroyNotify) g_object_unref);
+
 	g_object_unref (settings);
 }
 
@@ -870,53 +1063,37 @@ mail_session_add_service (CamelSession *session,
                           CamelProviderType type,
                           GError **error)
 {
+	ESourceRegistry *registry;
 	CamelService *service;
 
+	registry = e_mail_session_get_registry (E_MAIL_SESSION (session));
+
 	/* Chain up to parents add_service() method. */
 	service = CAMEL_SESSION_CLASS (e_mail_session_parent_class)->
 		add_service (session, uid, protocol, type, error);
 
-	/* Initialize the CamelSettings object from CamelURL parameters.
-	 * This is temporary; soon we'll read settings from key files. */
+	/* Configure the CamelService from the corresponding ESource. */
 
 	if (CAMEL_IS_SERVICE (service)) {
-		EAccount *account;
-		CamelURL *url = NULL;
-
-		account = e_get_account_by_uid (uid);
-		if (account != NULL) {
-			const gchar *url_string = NULL;
-
-			switch (type) {
-				case CAMEL_PROVIDER_STORE:
-					url_string = account->source->url;
-					break;
-				case CAMEL_PROVIDER_TRANSPORT:
-					url_string = account->transport->url;
-					break;
-				default:
-					break;
-			}
-
-			/* Be lenient about malformed URLs. */
-			if (url_string != NULL)
-				url = camel_url_new (url_string, NULL);
-		}
+		ESource *source;
 
-		if (url != NULL) {
-			CamelSettings *settings;
+		/* Each CamelService has a corresponding ESource. */
+		source = e_source_registry_lookup_by_uid (registry, uid);
+		g_return_val_if_fail (E_IS_SOURCE (source), service);
 
-			settings = camel_service_get_settings (service);
-			camel_settings_load_from_url (settings, url);
-			camel_url_free (url);
+		/* This handles all the messy property bindings. */
+		e_source_camel_configure_service (source, service);
 
-			g_object_notify (G_OBJECT (service), "settings");
+		g_object_bind_property (
+			source, "display-name",
+			service, "display-name",
+			G_BINDING_BIDIRECTIONAL |
+			G_BINDING_SYNC_CREATE);
 
-			/* Migrate files for this service from its old
-			 * URL-based directory to a UID-based directory
-			 * if necessary. */
-			camel_service_migrate_files (service);
-		}
+		/* Migrate files for this service from its old
+		 * URL-based directory to a UID-based directory
+		 * if necessary. */
+		camel_service_migrate_files (service);
 	}
 
 	return service;
@@ -930,114 +1107,69 @@ mail_session_get_password (CamelSession *session,
                            guint32 flags,
                            GError **error)
 {
-	EAccount *account = NULL;
-	const gchar *display_name = NULL;
-	const gchar *uid = NULL;
-	gchar *ret = NULL;
+	ESourceRegistry *registry;
+	gchar *password = NULL;
 
-	if (CAMEL_IS_SERVICE (service)) {
-		display_name = camel_service_get_display_name (service);
-		uid = camel_service_get_uid (service);
-		account = e_get_account_by_uid (uid);
-	}
+	/* XXX This method is now only for fringe cases.  For normal
+	 *     CamelService authentication, use authenticate_sync().
+	 *
+	 *     The two known fringe cases that still need this are:
+	 *
+	 *     1) CamelSaslPOPB4SMTP, where the CamelService is an SMTP
+	 *        transport and the item name is always "popb4smtp_uid".
+	 *        (This is a dirty hack, Camel just needs some way to
+	 *        pair up a CamelService and CamelTransport.  Not sure
+	 *        what that should look like just yet...)
+	 *
+	 *     2) CamelGpgContext, where the CamelService is NULL and
+	 *        the item name is a user ID (I think).  (Seahorse, or
+	 *        one of its dependent libraries, ought to handle this
+	 *        transparently once Camel fully transitions to GIO.)
+	 */
 
-	if (!strcmp(item, "popb4smtp_uid")) {
-		/* not 100% mt safe, but should be ok */
-		ret = g_strdup ((account != NULL) ? account->uid : uid);
-	} else {
-		gchar *key = mail_session_make_key (service, item);
-		EAccountService *config_service = NULL;
-
-		ret = e_passwords_get_password (NULL, key);
-		if (ret == NULL || (flags & CAMEL_SESSION_PASSWORD_REPROMPT)) {
-			gboolean remember;
-
-			g_free (ret);
-			ret = NULL;
-
-			if (account != NULL) {
-				if (CAMEL_IS_STORE (service))
-					config_service = account->source;
-				if (CAMEL_IS_TRANSPORT (service))
-					config_service = account->transport;
-			}
+	registry = e_mail_session_get_registry (E_MAIL_SESSION (session));
 
-			remember = config_service ? config_service->save_passwd : FALSE;
-
-			if (!config_service || (config_service &&
-				!config_service->get_password_canceled)) {
-				guint32 eflags;
-				gchar *title;
-
-				if (flags & CAMEL_SESSION_PASSPHRASE) {
-					if (display_name != NULL)
-						title = g_strdup_printf (
-							_("Enter Passphrase for %s"),
-							display_name);
-					else
-						title = g_strdup (
-							_("Enter Passphrase"));
-				} else {
-					if (display_name != NULL)
-						title = g_strdup_printf (
-							_("Enter Password for %s"),
-							display_name);
-					else
-						title = g_strdup (
-							_("Enter Password"));
-				}
-				if ((flags & CAMEL_SESSION_PASSWORD_STATIC) != 0)
-					eflags = E_PASSWORDS_REMEMBER_NEVER;
-				else if (config_service == NULL)
-					eflags = E_PASSWORDS_REMEMBER_SESSION;
-				else
-					eflags = E_PASSWORDS_REMEMBER_FOREVER;
-
-				if (flags & CAMEL_SESSION_PASSWORD_REPROMPT)
-					eflags |= E_PASSWORDS_REPROMPT;
-
-				if (flags & CAMEL_SESSION_PASSWORD_SECRET)
-					eflags |= E_PASSWORDS_SECRET;
-
-				if (flags & CAMEL_SESSION_PASSPHRASE)
-					eflags |= E_PASSWORDS_PASSPHRASE;
-
-				/* HACK: breaks abstraction ...
-				 * e_account_writable() doesn't use the
-				 * EAccount, it also uses the same writable
-				 * key for source and transport. */
-				if (!e_account_writable (NULL, E_ACCOUNT_SOURCE_SAVE_PASSWD))
-					eflags |= E_PASSWORDS_DISABLE_REMEMBER;
-
-				ret = e_passwords_ask_password (
-					title, NULL, key, prompt,
-					eflags, &remember, NULL);
-
-				if (!ret)
-					e_passwords_forget_password (NULL, key);
-
-				g_free (title);
-
-				if (ret && config_service) {
-					config_service->save_passwd = remember;
-					e_account_list_save (e_get_account_list ());
-				}
-
-				if (config_service)
-					config_service->get_password_canceled = ret == NULL;
-			}
-		}
+	/* Handle the CamelSaslPOPB4SMTP case. */
+	if (g_strcmp0 (item, "popb4smtp_uid") == 0)
+		return mail_session_resolve_popb4smtp (registry, service);
 
-		g_free (key);
+	/* Otherwise this had better be the CamelGpgContext case. */
+	g_return_val_if_fail (service == NULL, NULL);
+
+	password = e_passwords_get_password (NULL, item);
+
+	if (password == NULL || (flags & CAMEL_SESSION_PASSWORD_REPROMPT)) {
+		gboolean remember;
+		guint eflags = 0;
+
+		if (flags & CAMEL_SESSION_PASSWORD_STATIC)
+			eflags |= E_PASSWORDS_REMEMBER_NEVER;
+		else
+			eflags |= E_PASSWORDS_REMEMBER_SESSION;
+
+		if (flags & CAMEL_SESSION_PASSWORD_REPROMPT)
+			eflags |= E_PASSWORDS_REPROMPT;
+
+		if (flags & CAMEL_SESSION_PASSWORD_SECRET)
+			eflags |= E_PASSWORDS_SECRET;
+
+		if (flags & CAMEL_SESSION_PASSPHRASE)
+			eflags |= E_PASSWORDS_PASSPHRASE;
+
+		password = e_passwords_ask_password (
+			"", NULL, item, prompt, eflags, &remember, NULL);
+
+		if (password == NULL)
+			e_passwords_forget_password (NULL, item);
 	}
 
-	if (ret == NULL)
+	if (password == NULL)
 		g_set_error (
 			error, G_IO_ERROR,
 			G_IO_ERROR_CANCELLED,
-			_("User canceled operation."));
+			_("User cancelled operation"));
 
-	return ret;
+	return password;
 }
 
 static gboolean
@@ -1046,13 +1178,13 @@ mail_session_forget_password (CamelSession *session,
                               const gchar *item,
                               GError **error)
 {
-	gchar *key;
+	/* XXX The only remaining user of this method is CamelGpgContext,
+	 *     which does not provide a CamelService.  Use 'item' as the
+	 *     password key. */
 
-	key = mail_session_make_key (service, item);
+	g_return_val_if_fail (service == NULL, FALSE);
 
-	e_passwords_forget_password (NULL, key);
-
-	g_free (key);
+	e_passwords_forget_password (NULL, item);
 
 	return TRUE;
 }
@@ -1112,16 +1244,19 @@ static gboolean
 mail_session_lookup_addressbook (CamelSession *session,
                                  const gchar *name)
 {
+	ESourceRegistry *registry;
 	CamelInternetAddress *addr;
 	gboolean ret;
 
 	if (!mail_config_get_lookup_book ())
 		return FALSE;
 
+	registry = e_mail_session_get_registry (E_MAIL_SESSION (session));
+
 	addr = camel_internet_address_new ();
 	camel_address_decode ((CamelAddress *) addr, name);
 	ret = em_utils_in_addressbook (
-		addr, mail_config_get_lookup_book_local_only ());
+		registry, addr, mail_config_get_lookup_book_local_only ());
 	g_object_unref (addr);
 
 	return ret;
@@ -1134,13 +1269,16 @@ mail_session_forward_to (CamelSession *session,
                          const gchar *address,
                          GError **error)
 {
-	EAccount *account;
+	ESource *source;
+	ESourceRegistry *registry;
+	ESourceMailIdentity *extension;
 	CamelMimeMessage *forward;
 	CamelStream *mem;
 	CamelInternetAddress *addr;
 	CamelFolder *out_folder;
 	CamelMessageInfo *info;
 	CamelMedium *medium;
+	const gchar *extension_name;
 	const gchar *from_address;
 	const gchar *from_name;
 	const gchar *header_name;
@@ -1154,22 +1292,27 @@ mail_session_forward_to (CamelSession *session,
 	if (!*address) {
 		g_set_error (
 			error, CAMEL_ERROR, CAMEL_ERROR_GENERIC,
-			_("No destination address provided, forward "
+			_("No destination address provided, forwarding "
 			  "of the message has been cancelled."));
 		return FALSE;
 	}
 
-	account = em_utils_guess_account_with_recipients (message, folder);
-	if (!account) {
+	registry = e_mail_session_get_registry (E_MAIL_SESSION (session));
+
+	source = em_utils_guess_mail_identity_with_recipients (
+		registry, message, folder);
+	if (source == NULL) {
 		g_set_error (
 			error, CAMEL_ERROR, CAMEL_ERROR_GENERIC,
-			_("No account found to use, forward of the "
-			  "message has been cancelled."));
+			_("No identity found to use, forwarding "
+			  "of the message has been cancelled."));
 		return FALSE;
 	}
 
-	from_address = account->id->address;
-	from_name = account->id->name;
+	extension_name = E_SOURCE_EXTENSION_MAIL_IDENTITY;
+	extension = e_source_get_extension (source, extension_name);
+	from_address = e_source_mail_identity_get_address (extension);
+	from_name = e_source_mail_identity_get_name (extension);
 
 	forward = camel_mime_message_new ();
 
@@ -1289,19 +1432,23 @@ mail_session_authenticate_sync (CamelSession *session,
                                 GCancellable *cancellable,
                                 GError **error)
 {
+	ESource *source;
+	ESourceRegistry *registry;
+	ESourceAuthenticator *auth;
 	CamelServiceAuthType *authtype = NULL;
 	CamelAuthenticationResult result;
-	CamelProvider *provider;
-	CamelSettings *settings;
-	const gchar *password;
-	guint32 password_flags;
+	const gchar *uid;
+	gboolean authenticated;
 	GError *local_error = NULL;
 
 	/* Do not chain up.  Camel's default method is only an example for
 	 * subclasses to follow.  Instead we mimic most of its logic here. */
 
-	provider = camel_service_get_provider (service);
-	settings = camel_service_get_settings (service);
+	registry = e_mail_session_get_registry (E_MAIL_SESSION (session));
+
+	/* Treat a mechanism name of "none" as NULL. */
+	if (g_strcmp0 (mechanism, "none") == 0)
+		mechanism = NULL;
 
 	/* APOP is one case where a non-SASL mechanism name is passed, so
 	 * don't bail if the CamelServiceAuthType struct comes back NULL. */
@@ -1354,58 +1501,26 @@ mail_session_authenticate_sync (CamelSession *session,
 
 	g_clear_error (&local_error);
 
-	password_flags = CAMEL_SESSION_PASSWORD_SECRET;
-
-retry:
-	password = camel_service_get_password (service);
-
-	if (password == NULL) {
-		CamelNetworkSettings *network_settings;
-		const gchar *host;
-		const gchar *user;
-		gchar *prompt;
-		gchar *new_passwd;
-
-		network_settings = CAMEL_NETWORK_SETTINGS (settings);
-		host = camel_network_settings_get_host (network_settings);
-		user = camel_network_settings_get_user (network_settings);
+	/* Find a matching ESource for this CamelService. */
+	uid = camel_service_get_uid (service);
+	source = e_source_registry_lookup_by_uid (registry, uid);
 
-		prompt = camel_session_build_password_prompt (
-			provider->name, user, host);
-
-		new_passwd = camel_session_get_password (
-			session, service, prompt, "password",
-			password_flags, &local_error);
-		camel_service_set_password (service, new_passwd);
-		password = camel_service_get_password (service);
-		g_free (new_passwd);
-
-		g_free (prompt);
-
-		if (local_error != NULL) {
-			g_propagate_error (error, local_error);
-			return FALSE;
-		}
-
-		if (password == NULL) {
-			g_set_error (
-				error, CAMEL_SERVICE_ERROR,
-				CAMEL_SERVICE_ERROR_CANT_AUTHENTICATE,
-				_("No password was provided"));
-			return FALSE;
-		}
+	if (source == NULL) {
+		g_set_error (
+			error, CAMEL_SERVICE_ERROR,
+			CAMEL_SERVICE_ERROR_CANT_AUTHENTICATE,
+			_("No data source found for UID '%s'"), uid);
+		return FALSE;
 	}
 
-	result = camel_service_authenticate_sync (
-		service, mechanism, cancellable, error);
+	auth = e_mail_authenticator_new (service, mechanism);
 
-	if (result == CAMEL_AUTHENTICATION_REJECTED) {
-		password_flags |= CAMEL_SESSION_PASSWORD_REPROMPT;
-		camel_service_set_password (service, NULL);
-		goto retry;
-	}
+	authenticated = e_source_registry_authenticate_sync (
+		registry, source, auth, cancellable, error);
+
+	g_object_unref (auth);
 
-	return (result == CAMEL_AUTHENTICATION_ACCEPTED);
+	return authenticated;
 }
 
 static EMVFolderContext *
@@ -1481,6 +1596,18 @@ e_mail_session_class_init (EMailSessionClass *class)
 
 	g_object_class_install_property (
 		object_class,
+		PROP_REGISTRY,
+		g_param_spec_object (
+			"registry",
+			"Registry",
+			"Data source registry",
+			E_TYPE_SOURCE_REGISTRY,
+			G_PARAM_READWRITE |
+			G_PARAM_CONSTRUCT_ONLY |
+			G_PARAM_STATIC_STRINGS));
+
+	g_object_class_install_property (
+		object_class,
 		PROP_VFOLDER_STORE,
 		g_param_spec_object (
 			"vfolder-store",
@@ -1500,15 +1627,32 @@ e_mail_session_class_init (EMailSessionClass *class)
 		"flush-outbox",
 		G_OBJECT_CLASS_TYPE (object_class),
 		G_SIGNAL_RUN_FIRST,
-		0, /* struct offset */
-		NULL, NULL, /* accumulator */
+		G_STRUCT_OFFSET (EMailSessionClass, flush_outbox),
+		NULL, NULL,
 		g_cclosure_marshal_VOID__VOID,
 		G_TYPE_NONE, 0);
 
 	/**
+	 * EMailSession::refresh-service
+	 * @session: the #EMailSession that emitted the signal
+	 * @service: a #CamelService
+	 *
+	 * Emitted when @service should be refreshed.
+	 **/
+	signals[REFRESH_SERVICE] = g_signal_new (
+		"refresh-service",
+		G_OBJECT_CLASS_TYPE (object_class),
+		G_SIGNAL_RUN_LAST,
+		G_STRUCT_OFFSET (EMailSessionClass, refresh_service),
+		NULL, NULL,
+		g_cclosure_marshal_VOID__OBJECT,
+		G_TYPE_NONE, 1,
+		CAMEL_TYPE_SERVICE);
+
+	/**
 	 * EMailSession::store-added
-	 * @session: the email session
-	 * @store: the CamelStore
+	 * @session: the #EMailSession that emitted the signal
+	 * @store: a #CamelStore
 	 *
 	 * Emitted when a store is added
 	 **/
@@ -1516,16 +1660,16 @@ e_mail_session_class_init (EMailSessionClass *class)
 		"store-added",
 		G_OBJECT_CLASS_TYPE (object_class),
 		G_SIGNAL_RUN_FIRST,
-		0, /* struct offset */
-		NULL, NULL, /* accumulator */
+		G_STRUCT_OFFSET (EMailSessionClass, store_added),
+		NULL, NULL,
 		g_cclosure_marshal_VOID__OBJECT,
 		G_TYPE_NONE, 1,
 		CAMEL_TYPE_STORE);
 
 	/**
 	 * EMailSession::store-removed
-	 * @session: the email session
-	 * @store: the CamelStore
+	 * @session: the #EMailSession that emitted the signal
+	 * @store: a #CamelStore
 	 *
 	 * Emitted when a store is removed 
 	 **/
@@ -1533,26 +1677,38 @@ e_mail_session_class_init (EMailSessionClass *class)
 		"store-removed",
 		G_OBJECT_CLASS_TYPE (object_class),
 		G_SIGNAL_RUN_FIRST,
-		0, /* struct offset */
-		NULL, NULL, /* accumulator */
+		G_STRUCT_OFFSET (EMailSessionClass, store_removed),
+		NULL, NULL,
 		g_cclosure_marshal_VOID__OBJECT,
 		G_TYPE_NONE, 1,
 		CAMEL_TYPE_STORE);
 
 	camel_null_store_register_provider ();
+
+	/* Make sure ESourceCamel picks up the "none" provider. */
+	e_source_camel_register_types ();
 }
 
 static void
 e_mail_session_init (EMailSession *session)
 {
 	GSettings *settings;
+	GHashTable *auto_refresh_table;
 	GHashTable *junk_filters;
 
+	auto_refresh_table = g_hash_table_new_full (
+		(GHashFunc) g_str_hash,
+		(GEqualFunc) g_str_equal,
+		(GDestroyNotify) g_free,
+		(GDestroyNotify) NULL);
+
 	junk_filters = g_hash_table_new (
 		(GHashFunc) g_str_hash,
 		(GEqualFunc) g_str_equal);
 
 	session->priv = E_MAIL_SESSION_GET_PRIVATE (session);
+	session->priv->folder_cache = mail_folder_cache_new (session);
+	session->priv->auto_refresh_table = auto_refresh_table;
 	session->priv->junk_filters = junk_filters;
 	session->priv->proxy = e_proxy_new ();
 
@@ -1563,9 +1719,6 @@ e_mail_session_init (EMailSession *session)
 		g_ptr_array_new_with_free_func (
 		(GDestroyNotify) g_free);
 
-	/* Initialize the EAccount setup. */
-	e_account_writable (NULL, E_ACCOUNT_SOURCE_SAVE_PASSWD);
-
 	settings = g_settings_new ("org.gnome.evolution.mail");
 
 	camel_session_set_check_junk (
@@ -1583,11 +1736,13 @@ e_mail_session_init (EMailSession *session)
 }
 
 EMailSession *
-e_mail_session_new (void)
+e_mail_session_new (ESourceRegistry *registry)
 {
 	const gchar *user_data_dir;
 	const gchar *user_cache_dir;
 
+	g_return_val_if_fail (E_IS_SOURCE_REGISTRY (registry), NULL);
+
 	user_data_dir = mail_session_get_data_dir ();
 	user_cache_dir = mail_session_get_cache_dir ();
 
@@ -1595,9 +1750,18 @@ e_mail_session_new (void)
 		E_TYPE_MAIL_SESSION,
 		"user-data-dir", user_data_dir,
 		"user-cache-dir", user_cache_dir,
+		"registry", registry,
 		NULL);
 }
 
+ESourceRegistry *
+e_mail_session_get_registry (EMailSession *session)
+{
+	g_return_val_if_fail (E_IS_MAIL_SESSION (session), NULL);
+
+	return session->priv->registry;
+}
+
 MailFolderCache *
 e_mail_session_get_folder_cache (EMailSession *session)
 {
@@ -1987,6 +2151,66 @@ e_mail_session_uri_to_folder_finish (EMailSession *session,
 	return g_object_ref (context->folder);
 }
 
+gboolean
+e_binding_transform_service_to_source (GBinding *binding,
+                                       const GValue *source_value,
+                                       GValue *target_value,
+                                       gpointer session)
+{
+	CamelService *service;
+	ESourceRegistry *registry;
+	ESource *source;
+	const gchar *uid;
+
+	g_return_val_if_fail (G_IS_BINDING (binding), FALSE);
+	g_return_val_if_fail (E_IS_MAIL_SESSION (session), FALSE);
+
+	service = g_value_get_object (source_value);
+
+	if (!CAMEL_IS_SERVICE (service))
+		return FALSE;
+
+	uid = camel_service_get_uid (service);
+	registry = e_mail_session_get_registry (session);
+	source = e_source_registry_lookup_by_uid (registry, uid);
+
+	if (!E_IS_SOURCE (source))
+		return FALSE;
+
+	g_value_set_object (target_value, source);
+
+	return TRUE;
+}
+
+gboolean
+e_binding_transform_source_to_service (GBinding *binding,
+                                       const GValue *source_value,
+                                       GValue *target_value,
+                                       gpointer session)
+{
+	CamelService *service;
+	ESource *source;
+	const gchar *uid;
+
+	g_return_val_if_fail (G_IS_BINDING (binding), FALSE);
+	g_return_val_if_fail (E_IS_MAIL_SESSION (session), FALSE);
+
+	source = g_value_get_object (source_value);
+
+	if (!E_IS_SOURCE (source))
+		return FALSE;
+
+	uid = e_source_get_uid (source);
+	service = camel_session_get_service (session, uid);
+
+	if (!CAMEL_IS_SERVICE (service))
+		return FALSE;
+
+	g_value_set_object (target_value, service);
+
+	return TRUE;
+}
+
 /******************************** Legacy API *********************************/
 
 void
diff --git a/libemail-engine/e-mail-session.h b/libemail-engine/e-mail-session.h
index 16a6592..bf436c7 100644
--- a/libemail-engine/e-mail-session.h
+++ b/libemail-engine/e-mail-session.h
@@ -26,6 +26,7 @@
 #define E_MAIL_SESSION_H
 
 #include <camel/camel.h>
+#include <libedataserver/e-source-registry.h>
 #include <libemail-engine/e-mail-enums.h>
 #include <libemail-engine/mail-folder-cache.h>
 #include <libemail-utils/em-vfolder-context.h>
@@ -67,12 +68,22 @@ struct _EMailSession {
 struct _EMailSessionClass {
 	CamelSessionClass parent_class;
 
-	EMVFolderContext *	(*create_vfolder_context)		(EMailSession *session);
-
+	EMVFolderContext *
+			(*create_vfolder_context)
+						(EMailSession *session);
+	void		(*flush_outbox)		(EMailSession *session);
+	void		(*refresh_service)	(EMailSession *session,
+						 CamelService *service);
+	void		(*store_added)		(EMailSession *session,
+						 CamelStore *store);
+	void		(*store_removed)	(EMailSession *session,
+						 CamelStore *store);
 };
 
 GType		e_mail_session_get_type		(void);
-EMailSession *	e_mail_session_new		(void);
+EMailSession *	e_mail_session_new		(ESourceRegistry *registry);
+ESourceRegistry *
+		e_mail_session_get_registry	(EMailSession *session);
 MailFolderCache *
 		e_mail_session_get_folder_cache	(EMailSession *session);
 CamelStore *	e_mail_session_get_local_store	(EMailSession *session);
@@ -131,6 +142,19 @@ CamelFolder *	e_mail_session_uri_to_folder_finish
 EMVFolderContext *
 		e_mail_session_create_vfolder_context
 						(EMailSession *session);
+
+/* Useful GBinding transform functions */
+gboolean	e_binding_transform_service_to_source
+						(GBinding *binding,
+						 const GValue *source_value,
+						 GValue *target_value,
+						 gpointer session);
+gboolean	e_binding_transform_source_to_service
+						(GBinding *binding,
+						 const GValue *source_value,
+						 GValue *target_value,
+						 gpointer session);
+
 /*** Legacy API ***/
 
 void		mail_session_flush_filter_log	(EMailSession *session);
diff --git a/libemail-engine/e-mail-utils.c b/libemail-engine/e-mail-utils.c
index af861ca..0004d79 100644
--- a/libemail-engine/e-mail-utils.c
+++ b/libemail-engine/e-mail-utils.c
@@ -46,9 +46,14 @@
 #include <libedataserver/e-data-server-util.h>
 #include <libedataserver/e-flag.h>
 #include <libedataserver/e-proxy.h>
+#include <libedataserver/e-source-address-book.h>
+#include <libedataserver/e-source-autocomplete.h>
+#include <libedataserver/e-source-mail-account.h>
+#include <libedataserver/e-source-mail-composition.h>
+#include <libedataserver/e-source-mail-identity.h>
+#include <libedataserver/e-source-mail-submission.h>
 
-#include "libemail-utils/e-account-utils.h"
-#include "libemail-utils/mail-mt.h"
+#include <libemail-utils/mail-mt.h>
 
 #include "e-mail-folder-utils.h"
 #include "e-mail-session.h"
@@ -58,120 +63,141 @@
 #define d(x)
 
 /**
- * em_utils_folder_is_templates:
+ * em_utils_folder_is_drafts:
+ * @registry: an #ESourceRegistry
  * @folder: a #CamelFolder
  *
- * Decides if @folder is a Templates folder.
+ * Decides if @folder is a Drafts folder.
  *
- * Returns %TRUE if this is a Templates folder or %FALSE otherwise.
+ * Returns %TRUE if this is a Drafts folder or %FALSE otherwise.
  **/
-
 gboolean
-em_utils_folder_is_templates (CamelFolder *folder)
+em_utils_folder_is_drafts (ESourceRegistry *registry,
+                           CamelFolder *folder)
 {
-	CamelFolder *local_templates_folder;
+	CamelFolder *local_drafts_folder;
 	CamelSession *session;
 	CamelStore *store;
-	EAccountList *account_list;
-	EIterator *iterator;
+	GList *list, *iter;
 	gchar *folder_uri;
-	gboolean is_templates = FALSE;
+	gboolean is_drafts = FALSE;
+	const gchar *extension_name;
 
 	g_return_val_if_fail (CAMEL_IS_FOLDER (folder), FALSE);
 
 	store = camel_folder_get_parent_store (folder);
 	session = camel_service_get_session (CAMEL_SERVICE (store));
 
-	local_templates_folder =
+	local_drafts_folder =
 		e_mail_session_get_local_folder (
-		E_MAIL_SESSION (session), E_MAIL_LOCAL_FOLDER_TEMPLATES);
+		E_MAIL_SESSION (session), E_MAIL_LOCAL_FOLDER_DRAFTS);
 
-	if (folder == local_templates_folder)
+	if (folder == local_drafts_folder)
 		return TRUE;
 
 	folder_uri = e_mail_folder_uri_from_folder (folder);
 
-	account_list = e_get_account_list ();
-	iterator = e_list_get_iterator (E_LIST (account_list));
+	store = camel_folder_get_parent_store (folder);
+	session = camel_service_get_session (CAMEL_SERVICE (store));
 
-	while (!is_templates && e_iterator_is_valid (iterator)) {
-		EAccount *account;
+	extension_name = E_SOURCE_EXTENSION_MAIL_COMPOSITION;
+	list = e_source_registry_list_sources (registry, extension_name);
 
-		/* XXX EIterator misuses const. */
-		account = (EAccount *) e_iterator_get (iterator);
+	for (iter = list; iter != NULL; iter = g_list_next (iter)) {
+		ESource *source = E_SOURCE (iter->data);
+		ESourceExtension *extension;
+		const gchar *drafts_folder_uri;
 
-		if (account->templates_folder_uri != NULL)
-			is_templates = e_mail_folder_uri_equal (
-				session, folder_uri,
-				account->templates_folder_uri);
+		extension = e_source_get_extension (source, extension_name);
 
-		e_iterator_next (iterator);
+		drafts_folder_uri =
+			e_source_mail_composition_get_drafts_folder (
+			E_SOURCE_MAIL_COMPOSITION (extension));
+
+		if (drafts_folder_uri != NULL)
+			is_drafts = e_mail_folder_uri_equal (
+				session, folder_uri, drafts_folder_uri);
+
+		if (is_drafts)
+			break;
 	}
 
-	g_object_unref (iterator);
+	g_list_free (list);
 	g_free (folder_uri);
 
-	return is_templates;
+	return is_drafts;
 }
 
 /**
- * em_utils_folder_is_drafts:
+ * em_utils_folder_is_templates:
+ * @registry: an #ESourceRegistry
  * @folder: a #CamelFolder
  *
- * Decides if @folder is a Drafts folder.
+ * Decides if @folder is a Templates folder.
  *
- * Returns %TRUE if this is a Drafts folder or %FALSE otherwise.
+ * Returns %TRUE if this is a Templates folder or %FALSE otherwise.
  **/
+
 gboolean
-em_utils_folder_is_drafts (CamelFolder *folder)
+em_utils_folder_is_templates (ESourceRegistry *registry,
+                              CamelFolder *folder)
 {
-	CamelFolder *local_drafts_folder;
+	CamelFolder *local_templates_folder;
 	CamelSession *session;
 	CamelStore *store;
-	EAccountList *account_list;
-	EIterator *iterator;
+	GList *list, *iter;
 	gchar *folder_uri;
-	gboolean is_drafts = FALSE;
+	gboolean is_templates = FALSE;
+	const gchar *extension_name;
 
 	g_return_val_if_fail (CAMEL_IS_FOLDER (folder), FALSE);
 
 	store = camel_folder_get_parent_store (folder);
 	session = camel_service_get_session (CAMEL_SERVICE (store));
 
-	local_drafts_folder =
+	local_templates_folder =
 		e_mail_session_get_local_folder (
-		E_MAIL_SESSION (session), E_MAIL_LOCAL_FOLDER_DRAFTS);
+		E_MAIL_SESSION (session), E_MAIL_LOCAL_FOLDER_TEMPLATES);
 
-	if (folder == local_drafts_folder)
+	if (folder == local_templates_folder)
 		return TRUE;
 
 	folder_uri = e_mail_folder_uri_from_folder (folder);
 
-	account_list = e_get_account_list ();
-	iterator = e_list_get_iterator (E_LIST (account_list));
+	store = camel_folder_get_parent_store (folder);
+	session = camel_service_get_session (CAMEL_SERVICE (store));
+
+	extension_name = E_SOURCE_EXTENSION_MAIL_COMPOSITION;
+	list = e_source_registry_list_sources (registry, extension_name);
 
-	while (!is_drafts && e_iterator_is_valid (iterator)) {
-		EAccount *account;
+	for (iter = list; iter != NULL; iter = g_list_next (iter)) {
+		ESource *source = E_SOURCE (iter->data);
+		ESourceExtension *extension;
+		const gchar *templates_folder_uri;
 
-		/* XXX EIterator misuses const. */
-		account = (EAccount *) e_iterator_get (iterator);
+		extension = e_source_get_extension (source, extension_name);
 
-		if (account->drafts_folder_uri != NULL)
-			is_drafts = e_mail_folder_uri_equal (
-				session, folder_uri,
-				account->drafts_folder_uri);
+		templates_folder_uri =
+			e_source_mail_composition_get_templates_folder (
+			E_SOURCE_MAIL_COMPOSITION (extension));
 
-		e_iterator_next (iterator);
+		if (templates_folder_uri != NULL)
+			is_templates = e_mail_folder_uri_equal (
+				session, folder_uri, templates_folder_uri);
+
+		if (is_templates)
+			break;
 	}
 
-	g_object_unref (iterator);
+	g_list_free (list);
 	g_free (folder_uri);
 
-	return is_drafts;
+	return is_templates;
 }
 
 /**
  * em_utils_folder_is_sent:
+ * @registry: an #ESourceRegistry
  * @folder: a #CamelFolder
  *
  * Decides if @folder is a Sent folder.
@@ -179,15 +205,16 @@ em_utils_folder_is_drafts (CamelFolder *folder)
  * Returns %TRUE if this is a Sent folder or %FALSE otherwise.
  **/
 gboolean
-em_utils_folder_is_sent (CamelFolder *folder)
+em_utils_folder_is_sent (ESourceRegistry *registry,
+                         CamelFolder *folder)
 {
 	CamelFolder *local_sent_folder;
 	CamelSession *session;
 	CamelStore *store;
-	EAccountList *account_list;
-	EIterator *iterator;
+	GList *list, *iter;
 	gchar *folder_uri;
 	gboolean is_sent = FALSE;
+	const gchar *extension_name;
 
 	g_return_val_if_fail (CAMEL_IS_FOLDER (folder), FALSE);
 
@@ -203,24 +230,32 @@ em_utils_folder_is_sent (CamelFolder *folder)
 
 	folder_uri = e_mail_folder_uri_from_folder (folder);
 
-	account_list = e_get_account_list ();
-	iterator = e_list_get_iterator (E_LIST (account_list));
+	store = camel_folder_get_parent_store (folder);
+	session = camel_service_get_session (CAMEL_SERVICE (store));
+
+	extension_name = E_SOURCE_EXTENSION_MAIL_SUBMISSION;
+	list = e_source_registry_list_sources (registry, extension_name);
 
-	while (!is_sent && e_iterator_is_valid (iterator)) {
-		EAccount *account;
+	for (iter = list; iter != NULL; iter = g_list_next (iter)) {
+		ESource *source = E_SOURCE (iter->data);
+		ESourceExtension *extension;
+		const gchar *sent_folder_uri;
 
-		/* XXX EIterator misuses const. */
-		account = (EAccount *) e_iterator_get (iterator);
+		extension = e_source_get_extension (source, extension_name);
 
-		if (account->sent_folder_uri != NULL)
+		sent_folder_uri =
+			e_source_mail_submission_get_sent_folder (
+			E_SOURCE_MAIL_SUBMISSION (extension));
+
+		if (sent_folder_uri != NULL)
 			is_sent = e_mail_folder_uri_equal (
-				session, folder_uri,
-				account->sent_folder_uri);
+				session, folder_uri, sent_folder_uri);
 
-		e_iterator_next (iterator);
+		if (is_sent)
+			break;
 	}
 
-	g_object_unref (iterator);
+	g_list_free (list);
 	g_free (folder_uri);
 
 	return is_sent;
@@ -228,6 +263,7 @@ em_utils_folder_is_sent (CamelFolder *folder)
 
 /**
  * em_utils_folder_is_outbox:
+ * @registry: an #ESourceRegistry
  * @folder: a #CamelFolder
  *
  * Decides if @folder is an Outbox folder.
@@ -235,7 +271,8 @@ em_utils_folder_is_sent (CamelFolder *folder)
  * Returns %TRUE if this is an Outbox folder or %FALSE otherwise.
  **/
 gboolean
-em_utils_folder_is_outbox (CamelFolder *folder)
+em_utils_folder_is_outbox (ESourceRegistry *registry,
+                           CamelFolder *folder)
 {
 	CamelStore *store;
 	CamelSession *session;
@@ -255,19 +292,6 @@ em_utils_folder_is_outbox (CamelFolder *folder)
 
 /* ********************************************************************** */
 
-/* runs sync, in main thread */
-static gpointer
-emu_addr_setup (gpointer user_data)
-{
-	GError *err = NULL;
-	ESourceList **psource_list = user_data;
-
-	if (!e_book_client_get_sources (psource_list, &err))
-		g_error_free (err);
-
-	return NULL;
-}
-
 static void
 emu_addr_cancel_stop (gpointer data)
 {
@@ -383,33 +407,31 @@ static GHashTable *emu_books_hash = NULL;
  * broken books, which failed to open for some reason */
 static GHashTable *emu_broken_books_hash = NULL;
 
-static ESourceList *emu_books_source_list = NULL;
-
 static gboolean
-search_address_in_addressbooks (const gchar *address,
+search_address_in_addressbooks (ESourceRegistry *registry,
+                                const gchar *address,
                                 gboolean local_only,
                                 gboolean (*check_contact) (EContact *contact,
                                                            gpointer user_data),
                                 gpointer user_data)
 {
+	GList *list, *link;
+	GList *addr_sources = NULL;
 	gboolean found = FALSE, stop = FALSE, found_any = FALSE;
 	gchar *lowercase_addr;
 	gpointer ptr;
 	EBookQuery *book_query;
 	gchar *query;
-	GSList *s, *g, *addr_sources = NULL;
 	GHook *hook_cancellable;
 	GCancellable *cancellable;
+	const gchar *extension_name;
 
 	if (!address || !*address)
 		return FALSE;
 
 	G_LOCK (contact_cache);
 
-	if (!emu_books_source_list) {
-		mail_call_main (
-			MAIL_CALL_p_p, (MailMainFunc)
-			emu_addr_setup, &emu_books_source_list);
+	if (emu_books_hash == NULL) {
 		emu_books_hash = g_hash_table_new_full (
 			g_str_hash, g_str_equal, g_free, g_object_unref);
 		emu_broken_books_hash = g_hash_table_new_full (
@@ -418,11 +440,6 @@ search_address_in_addressbooks (const gchar *address,
 			g_str_hash, g_str_equal, g_free, NULL);
 	}
 
-	if (!emu_books_source_list) {
-		G_UNLOCK (contact_cache);
-		return FALSE;
-	}
-
 	lowercase_addr = g_utf8_strdown (address, -1);
 	ptr = g_hash_table_lookup (contact_cache, lowercase_addr);
 	if (ptr != NULL && (check_contact == NULL || ptr == NOT_FOUND_BOOK)) {
@@ -435,35 +452,48 @@ search_address_in_addressbooks (const gchar *address,
 	query = e_book_query_to_string (book_query);
 	e_book_query_unref (book_query);
 
-	for (g = e_source_list_peek_groups (emu_books_source_list);
-			g; g = g_slist_next (g)) {
-		ESourceGroup *group = g->data;
+	extension_name = E_SOURCE_EXTENSION_ADDRESS_BOOK;
+	list = e_source_registry_list_sources (registry, extension_name);
 
-		if (!group)
-			continue;
+	for (link = list; link != NULL; link = g_list_next (link)) {
+		ESource *source = E_SOURCE (link->data);
+		ESourceExtension *extension;
+		const gchar *backend_name;
+		gboolean source_is_local;
+		gboolean autocomplete;
+
+		extension_name = E_SOURCE_EXTENSION_ADDRESS_BOOK;
+		extension = e_source_get_extension (source, extension_name);
+
+		backend_name = e_source_backend_get_backend_name (
+			E_SOURCE_BACKEND (extension));
 
-		if (local_only && !(e_source_group_peek_base_uri (group) &&
-			g_str_has_prefix (
-			e_source_group_peek_base_uri (group), "local:")))
+		source_is_local = (g_strcmp0 (backend_name, "local") == 0);
+
+		if (local_only && !source_is_local)
 			continue;
 
-		for (s = e_source_group_peek_sources (group); s; s = g_slist_next (s)) {
-			ESource *source = s->data;
-			const gchar *completion = e_source_get_property (source, "completion");
+		extension_name = E_SOURCE_EXTENSION_AUTOCOMPLETE;
+		extension = e_source_get_extension (source, extension_name);
 
-			if (completion && g_ascii_strcasecmp (completion, "true") == 0) {
-				addr_sources = g_slist_prepend (
-					addr_sources, g_object_ref (source));
-			}
-		}
+		autocomplete = e_source_autocomplete_get_include_me (
+			E_SOURCE_AUTOCOMPLETE (extension));
+
+		if (!autocomplete)
+			continue;
+
+		addr_sources = g_list_prepend (
+			addr_sources, g_object_ref (source));
 	}
 
+	g_list_free (list);
+
 	cancellable = g_cancellable_new ();
 	hook_cancellable = mail_cancel_hook_add (
 		emu_addr_cancel_cancellable, cancellable);
 
-	for (s = addr_sources; !stop && !found && s; s = g_slist_next (s)) {
-		ESource *source = s->data;
+	for (link = addr_sources; !stop && !found && link != NULL; link = g_list_next (link)) {
+		ESource *source = E_SOURCE (link->data);
 		GSList *contacts;
 		EBookClient *book_client = NULL;
 		GHook *hook_stop;
@@ -472,8 +502,8 @@ search_address_in_addressbooks (const gchar *address,
 		const gchar *uid;
 		GError *err = NULL;
 
-		uid = e_source_peek_uid (source);
-		display_name = e_source_peek_name (source);
+		uid = e_source_get_uid (source);
+		display_name = e_source_get_display_name (source);
 
 		/* failed to load this book last time, skip it now */
 		if (g_hash_table_lookup (emu_broken_books_hash, uid) != NULL) {
@@ -598,7 +628,7 @@ search_address_in_addressbooks (const gchar *address,
 	mail_cancel_hook_remove (hook_cancellable);
 	g_object_unref (cancellable);
 
-	g_slist_free_full (addr_sources, (GDestroyNotify) g_object_unref);
+	g_list_free_full (addr_sources, (GDestroyNotify) g_object_unref);
 
 	g_free (query);
 
@@ -615,16 +645,20 @@ search_address_in_addressbooks (const gchar *address,
 }
 
 gboolean
-em_utils_in_addressbook (CamelInternetAddress *iaddr,
+em_utils_in_addressbook (ESourceRegistry *registry,
+                         CamelInternetAddress *iaddr,
                          gboolean local_only)
 {
 	const gchar *addr;
 
+	g_return_val_if_fail (E_IS_SOURCE_REGISTRY (registry), FALSE);
+
 	/* TODO: check all addresses? */
 	if (iaddr == NULL || !camel_internet_address_get (iaddr, 0, NULL, &addr))
 		return FALSE;
 
-	return search_address_in_addressbooks (addr, local_only, NULL, NULL);
+	return search_address_in_addressbooks (
+		registry, addr, local_only, NULL, NULL);
 }
 
 static gboolean
@@ -665,7 +699,8 @@ G_LOCK_DEFINE_STATIC (photos_cache);
 static GSList *photos_cache = NULL; /* list of PhotoInfo-s */
 
 CamelMimePart *
-em_utils_contact_photo (CamelInternetAddress *cia,
+em_utils_contact_photo (ESourceRegistry *registry,
+                        CamelInternetAddress *cia,
                         gboolean local_only)
 {
 	const gchar *addr = NULL;
@@ -674,6 +709,8 @@ em_utils_contact_photo (CamelInternetAddress *cia,
 	GSList *p, *first_not_null = NULL;
 	gint count_not_null = 0;
 
+	g_return_val_if_fail (E_IS_SOURCE_REGISTRY (registry), NULL);
+
 	if (cia == NULL || !camel_internet_address_get (cia, 0, NULL, &addr) || !addr) {
 		return NULL;
 	}
@@ -701,7 +738,8 @@ em_utils_contact_photo (CamelInternetAddress *cia,
 
 	/* !p means the address had not been found in the cache */
 	if (!p && search_address_in_addressbooks (
-			addr, local_only, extract_photo_data, &photo)) {
+		registry, addr, local_only, extract_photo_data, &photo)) {
+
 		PhotoInfo *pi;
 
 		if (photo && photo->type != E_CONTACT_PHOTO_TYPE_INLINED) {
@@ -815,11 +853,6 @@ emu_free_mail_cache (void)
 		emu_broken_books_hash = NULL;
 	}
 
-	if (emu_books_source_list) {
-		g_object_unref (emu_books_source_list);
-		emu_books_source_list = NULL;
-	}
-
 	if (contact_cache) {
 		g_hash_table_destroy (contact_cache);
 		contact_cache = NULL;
@@ -836,70 +869,164 @@ emu_free_mail_cache (void)
 	G_UNLOCK (photos_cache);
 }
 
-static EAccount *
-guess_account_from_folder (CamelFolder *folder)
+static ESource *
+guess_mail_account_from_folder (ESourceRegistry *registry,
+                                CamelFolder *folder)
 {
+	ESource *source;
 	CamelStore *store;
 	const gchar *uid;
 
+	/* Lookup an ESource by CamelStore UID. */
 	store = camel_folder_get_parent_store (folder);
 	uid = camel_service_get_uid (CAMEL_SERVICE (store));
+	source = e_source_registry_lookup_by_uid (registry, uid);
+
+	/* If we found an ESource, make sure it's a mail account. */
+	if (source != NULL) {
+		const gchar *extension_name;
+
+		extension_name = E_SOURCE_EXTENSION_MAIL_ACCOUNT;
+		if (!e_source_has_extension (source, extension_name))
+			source = NULL;
+	}
 
-	return e_get_account_by_uid (uid);
+	return source;
 }
 
-static EAccount *
-guess_account_from_message (CamelMimeMessage *message)
+static ESource *
+guess_mail_account_from_message (ESourceRegistry *registry,
+                                 CamelMimeMessage *message)
 {
+	ESource *source = NULL;
 	const gchar *uid;
 
+	/* Lookup an ESource by 'X-Evolution-Source' header. */
 	uid = camel_mime_message_get_source (message);
+	if (uid != NULL)
+		source = e_source_registry_lookup_by_uid (registry, uid);
+
+	/* If we found an ESource, make sure it's a mail account. */
+	if (source != NULL) {
+		const gchar *extension_name;
 
-	return (uid != NULL) ? e_get_account_by_uid (uid) : NULL;
+		extension_name = E_SOURCE_EXTENSION_MAIL_ACCOUNT;
+		if (!e_source_has_extension (source, extension_name))
+			source = NULL;
+	}
+
+	return source;
 }
 
-EAccount *
-em_utils_guess_account (CamelMimeMessage *message,
-                        CamelFolder *folder)
+ESource *
+em_utils_guess_mail_account (ESourceRegistry *registry,
+                             CamelMimeMessage *message,
+                             CamelFolder *folder)
 {
-	EAccount *account = NULL;
+	ESource *source = NULL;
+	const gchar *newsgroups;
 
+	g_return_val_if_fail (E_IS_SOURCE_REGISTRY (registry), NULL);
 	g_return_val_if_fail (CAMEL_IS_MIME_MESSAGE (message), NULL);
 
 	if (folder != NULL)
 		g_return_val_if_fail (CAMEL_IS_FOLDER (folder), NULL);
 
 	/* check for newsgroup header */
-	if (folder != NULL
-	    && camel_medium_get_header (CAMEL_MEDIUM (message), "Newsgroups"))
-		account = guess_account_from_folder (folder);
+	newsgroups = camel_medium_get_header (
+		CAMEL_MEDIUM (message), "Newsgroups");
+	if (folder != NULL && newsgroups != NULL)
+		source = guess_mail_account_from_folder (registry, folder);
 
 	/* check for source folder */
-	if (account == NULL && folder != NULL)
-		account = guess_account_from_folder (folder);
+	if (source == NULL && folder != NULL)
+		source = guess_mail_account_from_folder (registry, folder);
 
 	/* then message source */
-	if (account == NULL)
-		account = guess_account_from_message (message);
+	if (source == NULL)
+		source = guess_mail_account_from_message (registry, message);
+
+	return source;
+}
+
+ESource *
+em_utils_guess_mail_identity (ESourceRegistry *registry,
+                              CamelMimeMessage *message,
+                              CamelFolder *folder)
+{
+	ESource *source;
+	ESourceExtension *extension;
+	const gchar *extension_name;
+
+	g_return_val_if_fail (E_IS_SOURCE_REGISTRY (registry), NULL);
+	g_return_val_if_fail (CAMEL_IS_MIME_MESSAGE (message), NULL);
+
+	if (folder != NULL)
+		g_return_val_if_fail (CAMEL_IS_FOLDER (folder), NULL);
+
+	source = em_utils_guess_mail_account (registry, message, folder);
+
+	if (source == NULL)
+		return NULL;
+
+	extension_name = E_SOURCE_EXTENSION_MAIL_ACCOUNT;
+	extension = e_source_get_extension (source, extension_name);
+
+	return e_source_mail_account_get_identity (
+		E_SOURCE_MAIL_ACCOUNT (extension));
+}
+
+static gboolean
+mail_account_in_recipients (ESourceRegistry *registry,
+                            ESource *source,
+                            GHashTable *recipients)
+{
+	ESourceExtension *extension;
+	const gchar *extension_name;
+	const gchar *address;
+
+	/* Disregard disabled mail accounts. */
+	if (!e_source_get_enabled (source))
+		return FALSE;
+
+	extension_name = E_SOURCE_EXTENSION_MAIL_ACCOUNT;
+	extension = e_source_get_extension (source, extension_name);
 
-	return account;
+	source = e_source_mail_account_get_identity (
+		E_SOURCE_MAIL_ACCOUNT (extension));
+
+	if (source == NULL)
+		return FALSE;
+
+	extension_name = E_SOURCE_EXTENSION_MAIL_IDENTITY;
+	extension = e_source_get_extension (source, extension_name);
+
+	address = e_source_mail_identity_get_address (
+		E_SOURCE_MAIL_IDENTITY (extension));
+
+	if (address == NULL)
+		return FALSE;
+
+	return (g_hash_table_lookup (recipients, address) != NULL);
 }
 
-EAccount *
-em_utils_guess_account_with_recipients (CamelMimeMessage *message,
-                                        CamelFolder *folder)
+ESource *
+em_utils_guess_mail_account_with_recipients (ESourceRegistry *registry,
+                                             CamelMimeMessage *message,
+                                             CamelFolder *folder)
 {
-	EAccount *account = NULL;
-	EAccountList *account_list;
+	ESource *source = NULL;
 	GHashTable *recipients;
-	EIterator *iterator;
 	CamelInternetAddress *addr;
+	GList *list, *iter;
+	const gchar *extension_name;
 	const gchar *type;
 	const gchar *key;
 
 	/* This policy is subject to debate and tweaking,
 	 * but please also document the rational here. */
 
+	g_return_val_if_fail (E_IS_SOURCE_REGISTRY (registry), NULL);
 	g_return_val_if_fail (CAMEL_IS_MIME_MESSAGE (message), NULL);
 
 	/* Build a set of email addresses in which to test for membership.
@@ -929,53 +1056,128 @@ em_utils_guess_account_with_recipients (CamelMimeMessage *message,
 	}
 
 	/* First Preference: We were given a folder that maps to an
-	 * enabled account, and that account's email address appears
+	 * enabled mail account, and that account's address appears
 	 * in the list of To: or Cc: recipients. */
 
 	if (folder != NULL)
-		account = guess_account_from_folder (folder);
+		source = guess_mail_account_from_folder (registry, folder);
 
-	if (account == NULL || !account->enabled)
+	if (source == NULL)
 		goto second_preference;
 
-	if ((key = account->id->address) == NULL)
-		goto second_preference;
-
-	if (g_hash_table_lookup (recipients, key) != NULL)
+	if (mail_account_in_recipients (registry, source, recipients))
 		goto exit;
 
 second_preference:
 
-	/* Second Preference: Choose any enabled account whose email
+	/* Second Preference: Choose any enabled mail account whose
 	 * address appears in the list to To: or Cc: recipients. */
 
-	account_list = e_get_account_list ();
-	iterator = e_list_get_iterator (E_LIST (account_list));
+	source = NULL;
 
-	while (e_iterator_is_valid (iterator)) {
-		account = (EAccount *) e_iterator_get (iterator);
-		e_iterator_next (iterator);
+	extension_name = E_SOURCE_EXTENSION_MAIL_ACCOUNT;
+	list = e_source_registry_list_sources (registry, extension_name);
 
-		if (account == NULL || !account->enabled)
-			continue;
+	for (iter = list; iter != NULL; iter = g_list_next (iter)) {
+		ESource *temp = E_SOURCE (iter->data);
 
-		if ((key = account->id->address) == NULL)
-			continue;
-
-		if (g_hash_table_lookup (recipients, key) != NULL) {
-			g_object_unref (iterator);
-			goto exit;
+		if (mail_account_in_recipients (registry, temp, recipients)) {
+			source = temp;
+			break;
 		}
 	}
-	g_object_unref (iterator);
 
-	/* Last Preference: Defer to em_utils_guess_account(). */
-	account = em_utils_guess_account (message, folder);
+	g_list_free (list);
+
+	if (source != NULL)
+		goto exit;
+
+	/* Last Preference: Defer to em_utils_guess_mail_account(). */
+	source = em_utils_guess_mail_account (registry, message, folder);
 
 exit:
 	g_hash_table_destroy (recipients);
 
-	return account;
+	return source;
+}
+
+ESource *
+em_utils_guess_mail_identity_with_recipients (ESourceRegistry *registry,
+                                              CamelMimeMessage *message,
+                                              CamelFolder *folder)
+{
+	ESource *source;
+	ESourceExtension *extension;
+	const gchar *extension_name;
+
+	g_return_val_if_fail (E_IS_SOURCE_REGISTRY (registry), NULL);
+	g_return_val_if_fail (CAMEL_IS_MIME_MESSAGE (message), NULL);
+
+	source = em_utils_guess_mail_account_with_recipients (
+		registry, message, folder);
+
+	if (source == NULL)
+		return NULL;
+
+	extension_name = E_SOURCE_EXTENSION_MAIL_ACCOUNT;
+	extension = e_source_get_extension (source, extension_name);
+
+	return e_source_mail_account_get_identity (
+		E_SOURCE_MAIL_ACCOUNT (extension));
+}
+
+gboolean
+em_utils_mail_identity_is_enabled (ESourceRegistry *registry,
+                                   ESource *mail_identity_source)
+{
+	GList *list, *link;
+	const gchar *extension_name;
+	gboolean found_account = FALSE;
+	gboolean found_enabled_account = FALSE;
+
+	g_return_val_if_fail (E_IS_SOURCE_REGISTRY (registry), FALSE);
+
+	if (mail_identity_source == NULL)
+		return FALSE;
+
+	extension_name = E_SOURCE_EXTENSION_MAIL_IDENTITY;
+	if (!e_source_has_extension (mail_identity_source, extension_name))
+		return FALSE;
+
+	/* If any enabled account references the given identity, then
+	 * the identity is enabled.  If no accounts reference the given
+	 * identity, then the identity is assumed to be enabled.  So in
+	 * other words, an identity is disabled if and only if it is
+	 * referenced exclusively by disabled accounts. */
+
+	extension_name = E_SOURCE_EXTENSION_MAIL_ACCOUNT;
+	list = e_source_registry_list_sources (registry, extension_name);
+
+	for (link = list; link != NULL; link = g_list_next (link)) {
+		ESource *source = E_SOURCE (link->data);
+		ESourceMailAccount *extension;
+		gboolean enabled;
+
+		extension = e_source_get_extension (source, extension_name);
+
+		enabled = e_source_get_enabled (source);
+		source = e_source_mail_account_get_identity (extension);
+
+		if (source == NULL)
+			continue;
+
+		if (e_source_equal (source, mail_identity_source)) {
+			found_account = TRUE;
+			found_enabled_account |= enabled;
+		}
+
+		if (found_enabled_account)
+			break;
+	}
+
+	g_list_free (list);
+
+	return found_enabled_account || !found_account;
 }
 
 static void
diff --git a/libemail-engine/e-mail-utils.h b/libemail-engine/e-mail-utils.h
index 144f13d..9cf342c 100644
--- a/libemail-engine/e-mail-utils.h
+++ b/libemail-engine/e-mail-utils.h
@@ -23,21 +23,39 @@
 #define E_MAIL_UTILS_H
 
 #include <camel/camel.h>
-#include <libedataserver/e-account.h>
+#include <libedataserver/e-source-registry.h>
 
-gboolean	em_utils_folder_is_drafts	(CamelFolder *folder);
-gboolean	em_utils_folder_is_templates	(CamelFolder *folder);
-gboolean	em_utils_folder_is_sent		(CamelFolder *folder);
-gboolean	em_utils_folder_is_outbox	(CamelFolder *folder);
-gboolean	em_utils_in_addressbook		(CamelInternetAddress *addr,
+gboolean	em_utils_folder_is_drafts	(ESourceRegistry *registry,
+						 CamelFolder *folder);
+gboolean	em_utils_folder_is_templates	(ESourceRegistry *registry,
+						 CamelFolder *folder);
+gboolean	em_utils_folder_is_sent		(ESourceRegistry *registry,
+						 CamelFolder *folder);
+gboolean	em_utils_folder_is_outbox	(ESourceRegistry *registry,
+						 CamelFolder *folder);
+gboolean	em_utils_in_addressbook		(ESourceRegistry *registry,
+						 CamelInternetAddress *addr,
 						 gboolean local_only);
-CamelMimePart *	em_utils_contact_photo		(CamelInternetAddress *addr,
+CamelMimePart *	em_utils_contact_photo		(ESourceRegistry *registry,
+						 CamelInternetAddress *addr,
 						 gboolean local);
-EAccount *	em_utils_guess_account		(CamelMimeMessage *message,
+ESource *	em_utils_guess_mail_account	(ESourceRegistry *registry,
+						 CamelMimeMessage *message,
+						 CamelFolder *folder);
+ESource *	em_utils_guess_mail_identity	(ESourceRegistry *registry,
+						 CamelMimeMessage *message,
+						 CamelFolder *folder);
+ESource *	em_utils_guess_mail_account_with_recipients
+						(ESourceRegistry *registry,
+						 CamelMimeMessage *message,
 						 CamelFolder *folder);
-EAccount *	em_utils_guess_account_with_recipients
-						(CamelMimeMessage *message,
+ESource *	em_utils_guess_mail_identity_with_recipients
+						(ESourceRegistry *registry,
+						 CamelMimeMessage *message,
 						 CamelFolder *folder);
+gboolean	em_utils_mail_identity_is_enabled
+						(ESourceRegistry *registry,
+						 ESource *mail_identity_source);
 void		emu_remove_from_mail_cache	(const GSList *addresses);
 void		emu_remove_from_mail_cache_1	(const gchar *address);
 void		emu_free_mail_cache		(void);
diff --git a/libemail-engine/mail-config.c b/libemail-engine/mail-config.c
index 09f0332..af193f5 100644
--- a/libemail-engine/mail-config.c
+++ b/libemail-engine/mail-config.c
@@ -31,9 +31,6 @@
 
 #include <libedataserver/e-data-server-util.h>
 
-#include <libemail-utils/e-account-utils.h>
-#include <libemail-utils/e-signature-utils.h>
-
 #include "e-mail-folder-utils.h"
 #include "mail-config.h"
 #include "mail-tools.h"
@@ -137,24 +134,6 @@ settings_int_value_changed (GSettings *settings,
 	*save_location = g_settings_get_int (settings, key);
 }
 
-void
-mail_config_write (void)
-{
-	EAccountList *account_list;
-	ESignatureList *signature_list;
-
-	if (!config)
-		return;
-
-	account_list = e_get_account_list ();
-	signature_list = e_get_signature_list ();
-
-	e_account_list_save (account_list);
-	e_signature_list_save (signature_list);
-
-	g_settings_sync ();
-}
-
 gint
 mail_config_get_address_count (void)
 {
diff --git a/libemail-engine/mail-config.h b/libemail-engine/mail-config.h
index 0a1c618..cc836ac 100644
--- a/libemail-engine/mail-config.h
+++ b/libemail-engine/mail-config.h
@@ -29,7 +29,6 @@ G_BEGIN_DECLS
 
 /* Configuration */
 void		mail_config_init		(EMailSession *session);
-void		mail_config_write		(void);
 
 /* General Accessor functions */
 
diff --git a/libemail-engine/mail-folder-cache.c b/libemail-engine/mail-folder-cache.c
index 5c459ef..dbb6fcc 100644
--- a/libemail-engine/mail-folder-cache.c
+++ b/libemail-engine/mail-folder-cache.c
@@ -341,11 +341,16 @@ update_1folder (MailFolderCache *cache,
                 const gchar *msg_subject,
                 CamelFolderInfo *info)
 {
+	EMailSession *session;
+	ESourceRegistry *registry;
 	struct _folder_update *up;
 	CamelFolder *folder;
 	gint unread = -1;
 	gint deleted;
 
+	session = mail_folder_cache_get_session (cache);
+	registry = e_mail_session_get_registry (session);
+
 	folder = mfi->folder;
 	if (folder) {
 		gboolean folder_is_sent;
@@ -354,9 +359,9 @@ update_1folder (MailFolderCache *cache,
 		gboolean folder_is_vtrash;
 		gboolean special_case;
 
-		folder_is_sent = em_utils_folder_is_sent (folder);
-		folder_is_drafts = em_utils_folder_is_drafts (folder);
-		folder_is_outbox = em_utils_folder_is_outbox (folder);
+		folder_is_sent = em_utils_folder_is_sent (registry, folder);
+		folder_is_drafts = em_utils_folder_is_drafts (registry, folder);
+		folder_is_outbox = em_utils_folder_is_outbox (registry, folder);
 		folder_is_vtrash = CAMEL_IS_VTRASH_FOLDER (folder);
 
 		special_case =
diff --git a/libemail-engine/mail-ops.c b/libemail-engine/mail-ops.c
index 3e40bd0..867f8e8 100644
--- a/libemail-engine/mail-ops.c
+++ b/libemail-engine/mail-ops.c
@@ -35,8 +35,9 @@
 #include <glib/gi18n.h>
 
 #include <libedataserver/e-data-server-util.h>
+#include <libedataserver/e-source-mail-account.h>
+#include <libedataserver/e-source-mail-submission.h>
 
-#include <libemail-utils/e-account-utils.h>
 #include <libemail-utils/mail-mt.h>
 
 #include "e-mail-utils.h"
@@ -75,7 +76,6 @@ struct _fetch_mail_msg {
 	CamelStore *store;
 	GCancellable *cancellable;	/* we have our own cancellation
 					 * struct, the other should be empty */
-	gint keep;			/* keep on server? */
 
 	void (*done)(gpointer data);
 	gpointer data;
@@ -215,12 +215,19 @@ fetch_mail_exec (struct _fetch_mail_msg *m,
                  GError **error)
 {
 	struct _filter_mail_msg *fm = (struct _filter_mail_msg *) m;
+	GObjectClass *class;
 	CamelFolder *folder = NULL;
 	CamelService *service;
 	CamelSession *session;
+	CamelSettings *settings;
+	CamelUIDCache *cache = NULL;
 	CamelURL *url;
-	gboolean is_local_delivery = FALSE;
+	gboolean keep = FALSE;
+	gboolean delete_fetched;
+	gboolean is_local_delivery;
+	const gchar *data_dir;
 	const gchar *uid;
+	gchar *cachename;
 	gint i;
 
 	service = CAMEL_SERVICE (m->store);
@@ -232,6 +239,19 @@ fetch_mail_exec (struct _fetch_mail_msg *m,
 		goto exit;
 	g_object_ref (fm->destination);
 
+	service = CAMEL_SERVICE (m->store);
+	uid = camel_service_get_uid (service);
+	settings = camel_service_get_settings (service);
+	data_dir = camel_service_get_user_data_dir (service);
+
+	/* XXX This is a POP3-specific setting. */
+	class = G_OBJECT_GET_CLASS (settings);
+	if (g_object_class_find_property (class, "keep-on-server") != NULL)
+		g_object_get (settings, "keep-on-server", &keep, NULL);
+
+	/* Just for readability. */
+	delete_fetched = !keep;
+
 	url = camel_service_new_camel_url (service);
 	is_local_delivery = em_utils_is_local_delivery_mbox_file (url);
 
@@ -258,8 +278,6 @@ fetch_mail_exec (struct _fetch_mail_msg *m,
 		g_free (path);
 		g_free (url_string);
 	} else {
-		uid = camel_service_get_uid (service);
-
 		folder = fm->source_folder =
 			e_mail_session_get_inbox_sync (
 				fm->session, uid, cancellable, error);
@@ -267,78 +285,72 @@ fetch_mail_exec (struct _fetch_mail_msg *m,
 
 	camel_url_free (url);
 
-	if (folder != NULL) {
-		/* This handles 'keep on server' stuff, if we have any new
-		 * uid's to copy across, we need to copy them to a new array
-		 * 'cause of the way fetch_mail_free works. */
-		CamelUIDCache *cache = NULL;
-		CamelStore *parent_store;
-		CamelService *service;
-		const gchar *data_dir;
-		gchar *cachename;
-
-		parent_store = camel_folder_get_parent_store (folder);
+	if (folder == NULL)
+		goto exit;
 
-		service = CAMEL_SERVICE (parent_store);
-		data_dir = camel_service_get_user_data_dir (service);
+	/* This handles 'keep on server' stuff, if we have any new
+	 * uid's to copy across, we need to copy them to a new array
+	 * 'cause of the way fetch_mail_free works. */
 
-		cachename = g_build_filename (data_dir, "uid-cache", NULL);
-		cache = camel_uid_cache_new (cachename);
-		g_free (cachename);
+	cachename = g_build_filename (data_dir, "uid-cache", NULL);
+	cache = camel_uid_cache_new (cachename);
+	g_free (cachename);
 
-		if (cache) {
-			GPtrArray *folder_uids, *cache_uids, *uids;
+	if (cache) {
+		GPtrArray *folder_uids, *cache_uids, *uids;
 
-			folder_uids = camel_folder_get_uids (folder);
-			cache_uids = camel_uid_cache_get_new_uids (cache, folder_uids);
-			if (cache_uids) {
-				/* need to copy this, sigh */
-				fm->source_uids = uids = g_ptr_array_new ();
-				g_ptr_array_set_size (uids, cache_uids->len);
-				for (i = 0; i < cache_uids->len; i++)
-					uids->pdata[i] = g_strdup (cache_uids->pdata[i]);
-				camel_uid_cache_free_uids (cache_uids);
+		folder_uids = camel_folder_get_uids (folder);
+		cache_uids = camel_uid_cache_get_new_uids (cache, folder_uids);
+		if (cache_uids) {
+			/* need to copy this, sigh */
+			fm->source_uids = uids = g_ptr_array_new ();
+			g_ptr_array_set_size (uids, cache_uids->len);
+			for (i = 0; i < cache_uids->len; i++)
+				uids->pdata[i] = g_strdup (cache_uids->pdata[i]);
+			camel_uid_cache_free_uids (cache_uids);
 
-				fm->cache = cache;
-				em_filter_folder_element_exec (fm, cancellable, error);
+			fm->cache = cache;
 
-				/* need to uncancel so writes/etc. don't fail */
-				if (g_cancellable_is_cancelled (m->cancellable))
-					g_cancellable_reset (m->cancellable);
+			/* FIXME Should return a success/failure flag. */
+			em_filter_folder_element_exec (fm, cancellable, error);
 
-				/* save the cache of uids that we've just downloaded */
-				camel_uid_cache_save (cache);
-			}
+			/* need to uncancel so writes/etc. don't fail */
+			if (g_cancellable_is_cancelled (m->cancellable))
+				g_cancellable_reset (m->cancellable);
 
-			if (fm->delete && (!error || !*error)) {
-				/* not keep on server - just delete all
-				 * the actual messages on the server */
-				for (i = 0; i < folder_uids->len; i++) {
-					camel_folder_delete_message (
-						folder, folder_uids->pdata[i]);
-				}
-			}
+			/* save the cache of uids that we've just downloaded */
+			camel_uid_cache_save (cache);
+		}
 
-			if ((fm->delete || cache_uids) && (!error || !*error)) {
-				/* expunge messages (downloaded so far) */
-				/* FIXME Not passing a GCancellable or GError here. */
-				camel_folder_synchronize_sync (
-					folder, fm->delete, NULL, NULL);
+		if (delete_fetched && (!error || !*error)) {
+			/* not keep on server - just delete all
+			 * the actual messages on the server */
+			for (i = 0; i < folder_uids->len; i++) {
+				camel_folder_delete_message (
+					folder, folder_uids->pdata[i]);
 			}
+		}
 
-			camel_uid_cache_destroy (cache);
-			camel_folder_free_uids (folder, folder_uids);
-		} else {
-			em_filter_folder_element_exec (fm, cancellable, error);
+		if ((delete_fetched || cache_uids) && (!error || !*error)) {
+			/* expunge messages (downloaded so far) */
+			/* FIXME Not passing a GCancellable or GError here. */
+			camel_folder_synchronize_sync (
+				folder, delete_fetched, NULL, NULL);
 		}
 
-		/* we unref the source folder here since we
-		 * may now block in finalize (we try to
-		 * disconnect cleanly) */
-		g_object_unref (fm->source_folder);
-		fm->source_folder = NULL;
+		camel_uid_cache_destroy (cache);
+		camel_folder_free_uids (folder, folder_uids);
+	} else {
+		/* FIXME Should return a success/failure flag. */
+		em_filter_folder_element_exec (fm, cancellable, error);
 	}
 
+	/* we unref the source folder here since we
+	 * may now block in finalize (we try to
+	 * disconnect cleanly) */
+	g_object_unref (fm->source_folder);
+	fm->source_folder = NULL;
+
 exit:
 	/* we unref this here as it may have more work to do (syncing
 	 * folders and whatnot) before we are really done */
@@ -385,7 +397,6 @@ static MailMsgInfo fetch_mail_info = {
 /* ouch, a 'do everything' interface ... */
 void
 mail_fetch_mail (CamelStore *store,
-                 gint keep,
                  const gchar *type,
                  GCancellable *cancellable,
                  CamelFilterGetFolderFunc get_folder,
@@ -407,7 +418,6 @@ mail_fetch_mail (CamelStore *store,
 	fm = (struct _filter_mail_msg *) m;
 	fm->session = g_object_ref (session);
 	m->store = g_object_ref (store);
-	fm->delete = !keep;
 	fm->cache = NULL;
 	if (cancellable)
 		m->cancellable = g_object_ref (cancellable);
@@ -461,6 +471,44 @@ static void	report_status		(struct _send_queue_msg *m,
 					 const gchar *desc,
 					 ...);
 
+static gboolean
+get_submission_details_from_identity (EMailSession *session,
+                                      const gchar *identity_uid,
+                                      gchar **out_transport_uid,
+                                      gchar **out_sent_folder_uri)
+{
+	ESource *source;
+	ESourceRegistry *registry;
+	ESourceExtension *extension;
+	const gchar *extension_name;
+	const gchar *sent_folder_uri;
+	const gchar *transport_uid;
+
+	registry = e_mail_session_get_registry (session);
+	extension_name = E_SOURCE_EXTENSION_MAIL_SUBMISSION;
+	source = e_source_registry_lookup_by_uid (registry, identity_uid);
+
+	if (source == NULL)
+		return FALSE;
+
+	if (!e_source_has_extension (source, extension_name))
+		return FALSE;
+
+	extension = e_source_get_extension (source, extension_name);
+
+	sent_folder_uri = e_source_mail_submission_get_sent_folder (
+		E_SOURCE_MAIL_SUBMISSION (extension));
+
+	transport_uid = e_source_mail_submission_get_transport_uid (
+		E_SOURCE_MAIL_SUBMISSION (extension));
+
+	*out_transport_uid = g_strdup (transport_uid);
+
+	*out_sent_folder_uri = g_strdup (sent_folder_uri);
+
+	return TRUE;
+}
+
 /* send 1 message to a specific transport */
 static void
 mail_send_message (struct _send_queue_msg *m,
@@ -471,11 +519,11 @@ mail_send_message (struct _send_queue_msg *m,
                    GCancellable *cancellable,
                    GError **error)
 {
-	EAccount *account = NULL;
+	CamelService *service;
 	const CamelInternetAddress *iaddr;
 	CamelAddress *from, *recipients;
 	CamelMessageInfo *info = NULL;
-	CamelProvider *provider;
+	CamelProvider *provider = NULL;
 	gchar *transport_uid = NULL;
 	gchar *sent_folder_uri = NULL;
 	const gchar *resent_from, *tmp;
@@ -496,48 +544,31 @@ mail_send_message (struct _send_queue_msg *m,
 	err = g_string_new ("");
 	xev = mail_tool_remove_xevolution_headers (message);
 
-	tmp = camel_header_raw_find (&xev, "X-Evolution-Account", NULL);
+	tmp = camel_header_raw_find (&xev, "X-Evolution-Identity", NULL);
 	if (tmp != NULL) {
-		gchar *name;
-
-		name = g_strstrip (g_strdup (tmp));
-		if ((account = e_get_account_by_uid (name))
-		    /* 'old' x-evolution-account stored the name, how silly */
-		    || (account = e_get_account_by_name (name))) {
-			if (account->transport) {
-				CamelService *service;
-				gchar *transport_uid;
-
-				transport_uid = g_strconcat (
-					account->uid, "-transport", NULL);
-				service = camel_session_get_service (
-					CAMEL_SESSION (m->session),
-					transport_uid);
-				g_free (transport_uid);
-
-				if (CAMEL_IS_TRANSPORT (service))
-					transport = CAMEL_TRANSPORT (service);
-			}
+		gchar *identity_uid;
 
-			sent_folder_uri = g_strdup (account->sent_folder_uri);
-		}
-		g_free (name);
+		identity_uid = g_strstrip (g_strdup (tmp));
+		get_submission_details_from_identity (
+			m->session, identity_uid,
+			&transport_uid, &sent_folder_uri);
+		g_free (identity_uid);
 	}
 
-	if (!account) {
-		/* default back to these headers */
-		tmp = camel_header_raw_find(&xev, "X-Evolution-Transport", NULL);
-		if (tmp)
-			transport_uid = g_strstrip (g_strdup (tmp));
+	tmp = camel_header_raw_find (&xev, "X-Evolution-Transport", NULL);
+	if (transport_uid == NULL && tmp != NULL)
+		transport_uid = g_strstrip (g_strdup (tmp));
 
-		tmp = camel_header_raw_find(&xev, "X-Evolution-Fcc", NULL);
-		if (tmp)
-			sent_folder_uri = g_strstrip (g_strdup (tmp));
-	}
+	tmp = camel_header_raw_find (&xev, "X-Evolution-Fcc", NULL);
+	if (sent_folder_uri == NULL && tmp != NULL)
+		sent_folder_uri = g_strstrip (g_strdup (tmp));
 
-	if (transport != NULL) {
-		const gchar *uid;
+	service = camel_session_get_service (
+		CAMEL_SESSION (m->session), transport_uid);
+	if (service != NULL)
+		provider = camel_service_get_provider (service);
 
+	if (CAMEL_IS_TRANSPORT (service)) {
 		/* Let the dialog know the right account it is using. */
 		uid = camel_service_get_uid (CAMEL_SERVICE (transport));
 		report_status (m, CAMEL_FILTER_STATUS_ACTION, 0, uid);
@@ -564,12 +595,12 @@ mail_send_message (struct _send_queue_msg *m,
 
 	if (camel_address_length (recipients) > 0) {
 		if (!em_utils_connect_service_sync (
-			CAMEL_SERVICE (transport), cancellable, error))
+			service, cancellable, error))
 			goto exit;
 
 		if (!camel_transport_send_to_sync (
-			transport, message, from,
-			recipients, cancellable, error))
+			CAMEL_TRANSPORT (service), message,
+			from, recipients, cancellable, error))
 			goto exit;
 	}
 
@@ -620,8 +651,6 @@ mail_send_message (struct _send_queue_msg *m,
 		}
 	}
 
-	provider = camel_service_get_provider (CAMEL_SERVICE (transport));
-
 	if (provider == NULL
 	    || !(provider->flags & CAMEL_PROVIDER_DISABLE_SENT_FOLDER)) {
 		GError *local_error = NULL;
@@ -1319,9 +1348,10 @@ expunge_pop3_stores (CamelFolder *expunging,
 	CamelStore *parent_store;
 	CamelService *service;
 	CamelSession *session;
+	ESourceRegistry *registry;
 	GPtrArray *uids;
-	EAccount *account;
-	EIterator *iter;
+	GList *list, *link;
+	const gchar *extension_name;
 	gboolean success = TRUE;
 	guint ii;
 
@@ -1329,6 +1359,7 @@ expunge_pop3_stores (CamelFolder *expunging,
 
 	service = CAMEL_SERVICE (parent_store);
 	session = camel_service_get_session (service);
+	registry = e_mail_session_get_registry (E_MAIL_SESSION (session));
 
 	uids = camel_folder_get_uids (expunging);
 
@@ -1389,79 +1420,89 @@ expunge_pop3_stores (CamelFolder *expunging,
 		return TRUE;
 	}
 
-	for (iter = e_list_get_iterator ((EList *) e_get_account_list ());
-	     e_iterator_is_valid (iter); e_iterator_next (iter)) {
-		account = (EAccount *) e_iterator_get (iter);
+	extension_name = E_SOURCE_EXTENSION_MAIL_ACCOUNT;
+	list = e_source_registry_list_sources (registry, extension_name);
 
-		if (account->enabled &&
-		    account->source && account->source->url &&
-		    g_str_has_prefix (account->source->url, "pop://")) {
-			CamelFolder *folder;
-			CamelService *service;
-			CamelSettings *settings;
-			gboolean any_found = FALSE;
-			gboolean delete_expunged = FALSE;
-			gboolean keep_on_server = FALSE;
+	for (link = list; link != NULL; link = g_list_next (link)) {
+		ESource *source = E_SOURCE (link->data);
+		ESourceBackend *extension;
+		CamelFolder *folder;
+		CamelService *service;
+		CamelSettings *settings;
+		const gchar *backend_name;
+		const gchar *source_uid;
+		gboolean any_found = FALSE;
+		gboolean delete_expunged = FALSE;
+		gboolean keep_on_server = FALSE;
+		gboolean enabled;
 
-			service = camel_session_get_service (session, account->uid);
+		source_uid = e_source_get_uid (source);
+		enabled = e_source_get_enabled (source);
 
-			if (!CAMEL_IS_STORE (service))
-				continue;
+		extension = e_source_get_extension (source, extension_name);
+		backend_name = e_source_backend_get_backend_name (extension);
 
-			settings = camel_service_get_settings (service);
-			if (!settings)
-				continue;
+		if (!enabled || g_strcmp0 (backend_name, "pop") != 0)
+			continue;
 
-			g_object_get (
-				settings,
-				"delete-expunged", &delete_expunged,
-				"keep-on-server", &keep_on_server,
-				NULL);
+		service = camel_session_get_service (
+			CAMEL_SESSION (session), source_uid);
 
-			if (!keep_on_server || !delete_expunged)
-				continue;
+		settings = camel_service_get_settings (service);
 
-			folder = e_mail_session_get_inbox_sync (
-				E_MAIL_SESSION (session),
-				account->uid, cancellable, error);
+		g_object_get (
+			settings,
+			"delete-expunged", &delete_expunged,
+			"keep-on-server", &keep_on_server,
+			NULL);
 
-			/* Abort the loop on error. */
-			if (folder == NULL) {
-				success = FALSE;
-				break;
-			}
+		if (!keep_on_server || !delete_expunged)
+			continue;
 
-			uids = camel_folder_get_uids (folder);
-			if (uids) {
-				for (ii = 0; ii < uids->len; ii++) {
-					/* ensure the ID is from this account,
-					 * as it's generated by evolution */
-					const gchar *source_uid;
-
-					source_uid = g_hash_table_lookup (
-						expunging_uids, uids->pdata[ii]);
-					if (folder_is_from_source_uid (folder, source_uid)) {
-						any_found = TRUE;
-						camel_folder_delete_message (folder, uids->pdata[ii]);
-					}
-				}
-				camel_folder_free_uids (folder, uids);
-			}
+		folder = camel_store_get_inbox_folder_sync (
+			CAMEL_STORE (service), cancellable, error);
 
-			if (any_found)
-				success = camel_folder_synchronize_sync (
-					folder, TRUE, cancellable, error);
+		/* Abort the loop on error. */
+		if (folder == NULL) {
+			success = FALSE;
+			break;
+		}
 
+		uids = camel_folder_get_uids (folder);
+
+		if (uids == NULL) {
 			g_object_unref (folder);
+			continue;
+		}
 
-			/* Abort the loop on error. */
-			if (!success)
-				break;
+		for (ii = 0; ii < uids->len; ii++) {
+			/* ensure the ID is from this account,
+			 * as it's generated by evolution */
+			const gchar *source_uid;
+
+			source_uid = g_hash_table_lookup (
+				expunging_uids, uids->pdata[ii]);
+			if (folder_is_from_source_uid (folder, source_uid)) {
+				any_found = TRUE;
+				camel_folder_delete_message (
+					folder, uids->pdata[ii]);
+			}
 		}
+
+		camel_folder_free_uids (folder, uids);
+
+		if (any_found)
+			success = camel_folder_synchronize_sync (
+				folder, TRUE, cancellable, error);
+
+		g_object_unref (folder);
+
+		/* Abort the loop on error. */
+		if (!success)
+			break;
 	}
 
-	if (iter)
-		g_object_unref (iter);
+	g_list_free (list);
 
 	g_hash_table_destroy (expunging_uids);
 
diff --git a/libemail-engine/mail-ops.h b/libemail-engine/mail-ops.h
index 236dd23..cafcefc 100644
--- a/libemail-engine/mail-ops.h
+++ b/libemail-engine/mail-ops.h
@@ -72,7 +72,6 @@ void		mail_send_queue			(EMailSession *session,
 						 gpointer data);
 
 void		mail_fetch_mail			(CamelStore *store,
-						 gint keep,
 						 const gchar *type,
 						 GCancellable *cancellable,
 						 CamelFilterGetFolderFunc get_folder,
diff --git a/libemail-utils/Makefile.am b/libemail-utils/Makefile.am
index a856df6..18e9926 100644
--- a/libemail-utils/Makefile.am
+++ b/libemail-utils/Makefile.am
@@ -13,10 +13,6 @@ libemail_utils_la_CPPFLAGS = \
 
 libmailutilsincludedir = $(privincludedir)/libemail-utils
 libmailutilsinclude_HEADERS = \
-	e-account-utils.h \
-	e-signature-list.h \
-	e-signature-utils.h \
-	e-signature.h \
 	em-filter-folder-element.h \
 	em-vfolder-context.h \
 	em-vfolder-rule.h \
@@ -25,10 +21,6 @@ libmailutilsinclude_HEADERS = \
 
 libemail_utils_la_SOURCES = \
 	$(libmailutilsinclude_HEADERS) \
-	e-account-utils.c \
-	e-signature-list.c \
-	e-signature-utils.c \
-	e-signature.c \
 	em-filter-folder-element.c \
 	em-vfolder-context.c \
 	em-vfolder-rule.c \
diff --git a/mail/Makefile.am b/mail/Makefile.am
index 3a13284..0768162 100644
--- a/mail/Makefile.am
+++ b/mail/Makefile.am
@@ -44,6 +44,23 @@ mailinclude_HEADERS =					\
 	e-mail-attachment-bar.h				\
 	e-mail-backend.h				\
 	e-mail-browser.h				\
+	e-mail-config-assistant.h			\
+	e-mail-config-auth-check.h			\
+	e-mail-config-confirm-page.h			\
+	e-mail-config-defaults-page.h			\
+	e-mail-config-identity-page.h			\
+	e-mail-config-notebook.h			\
+	e-mail-config-page.h				\
+	e-mail-config-provider-page.h			\
+	e-mail-config-receiving-page.h			\
+	e-mail-config-security-page.h			\
+	e-mail-config-sending-page.h			\
+	e-mail-config-service-backend.h			\
+	e-mail-config-service-page.h			\
+	e-mail-config-sidebar.h				\
+	e-mail-config-summary-page.h			\
+	e-mail-config-welcome-page.h			\
+	e-mail-config-window.h				\
 	e-mail-display.h				\
 	e-mail-folder-pane.h				\
 	e-mail-junk-options.h				\
@@ -62,7 +79,6 @@ mailinclude_HEADERS =					\
 	e-mail-sidebar.h				\
 	e-mail-tag-editor.h				\
 	e-mail-view.h					\
-	em-account-editor.h				\
 	em-composer-utils.h				\
 	em-config.h					\
 	em-event.h					\
@@ -109,6 +125,23 @@ libevolution_mail_la_SOURCES =				\
 	e-mail-attachment-bar.c				\
 	e-mail-backend.c				\
 	e-mail-browser.c				\
+	e-mail-config-assistant.c			\
+	e-mail-config-auth-check.c			\
+	e-mail-config-confirm-page.c			\
+	e-mail-config-defaults-page.c			\
+	e-mail-config-identity-page.c			\
+	e-mail-config-notebook.c			\
+	e-mail-config-page.c				\
+	e-mail-config-provider-page.c			\
+	e-mail-config-receiving-page.c			\
+	e-mail-config-security-page.c			\
+	e-mail-config-sending-page.c			\
+	e-mail-config-service-backend.c			\
+	e-mail-config-service-page.c			\
+	e-mail-config-sidebar.c				\
+	e-mail-config-summary-page.c			\
+	e-mail-config-welcome-page.c			\
+	e-mail-config-window.c				\
 	e-mail-display.c				\
 	e-mail-folder-pane.c				\
 	e-mail-junk-options.c				\
@@ -127,7 +160,6 @@ libevolution_mail_la_SOURCES =				\
 	e-mail-sidebar.c				\
 	e-mail-tag-editor.c				\
 	e-mail-view.c					\
-	em-account-editor.c				\
 	em-composer-utils.c				\
 	em-config.c					\
 	em-event.c					\
diff --git a/mail/e-mail-account-manager.c b/mail/e-mail-account-manager.c
index 86a0bf5..0f57078 100644
--- a/mail/e-mail-account-manager.c
+++ b/mail/e-mail-account-manager.c
@@ -70,18 +70,25 @@ static void
 mail_account_manager_edit_cb (EMailAccountManager *manager)
 {
 	EMailAccountTreeView *tree_view;
-	EAccount *account;
+	EMailAccountStore *store;
+	ESourceRegistry *registry;
+	EMailSession *session;
 	CamelService *service;
+	ESource *source;
 	const gchar *uid;
 
+	store = e_mail_account_manager_get_store (manager);
+	session = e_mail_account_store_get_session (store);
+	registry = e_mail_session_get_registry (session);
+
 	tree_view = E_MAIL_ACCOUNT_TREE_VIEW (manager->priv->tree_view);
 	service = e_mail_account_tree_view_get_selected_service (tree_view);
 
 	uid = camel_service_get_uid (service);
-	account = e_get_account_by_uid (uid);
-	g_return_if_fail (account != NULL);
+	source = e_source_registry_lookup_by_uid (registry, uid);
+	g_return_if_fail (source != NULL);
 
-	e_mail_account_manager_edit_account (manager, account);
+	e_mail_account_manager_edit_account (manager, source);
 }
 
 static void
@@ -519,7 +526,7 @@ e_mail_account_manager_class_init (EMailAccountManagerClass *class)
 		NULL, NULL,
 		g_cclosure_marshal_VOID__OBJECT,
 		G_TYPE_NONE, 1,
-		E_TYPE_ACCOUNT);
+		E_TYPE_SOURCE);
 }
 
 static void
@@ -556,11 +563,11 @@ e_mail_account_manager_add_account (EMailAccountManager *manager)
 
 void
 e_mail_account_manager_edit_account (EMailAccountManager *manager,
-                                     EAccount *account)
+                                     ESource *source)
 {
 	g_return_if_fail (E_IS_MAIL_ACCOUNT_MANAGER (manager));
-	g_return_if_fail (E_IS_ACCOUNT (account));
+	g_return_if_fail (E_IS_SOURCE (source));
 
-	g_signal_emit (manager, signals[EDIT_ACCOUNT], 0, account);
+	g_signal_emit (manager, signals[EDIT_ACCOUNT], 0, source);
 }
 
diff --git a/mail/e-mail-account-manager.h b/mail/e-mail-account-manager.h
index 63e52b4..a17ff2a 100644
--- a/mail/e-mail-account-manager.h
+++ b/mail/e-mail-account-manager.h
@@ -20,8 +20,8 @@
 #define E_MAIL_ACCOUNT_MANAGER_H
 
 #include <gtk/gtk.h>
+#include <libedataserver/e-source.h>
 #include <mail/e-mail-account-store.h>
-#include <libemail-utils/e-account-utils.h>
 
 /* Standard GObject macros */
 #define E_TYPE_MAIL_ACCOUNT_MANAGER \
@@ -59,7 +59,7 @@ struct _EMailAccountManagerClass {
 	/* Signals */
 	void		(*add_account)		(EMailAccountManager *manager);
 	void		(*edit_account)		(EMailAccountManager *manager,
-						 EAccount *account);
+						 ESource *source);
 };
 
 GType		e_mail_account_manager_get_type	(void) G_GNUC_CONST;
@@ -71,7 +71,7 @@ void		e_mail_account_manager_add_account
 						(EMailAccountManager *manager);
 void		e_mail_account_manager_edit_account
 						(EMailAccountManager *manager,
-						 EAccount *account);
+						 ESource *source);
 
 G_END_DECLS
 
diff --git a/mail/e-mail-account-store.c b/mail/e-mail-account-store.c
index 2dac692..bab5d1b 100644
--- a/mail/e-mail-account-store.c
+++ b/mail/e-mail-account-store.c
@@ -27,7 +27,6 @@
 #include <e-util/e-marshal.h>
 #include <libevolution-utils/e-alert-dialog.h>
 
-#include <libemail-utils/e-account-utils.h>
 #include <libemail-engine/mail-ops.h>
 
 #include <mail/mail-vfolder-ui.h>
@@ -101,24 +100,6 @@ index_item_free (IndexItem *item)
 	g_slice_free (IndexItem, item);
 }
 
-static void
-mail_account_store_save_default (EMailAccountStore *store)
-{
-	EAccountList *account_list;
-	EAccount *account;
-	CamelService *service;
-	const gchar *uid;
-
-	service = e_mail_account_store_get_default_service (store);
-
-	account_list = e_get_account_list ();
-	uid = camel_service_get_uid (service);
-	account = e_get_account_by_uid (uid);
-	g_return_if_fail (account != NULL);
-
-	e_account_list_set_default (account_list, account);
-}
-
 static gboolean
 mail_account_store_get_iter (EMailAccountStore *store,
                              CamelService *service,
@@ -238,6 +219,46 @@ mail_account_store_service_notify_cb (CamelService *service,
 }
 
 static void
+mail_account_store_remove_source_cb (ESourceRegistry *registry,
+                                     GAsyncResult *result,
+                                     EMailAccountStore *store)
+{
+	GError *error = NULL;
+
+	/* FIXME EMailAccountStore should implement EAlertSink. */
+	if (!e_source_registry_remove_source_finish (registry, result, &error)) {
+		g_warning ("%s: %s", G_STRFUNC, error->message);
+		g_error_free (error);
+	}
+
+	g_return_if_fail (store->priv->busy_count > 0);
+	store->priv->busy_count--;
+	g_object_notify (G_OBJECT (store), "busy");
+
+	g_object_unref (store);
+}
+
+static void
+mail_account_store_write_source_cb (ESource *source,
+                                    GAsyncResult *result,
+                                    EMailAccountStore *store)
+{
+	GError *error = NULL;
+
+	/* FIXME EMailAccountStore should implement EAlertSink. */
+	if (!e_source_write_finish (source, result, &error)) {
+		g_warning ("%s: %s", G_STRFUNC, error->message);
+		g_error_free (error);
+	}
+
+	g_return_if_fail (store->priv->busy_count > 0);
+	store->priv->busy_count--;
+	g_object_notify (G_OBJECT (store), "busy");
+
+	g_object_unref (store);
+}
+
+static void
 mail_account_store_clean_index (EMailAccountStore *store)
 {
 	GQueue trash = G_QUEUE_INIT;
@@ -427,23 +448,34 @@ static void
 mail_account_store_constructed (GObject *object)
 {
 	EMailAccountStore *store;
+	EMailSession *session;
+	ESourceRegistry *registry;
 	const gchar *config_dir;
 
 	/* Chain up to parent's constructed() method. */
 	G_OBJECT_CLASS (e_mail_account_store_parent_class)->constructed (object);
 
 	store = E_MAIL_ACCOUNT_STORE (object);
+	session = e_mail_account_store_get_session (store);
+	registry = e_mail_session_get_registry (session);
+
+	/* Bind the default mail account ESource to our default
+	 * CamelService, with help from some transform functions. */
+	g_object_bind_property_full (
+		registry, "default-mail-account",
+		store, "default-service",
+		G_BINDING_BIDIRECTIONAL |
+		G_BINDING_SYNC_CREATE,
+		e_binding_transform_source_to_service,
+		e_binding_transform_service_to_source,
+		session, (GDestroyNotify) NULL);
+
 	config_dir = mail_session_get_config_dir ();
 
 	/* XXX Should we take the filename as a constructor property? */
 	store->priv->sort_order_filename = g_build_filename (
 		config_dir, "sortorder.ini", NULL);
 
-	/* XXX This is kinda lame, but should work until EAccount dies. */
-	g_signal_connect (
-		object, "notify::default-service",
-		G_CALLBACK (mail_account_store_save_default), NULL);
-
 	e_extensible_load_extensions (E_EXTENSIBLE (object));
 }
 
@@ -458,94 +490,55 @@ static void
 mail_account_store_service_removed (EMailAccountStore *store,
                                     CamelService *service)
 {
-	/* XXX On the account-mgmt branch this operation is asynchronous.
-	 *     The 'busy_count' is bumped until changes are written back
-	 *     to the D-Bus service.  For now I guess we'll just block. */
-
-	EAccountList *account_list;
-	EAccount *account;
 	EMailSession *session;
-	MailFolderCache *cache;
-	CamelProvider *provider;
+	ESourceRegistry *registry;
+	ESource *source;
 	const gchar *uid;
 
 	session = e_mail_account_store_get_session (store);
-	cache = e_mail_session_get_folder_cache (session);
+	registry = e_mail_session_get_registry (session);
 
-	mail_folder_cache_service_removed (cache, service);
-
-	account_list = e_get_account_list ();
 	uid = camel_service_get_uid (service);
-	account = e_get_account_by_uid (uid);
-	g_return_if_fail (account != NULL);
-
-	/* no change */
-	if (!account->enabled)
-		return;
-
-	provider = camel_service_get_provider (service);
-	g_return_if_fail (provider != NULL);
-
-	if (provider->flags & CAMEL_PROVIDER_IS_STORAGE)
-		mail_disconnect_store (CAMEL_STORE (service));
+	source = e_source_registry_lookup_by_uid (registry, uid);
 
-	/* Remove all the proxies the account has created.
-	 * FIXME This proxy stuff belongs in evolution-groupwise. */
-	e_account_list_remove_account_proxies (account_list, account);
+	if (E_IS_SOURCE (source)) {
+		store->priv->busy_count++;
+		g_object_notify (G_OBJECT (store), "busy");
 
-	e_account_list_remove (account_list, account);
-
-	e_account_list_save (account_list);
+		/* XXX Should this be cancellable? */
+		e_source_registry_remove_source (
+			registry, source, NULL, (GAsyncReadyCallback)
+			mail_account_store_remove_source_cb,
+			g_object_ref (store));
+	}
 }
 
 static void
 mail_account_store_service_enabled (EMailAccountStore *store,
                                     CamelService *service)
 {
-	/* XXX On the account-mgmt branch this operation is asynchronous.
-	 *     The 'busy_count' is bumped until changes are written back
-	 *     to the D-Bus service.  For now I guess we'll just block. */
-
 	EMailSession *session;
-	MailFolderCache *cache;
-	GSettings *settings;
+	ESourceRegistry *registry;
+	ESource *source;
 	const gchar *uid;
 
 	session = e_mail_account_store_get_session (store);
-	cache = e_mail_session_get_folder_cache (session);
-
-	mail_folder_cache_service_enabled (cache, service);
+	registry = e_mail_session_get_registry (session);
 
 	uid = camel_service_get_uid (service);
+	source = e_source_registry_lookup_by_uid (registry, uid);
 
-	/* Handle built-in services that don't have an EAccount. */
-
-	if (g_strcmp0 (uid, E_MAIL_SESSION_LOCAL_UID) == 0) {
-		settings = g_settings_new ("org.gnome.evolution.mail");
-		g_settings_set_boolean (settings, "enable-local", TRUE);
-		g_object_unref (settings);
-
-	} else if (g_strcmp0 (uid, E_MAIL_SESSION_VFOLDER_UID) == 0) {
-		settings = g_settings_new ("org.gnome.evolution.mail");
-		g_settings_set_boolean (settings, "enable-vfolders", TRUE);
-		g_object_unref (settings);
-
-	} else {
-		EAccountList *account_list;
-		EAccount *account;
-
-		account_list = e_get_account_list ();
-		account = e_get_account_by_uid (uid);
-		g_return_if_fail (account != NULL);
-
-		/* no change */
-		if (account->enabled)
-			return;
+	if (E_IS_SOURCE (source)) {
+		e_source_set_enabled (source, TRUE);
 
-		account->enabled = TRUE;
+		store->priv->busy_count++;
+		g_object_notify (G_OBJECT (store), "busy");
 
-		e_account_list_change (account_list, account);
-		e_account_list_save (account_list);
+		/* XXX Should this be cancellable? */
+		e_source_write (
+			source, NULL, (GAsyncReadyCallback)
+			mail_account_store_write_source_cb,
+			g_object_ref (store));
 	}
 }
 
@@ -553,63 +546,28 @@ static void
 mail_account_store_service_disabled (EMailAccountStore *store,
                                      CamelService *service)
 {
-	/* XXX On the account-mgmt branch this operation is asynchronous.
-	 *     The 'busy_count' is bumped until changes are written back
-	 *     to the D-Bus service.  For now I guess we'll just block. */
-
 	EMailSession *session;
-	MailFolderCache *cache;
-	GSettings *settings;
+	ESourceRegistry *registry;
+	ESource *source;
 	const gchar *uid;
 
 	session = e_mail_account_store_get_session (store);
-	cache = e_mail_session_get_folder_cache (session);
-
-	mail_folder_cache_service_disabled (cache, service);
+	registry = e_mail_session_get_registry (session);
 
 	uid = camel_service_get_uid (service);
+	source = e_source_registry_lookup_by_uid (registry, uid);
 
-	/* Handle built-in services that don't have an EAccount. */
+	if (E_IS_SOURCE (source)) {
+		e_source_set_enabled (source, FALSE);
 
-	if (g_strcmp0 (uid, E_MAIL_SESSION_LOCAL_UID) == 0) {
-		settings = g_settings_new ("org.gnome.evolution.mail");
-		g_settings_set_boolean (settings, "enable-local", FALSE);
-		g_object_unref (settings);
-
-	} else if (g_strcmp0 (uid, E_MAIL_SESSION_VFOLDER_UID) == 0) {
-		settings = g_settings_new ("org.gnome.evolution.mail");
-		g_settings_set_boolean (settings, "enable-vfolders", FALSE);
-		g_object_unref (settings);
-
-	} else {
-		EAccountList *account_list;
-		EAccount *account;
-		CamelProvider *provider;
+		store->priv->busy_count++;
+		g_object_notify (G_OBJECT (store), "busy");
 
-		account_list = e_get_account_list ();
-		account = e_get_account_by_uid (uid);
-		g_return_if_fail (account != NULL);
-
-		/* no change */
-		if (!account->enabled)
-			return;
-
-		account->enabled = FALSE;
-
-		provider = camel_service_get_provider (service);
-		g_return_if_fail (provider != NULL);
-
-		if (provider->flags & CAMEL_PROVIDER_IS_STORAGE)
-			mail_disconnect_store (CAMEL_STORE (service));
-
-		/* FIXME This proxy stuff belongs in evolution-groupwise. */
-		e_account_list_remove_account_proxies (account_list, account);
-
-		if (account->parent_uid != NULL)
-			e_account_list_remove (account_list, account);
-
-		e_account_list_change (account_list, account);
-		e_account_list_save (account_list);
+		/* XXX Should this be cancellable? */
+		e_source_write (
+			source, NULL, (GAsyncReadyCallback)
+			mail_account_store_write_source_cb,
+			g_object_ref (store));
 	}
 }
 
@@ -643,25 +601,14 @@ mail_account_store_remove_requested (EMailAccountStore *store,
                                      GtkWindow *parent_window,
                                      CamelService *service)
 {
-	EAccountList *account_list;
-	EAccount *account;
-	const gchar *alert;
-	const gchar *uid;
 	gint response;
 
-	account_list = e_get_account_list ();
-	uid = camel_service_get_uid (service);
-	account = e_get_account_by_uid (uid);
-
-	g_return_val_if_fail (account != NULL, FALSE);
-
-	/* FIXME This proxy stuff belongs in evolution-groupwise. */
-	if (e_account_list_account_has_proxies (account_list, account))
-		alert = "mail:ask-delete-account-with-proxies";
-	else
-		alert = "mail:ask-delete-account";
+	/* FIXME Need to use "mail:ask-delete-account-with-proxies" if the
+	 *       mail account has proxies.  But this is groupwise-specific
+	 *       and doesn't belong here anyway.  Think of a better idea. */
 
-	response = e_alert_run_dialog_for_args (parent_window, alert, NULL);
+	response = e_alert_run_dialog_for_args (
+		parent_window, "mail:ask-delete-account", NULL);
 
 	return (response == GTK_RESPONSE_YES);
 }
@@ -679,34 +626,12 @@ mail_account_store_disable_requested (EMailAccountStore *store,
                                       GtkWindow *parent_window,
                                       CamelService *service)
 {
-	EAccountList *account_list;
-	EAccount *account;
-	const gchar *uid;
-	gint response;
-
-	account_list = e_get_account_list ();
-	uid = camel_service_get_uid (service);
-	account = e_get_account_by_uid (uid);
-
-	/* "On This Computer" and "Search Folders" do not have
-	 * EAccounts, so just silently return TRUE if we failed
-	 * to find a matching EAccount for the CamelService. */
-
-	/* Silently return TRUE if we failed to find a matching
-	 * EAccount since "On This Computer" and "Search Folders"
-	 * do not have EAccounts. */
-	if (account == NULL)
-		return TRUE;
-
-	/* FIXME This proxy stuff belongs in evolution-groupwise. */
-	if (e_account_list_account_has_proxies (account_list, account))
-		response = e_alert_run_dialog_for_args (
-			parent_window,
-			"mail:ask-delete-proxy-accounts", NULL);
-	else
-		response = GTK_RESPONSE_YES;
+	/* FIXME Need to check whether the account has proxies and run a
+	 *       "mail:ask-delete-proxy-accounts" alert dialog, but this
+	 *       is groupwise-specific and doesn't belong here anyway.
+	 *       Think of a better idea. */
 
-	return (response == GTK_RESPONSE_YES);
+	return TRUE;
 }
 
 static void
@@ -1086,13 +1011,18 @@ e_mail_account_store_add_service (EMailAccountStore *store,
 		g_object_unref (settings);
 
 	} else {
-		EAccount *account;
+		EMailSession *session;
+		ESourceRegistry *registry;
+		ESource *source;
+
+		session = e_mail_account_store_get_session (store);
 
-		account = e_get_account_by_uid (uid);
-		g_return_if_fail (account != NULL);
+		registry = e_mail_session_get_registry (session);
+		source = e_source_registry_lookup_by_uid (registry, uid);
+		g_return_if_fail (source != NULL);
 
 		builtin = FALSE;
-		enabled = account->enabled;
+		enabled = e_source_get_enabled (source);
 	}
 
 	/* Where do we insert new services now that accounts can be
diff --git a/mail/e-mail-backend.c b/mail/e-mail-backend.c
index c350bd7..2a0a386 100644
--- a/mail/e-mail-backend.c
+++ b/mail/e-mail-backend.c
@@ -32,15 +32,15 @@
 #include <glib/gstdio.h>
 #include <glib/gi18n-lib.h>
 #include <libedataserver/e-data-server-util.h>
+#include <libedataserver/e-source-mail-account.h>
+#include <libedataserver/e-source-mail-composition.h>
+#include <libedataserver/e-source-mail-submission.h>
 
 #include <shell/e-shell.h>
 
 #include <libevolution-utils/e-alert-dialog.h>
 #include <libevolution-utils/e-alert-sink.h>
 
-#include <misc/e-account-combo-box.h>
-
-#include <libemail-utils/e-account-utils.h>
 #include <libemail-engine/e-mail-folder-utils.h>
 #include <libemail-engine/e-mail-session.h>
 #include <libemail-engine/e-mail-store-utils.h>
@@ -141,11 +141,14 @@ mail_backend_prepare_for_offline_cb (EShell *shell,
 {
 	GtkWindow *window;
 	EMailSession *session;
+	ESourceRegistry *registry;
 	GList *list, *link;
+	const gchar *extension_name;
 	gboolean synchronize = FALSE;
 
 	window = e_shell_get_active_window (shell);
 	session = e_mail_backend_get_session (backend);
+	registry = e_mail_session_get_registry (session);
 
 	if (e_shell_get_network_available (shell) &&
 		e_shell_backend_is_started (E_SHELL_BACKEND (backend)))
@@ -158,12 +161,17 @@ mail_backend_prepare_for_offline_cb (EShell *shell,
 			CAMEL_SESSION (session), FALSE);
 	}
 
-	list = camel_session_list_services (CAMEL_SESSION (session));
+	extension_name = E_SOURCE_EXTENSION_MAIL_ACCOUNT;
+	list = e_source_registry_list_sources (registry, extension_name);
 
 	for (link = list; link != NULL; link = g_list_next (link)) {
+		ESource *source = E_SOURCE (link->data);
 		CamelService *service;
+		const gchar *uid;
 
-		service = CAMEL_SERVICE (link->data);
+		uid = e_source_get_uid (source);
+		service = camel_session_get_service (
+			CAMEL_SESSION (session), uid);
 
 		if (!CAMEL_IS_STORE (service))
 			continue;
@@ -185,27 +193,31 @@ mail_backend_prepare_for_online_cb (EShell *shell,
                                     EMailBackend *backend)
 {
 	EMailSession *session;
+	ESourceRegistry *registry;
 	GList *list, *link;
+	const gchar *extension_name;
 
 	session = e_mail_backend_get_session (backend);
+	registry = e_mail_session_get_registry (session);
+
 	camel_session_set_online (CAMEL_SESSION (session), TRUE);
 
-	list = camel_session_list_services (CAMEL_SESSION (session));
+	extension_name = E_SOURCE_EXTENSION_MAIL_ACCOUNT;
+	list = e_source_registry_list_sources (registry, extension_name);
 
 	for (link = list; link != NULL; link = g_list_next (link)) {
+		ESource *source = E_SOURCE (link->data);
 		CamelService *service;
-		EAccount *account;
 		const gchar *uid;
 
-		service = CAMEL_SERVICE (link->data);
-
-		if (!CAMEL_IS_STORE (service))
+		if (!e_source_get_enabled (source))
 			continue;
 
-		uid = camel_service_get_uid (service);
-		account = e_get_account_by_uid (uid);
+		uid = e_source_get_uid (source);
+		service = camel_session_get_service (
+			CAMEL_SESSION (session), uid);
 
-		if (account != NULL && !account->enabled)
+		if (!CAMEL_IS_STORE (service))
 			continue;
 
 		/* FIXME Not passing a GCancellable. */
@@ -273,7 +285,6 @@ mail_backend_prepare_for_quit_cb (EShell *shell,
                                   EActivity *activity,
                                   EMailBackend *backend)
 {
-	EAccountList *account_list;
 	EMailSession *session;
 	GList *list, *link;
 	gboolean delete_junk;
@@ -286,9 +297,6 @@ mail_backend_prepare_for_quit_cb (EShell *shell,
 
 	camel_application_is_exiting = TRUE;
 
-	account_list = e_get_account_list ();
-	e_account_list_prune_proxies (account_list);
-
 	mail_vfolder_shutdown ();
 
 	/* Cancel all pending activities. */
@@ -399,20 +407,26 @@ mail_backend_folder_deleted_cb (MailFolderCache *folder_cache,
                                 const gchar *folder_name,
                                 EMailBackend *backend)
 {
+	EShell *shell;
 	CamelStoreClass *class;
-	EAccountList *account_list;
-	EIterator *iterator;
+	ESourceRegistry *registry;
+	EShellBackend *shell_backend;
 	EMailSession *session;
 	EAlertSink *alert_sink;
+	GList *list, *link;
+	const gchar *extension_name;
 	const gchar *local_drafts_folder_uri;
 	const gchar *local_sent_folder_uri;
-	gboolean write_config = FALSE;
 	gchar *uri;
 
 	/* Check whether the deleted folder was a designated Drafts or
 	 * Sent folder for any mail account, and if so revert the setting
 	 * to the equivalent local folder, which is always present. */
 
+	shell_backend = E_SHELL_BACKEND (backend);
+	shell = e_shell_backend_get_shell (shell_backend);
+	registry = e_shell_get_registry (shell);
+
 	class = CAMEL_STORE_GET_CLASS (store);
 	g_return_if_fail (class->compare_folder_name != NULL);
 
@@ -429,51 +443,69 @@ mail_backend_folder_deleted_cb (MailFolderCache *folder_cache,
 
 	uri = e_mail_folder_uri_build (store, folder_name);
 
-	account_list = e_get_account_list ();
-	iterator = e_list_get_iterator (E_LIST (account_list));
+	extension_name = E_SOURCE_EXTENSION_MAIL_COMPOSITION;
+	list = e_source_registry_list_sources (registry, extension_name);
+
+	for (link = list; link != NULL; link = g_list_next (link)) {
+		ESource *source = E_SOURCE (link->data);
+		ESourceExtension *extension;
+		const gchar *drafts_folder_uri;
 
-	while (e_iterator_is_valid (iterator)) {
-		EAccount *account;
+		extension = e_source_get_extension (source, extension_name);
 
-		/* XXX EIterator misuses const. */
-		account = (EAccount *) e_iterator_get (iterator);
+		drafts_folder_uri =
+			e_source_mail_composition_get_drafts_folder (
+			E_SOURCE_MAIL_COMPOSITION (extension));
 
-		if (account->sent_folder_uri != NULL) {
-			gboolean match;
+		if (class->compare_folder_name (drafts_folder_uri, uri)) {
+			GError *error = NULL;
 
-			match = class->compare_folder_name (
-				account->sent_folder_uri, uri);
+			e_source_mail_composition_set_drafts_folder (
+				E_SOURCE_MAIL_COMPOSITION (extension),
+				local_drafts_folder_uri);
 
-			if (match) {
-				g_free (account->sent_folder_uri);
-				account->sent_folder_uri =
-					g_strdup (local_sent_folder_uri);
-				write_config = TRUE;
+			/* FIXME This is a blocking D-Bus method call. */
+			if (!e_source_write_sync (source, NULL, &error)) {
+				g_warning ("%s", error->message);
+				g_error_free (error);
 			}
 		}
+	}
+
+	g_list_free (list);
 
-		if (account->drafts_folder_uri != NULL) {
-			gboolean match;
+	extension_name = E_SOURCE_EXTENSION_MAIL_SUBMISSION;
+	list = e_source_registry_list_sources (registry, extension_name);
 
-			match = class->compare_folder_name (
-				account->drafts_folder_uri, uri);
+	for (link = list; link != NULL; link = g_list_next (link)) {
+		ESource *source = E_SOURCE (link->data);
+		ESourceExtension *extension;
+		const gchar *sent_folder_uri;
+
+		extension = e_source_get_extension (source, extension_name);
+
+		sent_folder_uri =
+			e_source_mail_submission_get_sent_folder (
+			E_SOURCE_MAIL_SUBMISSION (extension));
+
+		if (class->compare_folder_name (sent_folder_uri, uri)) {
+			GError *error = NULL;
 
-			if (match) {
-				g_free (account->drafts_folder_uri);
-				account->drafts_folder_uri =
-					g_strdup (local_drafts_folder_uri);
-				write_config = TRUE;
+			e_source_mail_submission_set_sent_folder (
+				E_SOURCE_MAIL_SUBMISSION (extension),
+				local_sent_folder_uri);
+
+			/* FIXME This is a blocking D-Bus method call. */
+			if (!e_source_write_sync (source, NULL, &error)) {
+				g_warning ("%s", error->message);
+				g_error_free (error);
 			}
 		}
-
-		e_iterator_next (iterator);
 	}
 
-	g_object_unref (iterator);
-	g_free (uri);
+	g_list_free (list);
 
-	if (write_config)
-		mail_config_write ();
+	g_free (uri);
 
 	/* This does something completely different.
 	 * XXX Make it a separate signal handler? */
@@ -487,10 +519,12 @@ mail_backend_folder_renamed_cb (MailFolderCache *folder_cache,
                                 const gchar *new_folder_name,
                                 EMailBackend *backend)
 {
+	EShell *shell;
 	CamelStoreClass *class;
-	EAccountList *account_list;
-	EIterator *iterator;
-	gboolean write_config = FALSE;
+	ESourceRegistry *registry;
+	EShellBackend *shell_backend;
+	GList *list, *link;
+	const gchar *extension_name;
 	gchar *old_uri;
 	gchar *new_uri;
 	gint ii;
@@ -500,54 +534,84 @@ mail_backend_folder_renamed_cb (MailFolderCache *folder_cache,
 		"views/custom_view-"
 	};
 
+	/* Check whether the renamed folder was a designated Drafts or
+	 * Sent folder for any mail account, and if so update the setting
+	 * to the new folder name. */
+
+	shell_backend = E_SHELL_BACKEND (backend);
+	shell = e_shell_backend_get_shell (shell_backend);
+	registry = e_shell_get_registry (shell);
+
 	class = CAMEL_STORE_GET_CLASS (store);
 	g_return_if_fail (class->compare_folder_name != NULL);
 
 	old_uri = e_mail_folder_uri_build (store, old_folder_name);
 	new_uri = e_mail_folder_uri_build (store, new_folder_name);
 
-	account_list = e_get_account_list ();
-	iterator = e_list_get_iterator (E_LIST (account_list));
+	extension_name = E_SOURCE_EXTENSION_MAIL_COMPOSITION;
+	list = e_source_registry_list_sources (registry, extension_name);
+
+	for (link = list; link != NULL; link = g_list_next (link)) {
+		ESource *source = E_SOURCE (link->data);
+		ESourceExtension *extension;
+		const gchar *drafts_folder_uri;
 
-	while (e_iterator_is_valid (iterator)) {
-		EAccount *account;
+		extension = e_source_get_extension (source, extension_name);
 
-		/* XXX EIterator misuses const. */
-		account = (EAccount *) e_iterator_get (iterator);
+		drafts_folder_uri =
+			e_source_mail_composition_get_drafts_folder (
+			E_SOURCE_MAIL_COMPOSITION (extension));
 
-		if (account->sent_folder_uri != NULL) {
-			gboolean match;
+		if (class->compare_folder_name (drafts_folder_uri, old_uri)) {
+			GError *error = NULL;
 
-			match = class->compare_folder_name (
-				account->sent_folder_uri, old_uri);
+			e_source_mail_composition_set_drafts_folder (
+				E_SOURCE_MAIL_COMPOSITION (extension),
+				new_uri);
 
-			if (match) {
-				g_free (account->sent_folder_uri);
-				account->sent_folder_uri = g_strdup (new_uri);
-				write_config = TRUE;
+			/* FIXME This is a blocking D-Bus method call. */
+			if (!e_source_write_sync (source, NULL, &error)) {
+				g_warning ("%s", error->message);
+				g_error_free (error);
 			}
 		}
+	}
 
-		if (account->drafts_folder_uri != NULL) {
-			gboolean match;
+	g_list_free (list);
+
+	extension_name = E_SOURCE_EXTENSION_MAIL_SUBMISSION;
+	list = e_source_registry_list_sources (registry, extension_name);
 
-			match = class->compare_folder_name (
-				account->drafts_folder_uri, old_uri);
+	for (link = list; link != NULL; link = g_list_next (link)) {
+		ESource *source = E_SOURCE (link->data);
+		ESourceExtension *extension;
+		const gchar *sent_folder_uri;
 
-			if (match) {
-				g_free (account->drafts_folder_uri);
-				account->drafts_folder_uri = g_strdup (new_uri);
-				write_config = TRUE;
+		extension = e_source_get_extension (source, extension_name);
+
+		sent_folder_uri =
+			e_source_mail_submission_get_sent_folder (
+			E_SOURCE_MAIL_SUBMISSION (extension));
+
+		if (class->compare_folder_name (sent_folder_uri, old_uri)) {
+			GError *error = NULL;
+
+			e_source_mail_submission_set_sent_folder (
+				E_SOURCE_MAIL_SUBMISSION (extension),
+				new_uri);
+
+			/* FIXME This is a blocking D-Bus method call. */
+			if (!e_source_write_sync (source, NULL, &error)) {
+				g_warning ("%s", error->message);
+				g_error_free (error);
 			}
 		}
-
-		e_iterator_next (iterator);
 	}
 
-	g_object_unref (iterator);
+	g_list_free (list);
 
-	if (write_config)
-		mail_config_write ();
+	g_free (old_uri);
+	g_free (new_uri);
 
 	/* Rename GalView files. */
 
@@ -565,9 +629,6 @@ mail_backend_folder_renamed_cb (MailFolderCache *folder_cache,
 		g_free (newname);
 	}
 
-	g_free (old_uri);
-	g_free (new_uri);
-
 	/* This does something completely different.
 	 * XXX Make it a separate signal handler? */
 	mail_filter_rename_folder (
@@ -606,10 +667,8 @@ mail_backend_folder_changed_cb (MailFolderCache *folder_cache,
 			g_object_unref (folder);
 	}
 
-	g_free (folder_uri);
-
 	target = em_event_target_new_folder (
-		event, store, folder_name, new_messages,
+		event, store, folder_uri, new_messages,
 		msg_uid, msg_sender, msg_subject);
 
 	folder_type = (flags & CAMEL_FOLDER_TYPE_MASK);
@@ -939,6 +998,7 @@ mail_backend_constructed (GObject *object)
 	EShell *shell;
 	EShellBackend *shell_backend;
 	MailFolderCache *folder_cache;
+	ESourceRegistry *registry;
 
 	priv = E_MAIL_BACKEND_GET_PRIVATE (object);
 
@@ -948,9 +1008,8 @@ mail_backend_constructed (GObject *object)
 	if (camel_init (e_get_user_data_dir (), TRUE) != 0)
 		exit (0);
 
-	camel_provider_init ();
-
-	priv->session = e_mail_ui_session_new ();
+	registry = e_shell_get_registry (shell);
+	priv->session = e_mail_ui_session_new (registry);
 
 	g_signal_connect (
 		priv->session, "flush-outbox",
@@ -978,10 +1037,6 @@ mail_backend_constructed (GObject *object)
 		G_CALLBACK (mail_backend_job_finished_cb),
 		shell_backend);
 
-	/* FIXME This is an evil hack that needs to die.
-	 *       Give EAccountComboBox a CamelSession property. */
-	e_account_combo_box_set_session (CAMEL_SESSION (priv->session));
-
 	g_signal_connect (
 		priv->session, "store-added",
 		G_CALLBACK (mail_backend_add_store),
@@ -1029,7 +1084,6 @@ mail_backend_constructed (GObject *object)
 		G_CALLBACK (mail_backend_folder_changed_cb), shell_backend);
 
 	mail_config_init (priv->session);
-	mail_msg_init ();
 
 	mail_msg_register_activities (
 		mail_mt_create_activity,
diff --git a/mail/e-mail-config-assistant.c b/mail/e-mail-config-assistant.c
new file mode 100644
index 0000000..4844a78
--- /dev/null
+++ b/mail/e-mail-config-assistant.c
@@ -0,0 +1,789 @@
+/*
+ * e-mail-config-assistant.c
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) version 3.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with the program; if not, see <http://www.gnu.org/licenses/>
+ *
+ */
+
+#include "e-mail-config-assistant.h"
+
+#include <config.h>
+#include <glib/gi18n-lib.h>
+
+#include <libebackend/e-extensible.h>
+#include <libedataserver/e-source-mail-account.h>
+#include <libedataserver/e-source-mail-composition.h>
+#include <libedataserver/e-source-mail-submission.h>
+#include <libedataserver/e-source-mail-transport.h>
+
+#include <mail/e-mail-config-confirm-page.h>
+#include <mail/e-mail-config-identity-page.h>
+#include <mail/e-mail-config-provider-page.h>
+#include <mail/e-mail-config-receiving-page.h>
+#include <mail/e-mail-config-sending-page.h>
+#include <mail/e-mail-config-summary-page.h>
+#include <mail/e-mail-config-welcome-page.h>
+
+#define E_MAIL_CONFIG_ASSISTANT_GET_PRIVATE(obj) \
+	(G_TYPE_INSTANCE_GET_PRIVATE \
+	((obj), E_TYPE_MAIL_CONFIG_ASSISTANT, EMailConfigAssistantPrivate))
+
+#define DEFAULT_RECVING_BACKEND "imapx"
+#define DEFAULT_SENDING_BACKEND "smtp"
+
+struct _EMailConfigAssistantPrivate {
+	EMailSession *session;
+	ESource *identity_source;
+	GPtrArray *account_sources;
+	GPtrArray *transport_sources;
+	EMailConfigServicePage *receiving_page;
+	EMailConfigServicePage *sending_page;
+	EMailConfigSummaryPage *summary_page;
+};
+
+enum {
+	PROP_0,
+	PROP_ACCOUNT_SOURCE,
+	PROP_IDENTITY_SOURCE,
+	PROP_SESSION,
+	PROP_TRANSPORT_SOURCE
+};
+
+G_DEFINE_TYPE_WITH_CODE (
+	EMailConfigAssistant,
+	e_mail_config_assistant,
+	GTK_TYPE_ASSISTANT,
+	G_IMPLEMENT_INTERFACE (
+		E_TYPE_EXTENSIBLE, NULL))
+
+static gint
+mail_config_assistant_provider_compare (gconstpointer data1,
+                                        gconstpointer data2)
+{
+	const CamelProvider *provider1 = data1;
+	const CamelProvider *provider2 = data2;
+
+	/* The "none" provider comes first. */
+	if (g_strcmp0 (provider1->protocol, "none") == 0)
+		return -1;
+	if (g_strcmp0 (provider2->protocol, "none") == 0)
+		return 1;
+
+	/* Then sort remote providers before local providers. */
+	if (provider1->flags & CAMEL_PROVIDER_IS_REMOTE) {
+		if (provider2->flags & CAMEL_PROVIDER_IS_REMOTE)
+			return 0;
+		else
+			return -1;
+	} else {
+		if (provider2->flags & CAMEL_PROVIDER_IS_REMOTE)
+			return 1;
+		else
+			return 0;
+	}
+}
+
+static GList *
+mail_config_assistant_list_providers (void)
+{
+	GList *list, *link;
+	GQueue trash = G_QUEUE_INIT;
+
+	list = camel_provider_list (TRUE);
+	list = g_list_sort (list, mail_config_assistant_provider_compare);
+
+	/* Keep only providers with a "mail" or "news" domain. */
+
+	for (link = list; link != NULL; link = g_list_next (link)) {
+		CamelProvider *provider = link->data;
+		gboolean mail_or_news_domain;
+
+		mail_or_news_domain =
+			(g_strcmp0 (provider->domain, "mail") == 0) ||
+			(g_strcmp0 (provider->domain, "news") == 0);
+
+		if (mail_or_news_domain)
+			continue;
+
+		g_queue_push_tail (&trash, link);
+	}
+
+	while ((link = g_queue_pop_head (&trash)) != NULL)
+		list = g_list_remove_link (list, link);
+
+	return list;
+}
+
+static void
+mail_config_assistant_notify_account_source (EMailConfigAssistant *assistant)
+{
+	g_object_notify (G_OBJECT (assistant), "account-source");
+}
+
+static void
+mail_config_assistant_notify_transport_source (EMailConfigAssistant *assistant)
+{
+	g_object_notify (G_OBJECT (assistant), "transport-source");
+}
+
+static void
+mail_config_assistant_page_changed (EMailConfigPage *page,
+                                    EMailConfigAssistant *assistant)
+{
+	gtk_assistant_set_page_complete (
+		GTK_ASSISTANT (assistant), GTK_WIDGET (page),
+		e_mail_config_page_check_complete (page));
+}
+
+static gboolean
+mail_config_assistant_provider_page_visible (GBinding *binding,
+                                             const GValue *source_value,
+                                             GValue *target_value,
+                                             gpointer unused)
+{
+	EMailConfigProviderPage *page;
+	GObject *target_object;
+	ESource *active_source;
+	ESource *scratch_source;
+	gboolean visible;
+
+	target_object = g_binding_get_target (binding);
+	page = E_MAIL_CONFIG_PROVIDER_PAGE (target_object);
+	scratch_source = e_mail_config_provider_page_get_scratch_source (page);
+
+	active_source = g_value_get_object (source_value);
+	visible = e_source_equal (active_source, scratch_source);
+	g_value_set_boolean (target_value, visible);
+
+	return TRUE;
+}
+
+static gboolean
+mail_config_assistant_sending_page_visible (GBinding *binding,
+                                            const GValue *source_value,
+                                            GValue *target_value,
+                                            gpointer unused)
+{
+	EMailConfigServicePage *page;
+	CamelProvider *provider;
+	GObject *source_object;
+	ESource *source;
+	gboolean visible;
+
+	source_object = g_binding_get_source (binding);
+	page = E_MAIL_CONFIG_SERVICE_PAGE (source_object);
+
+	source = g_value_get_object (source_value);
+	provider = e_mail_config_service_page_get_provider (page, source);
+	g_return_val_if_fail (provider != NULL, FALSE);
+
+	visible = !CAMEL_PROVIDER_IS_STORE_AND_TRANSPORT (provider);
+	g_value_set_boolean (target_value, visible);
+
+	return TRUE;
+}
+
+static void
+mail_config_assistant_set_session (EMailConfigAssistant *assistant,
+                                   EMailSession *session)
+{
+	g_return_if_fail (E_IS_MAIL_SESSION (session));
+	g_return_if_fail (assistant->priv->session == NULL);
+
+	assistant->priv->session = g_object_ref (session);
+}
+
+static void
+mail_config_assistant_set_property (GObject *object,
+                                    guint property_id,
+                                    const GValue *value,
+                                    GParamSpec *pspec)
+{
+	switch (property_id) {
+		case PROP_SESSION:
+			mail_config_assistant_set_session (
+				E_MAIL_CONFIG_ASSISTANT (object),
+				g_value_get_object (value));
+			return;
+	}
+
+	G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+}
+
+static void
+mail_config_assistant_get_property (GObject *object,
+                                    guint property_id,
+                                    GValue *value,
+                                    GParamSpec *pspec)
+{
+	switch (property_id) {
+		case PROP_ACCOUNT_SOURCE:
+			g_value_set_object (
+				value,
+				e_mail_config_assistant_get_account_source (
+				E_MAIL_CONFIG_ASSISTANT (object)));
+			return;
+
+		case PROP_IDENTITY_SOURCE:
+			g_value_set_object (
+				value,
+				e_mail_config_assistant_get_identity_source (
+				E_MAIL_CONFIG_ASSISTANT (object)));
+			return;
+
+		case PROP_SESSION:
+			g_value_set_object (
+				value,
+				e_mail_config_assistant_get_session (
+				E_MAIL_CONFIG_ASSISTANT (object)));
+			return;
+
+		case PROP_TRANSPORT_SOURCE:
+			g_value_set_object (
+				value,
+				e_mail_config_assistant_get_transport_source (
+				E_MAIL_CONFIG_ASSISTANT (object)));
+			return;
+	}
+
+	G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+}
+
+static void
+mail_config_assistant_dispose (GObject *object)
+{
+	EMailConfigAssistantPrivate *priv;
+
+	priv = E_MAIL_CONFIG_ASSISTANT_GET_PRIVATE (object);
+
+	if (priv->session != NULL) {
+		g_object_unref (priv->session);
+		priv->session = NULL;
+	}
+
+	if (priv->identity_source != NULL) {
+		g_object_unref (priv->identity_source);
+		priv->identity_source = NULL;
+	}
+
+	if (priv->receiving_page != NULL) {
+		g_object_unref (priv->receiving_page);
+		priv->receiving_page = NULL;
+	}
+
+	if (priv->sending_page != NULL) {
+		g_object_unref (priv->sending_page);
+		priv->sending_page = NULL;
+	}
+
+	if (priv->summary_page != NULL) {
+		g_object_unref (priv->summary_page);
+		priv->summary_page = NULL;
+	}
+
+	g_ptr_array_set_size (priv->account_sources, 0);
+	g_ptr_array_set_size (priv->transport_sources, 0);
+
+	/* Chain up to parent's dispose() method. */
+	G_OBJECT_CLASS (e_mail_config_assistant_parent_class)->
+		dispose (object);
+}
+
+static void
+mail_config_assistant_finalize (GObject *object)
+{
+	EMailConfigAssistantPrivate *priv;
+
+	priv = E_MAIL_CONFIG_ASSISTANT_GET_PRIVATE (object);
+
+	g_ptr_array_free (priv->account_sources, TRUE);
+	g_ptr_array_free (priv->transport_sources, TRUE);
+
+	/* Chain up to parent's finalize() method. */
+	G_OBJECT_CLASS (e_mail_config_assistant_parent_class)->
+		finalize (object);
+}
+
+static void
+mail_config_assistant_constructed (GObject *object)
+{
+	EMailConfigAssistant *assistant;
+	ESource *default_source;
+	ESource *identity_source;
+	ESourceRegistry *registry;
+	ESourceExtension *extension;
+	ESourceMailComposition *mail_composition_extension;
+	ESourceMailSubmission *mail_submission_extension;
+	EMailSession *session;
+	EMailConfigPage *page;
+	GList *list, *link;
+	const gchar *extension_name;
+	const gchar *title;
+
+	assistant = E_MAIL_CONFIG_ASSISTANT (object);
+
+	/* Chain up to parent's constructed() method. */
+	G_OBJECT_CLASS (e_mail_config_assistant_parent_class)->
+		constructed (object);
+
+	title = _("Evolution Account Assistant");
+	gtk_window_set_title (GTK_WINDOW (assistant), title);
+	gtk_window_set_position (GTK_WINDOW (assistant), GTK_WIN_POS_CENTER);
+
+	session = e_mail_config_assistant_get_session (assistant);
+	registry = e_mail_session_get_registry (session);
+
+	/* Configure a new identity source. */
+
+	identity_source = e_source_new (NULL, NULL);
+	assistant->priv->identity_source = identity_source;
+	session = e_mail_config_assistant_get_session (assistant);
+
+	extension_name = E_SOURCE_EXTENSION_MAIL_COMPOSITION;
+	extension = e_source_get_extension (identity_source, extension_name);
+	mail_composition_extension = E_SOURCE_MAIL_COMPOSITION (extension);
+
+	extension_name = E_SOURCE_EXTENSION_MAIL_SUBMISSION;
+	extension = e_source_get_extension (identity_source, extension_name);
+	mail_submission_extension = E_SOURCE_MAIL_SUBMISSION (extension);
+
+	e_source_mail_composition_set_drafts_folder (
+		mail_composition_extension,
+		e_mail_session_get_local_folder_uri (
+		session, E_MAIL_LOCAL_FOLDER_DRAFTS));
+
+	e_source_mail_composition_set_templates_folder (
+		mail_composition_extension,
+		e_mail_session_get_local_folder_uri (
+		session, E_MAIL_LOCAL_FOLDER_TEMPLATES));
+
+	e_source_mail_submission_set_sent_folder (
+		mail_submission_extension,
+		e_mail_session_get_local_folder_uri (
+		session, E_MAIL_LOCAL_FOLDER_SENT));
+
+	/*** Welcome Page ***/
+
+	page = e_mail_config_welcome_page_new ();
+	e_mail_config_assistant_add_page (assistant, page);
+
+	/*** Identity Page ***/
+
+	page = e_mail_config_identity_page_new (registry, identity_source);
+	e_mail_config_identity_page_set_show_account_info (
+		E_MAIL_CONFIG_IDENTITY_PAGE (page), FALSE);
+	e_mail_config_identity_page_set_show_signatures (
+		E_MAIL_CONFIG_IDENTITY_PAGE (page), FALSE);
+	e_mail_config_assistant_add_page (assistant, page);
+
+	/*** Receiving Page ***/
+
+	page = e_mail_config_receiving_page_new (registry);
+	e_mail_config_assistant_add_page (assistant, page);
+	assistant->priv->receiving_page = g_object_ref (page);
+
+	g_signal_connect_swapped (
+		page, "notify::active-source",
+		G_CALLBACK (mail_config_assistant_notify_account_source),
+		assistant);
+
+	/*** Receiving Options (multiple) ***/
+
+	/* Populate the Receiving Email page while at the same time
+	 * adding a Receiving Options page for each account type. */
+
+	default_source = NULL;
+
+	list = mail_config_assistant_list_providers ();
+
+	for (link = list; link != NULL; link = g_list_next (link)) {
+		CamelProvider *provider = link->data;
+		ESourceBackend *backend_extension;
+		ESource *scratch_source;
+		const gchar *backend_name;
+
+		if (provider->object_types[CAMEL_PROVIDER_STORE] == 0)
+			continue;
+
+		/* ESource uses "backend_name" and CamelProvider
+		 * uses "protocol", but the terms are synonymous. */
+		backend_name = provider->protocol;
+
+		scratch_source = e_source_new (NULL, NULL);
+		backend_extension = e_source_get_extension (
+			scratch_source, E_SOURCE_EXTENSION_MAIL_ACCOUNT);
+		e_source_backend_set_backend_name (
+			backend_extension, backend_name);
+
+		e_mail_config_service_page_add_scratch_source (
+			assistant->priv->receiving_page, scratch_source);
+
+		page = e_mail_config_provider_page_new (scratch_source);
+
+		if (g_strcmp0 (backend_name, DEFAULT_RECVING_BACKEND) == 0)
+			default_source = g_object_ref (scratch_source);
+
+		g_object_unref (scratch_source);
+
+		/* Note: We exclude this page if it has no options,
+		 *       but we don't know that until we create it. */
+		if (e_mail_config_provider_page_is_empty (
+				E_MAIL_CONFIG_PROVIDER_PAGE (page))) {
+			g_object_unref (g_object_ref_sink (page));
+			continue;
+		} else {
+			e_mail_config_assistant_add_page (assistant, page);
+		}
+
+		/* Each Receiving Options page is only visible when its
+		 * scratch source is active on the Receiving Email page. */
+		g_object_bind_property_full (
+			assistant->priv->receiving_page, "active-source",
+			page, "visible",
+			G_BINDING_SYNC_CREATE,
+			mail_config_assistant_provider_page_visible,
+			NULL,
+			NULL, (GDestroyNotify) NULL);
+	}
+
+	g_list_free (list);
+
+	if (default_source != NULL) {
+		e_mail_config_service_page_set_active_source (
+			assistant->priv->receiving_page, default_source);
+		g_object_unref (default_source);
+	}
+
+	/*** Sending Page ***/
+
+	page = e_mail_config_sending_page_new (registry);
+	e_mail_config_assistant_add_page (assistant, page);
+	assistant->priv->sending_page = g_object_ref (page);
+
+	g_signal_connect_swapped (
+		page, "notify::active-source",
+		G_CALLBACK (mail_config_assistant_notify_transport_source),
+		assistant);
+
+	/* This page is invisible when the active account type is both a
+	 * storage and transport service.  This is common with groupware
+	 * products like Microsoft Exchange and Novell GroupWise. */
+	g_object_bind_property_full (
+		assistant->priv->receiving_page, "active-source",
+		page, "visible",
+		G_BINDING_SYNC_CREATE,
+		mail_config_assistant_sending_page_visible,
+		NULL,
+		NULL, (GDestroyNotify) NULL);
+
+	default_source = NULL;
+
+	list = mail_config_assistant_list_providers ();
+
+	for (link = list; link != NULL; link = g_list_next (link)) {
+		CamelProvider *provider = link->data;
+		ESourceBackend *backend_extension;
+		ESource *scratch_source;
+		const gchar *backend_name;
+
+		if (provider->object_types[CAMEL_PROVIDER_TRANSPORT] == 0)
+			continue;
+
+		if (CAMEL_PROVIDER_IS_STORE_AND_TRANSPORT (provider))
+			continue;
+
+		/* ESource uses "backend_name" and CamelProvider
+		 * uses "protocol", but the terms are synonymous. */
+		backend_name = provider->protocol;
+
+		scratch_source = e_source_new (NULL, NULL);
+		backend_extension = e_source_get_extension (
+			scratch_source, E_SOURCE_EXTENSION_MAIL_TRANSPORT);
+		e_source_backend_set_backend_name (
+			backend_extension, backend_name);
+
+		e_mail_config_service_page_add_scratch_source (
+			assistant->priv->sending_page, scratch_source);
+
+		if (g_strcmp0 (backend_name, DEFAULT_SENDING_BACKEND) == 0)
+			default_source = g_object_ref (scratch_source);
+
+		g_object_unref (scratch_source);
+	}
+
+	g_list_free (list);
+
+	if (default_source != NULL) {
+		e_mail_config_service_page_set_active_source (
+			assistant->priv->sending_page, default_source);
+		g_object_unref (default_source);
+	}
+
+	/*** Summary Page ***/
+
+	page = e_mail_config_summary_page_new ();
+	e_mail_config_assistant_add_page (assistant, page);
+	assistant->priv->summary_page = g_object_ref (page);
+
+	g_object_bind_property (
+		assistant, "account-source",
+		page, "account-source",
+		G_BINDING_SYNC_CREATE);
+
+	g_object_bind_property (
+		assistant, "identity-source",
+		page, "identity-source",
+		G_BINDING_SYNC_CREATE);
+
+	g_object_bind_property (
+		assistant, "transport-source",
+		page, "transport-source",
+		G_BINDING_SYNC_CREATE);
+
+	/*** Confirm Page ***/
+
+	page = e_mail_config_confirm_page_new ();
+	e_mail_config_assistant_add_page (assistant, page);
+
+	e_extensible_load_extensions (E_EXTENSIBLE (assistant));
+}
+
+static void
+mail_config_assistant_remove (GtkContainer *container,
+                              GtkWidget *widget)
+{
+	if (E_IS_MAIL_CONFIG_PAGE (widget))
+		g_signal_handlers_disconnect_by_func (
+			widget, mail_config_assistant_page_changed,
+			E_MAIL_CONFIG_ASSISTANT (container));
+
+	/* Chain up to parent's remove() method. */
+	GTK_CONTAINER_CLASS (e_mail_config_assistant_parent_class)->
+		remove (container, widget);
+}
+
+static void
+mail_config_assistant_close (GtkAssistant *assistant)
+{
+	/* Do not chain up.  GtkAssistant does not implement this method. */
+
+	gtk_widget_destroy (GTK_WIDGET (assistant));
+}
+
+static void
+mail_config_assistant_cancel (GtkAssistant *assistant)
+{
+	/* Do not chain up.  GtkAssistant does not implement this method. */
+
+	gtk_widget_destroy (GTK_WIDGET (assistant));
+}
+
+static void
+e_mail_config_assistant_class_init (EMailConfigAssistantClass *class)
+{
+	GObjectClass *object_class;
+	GtkContainerClass *container_class;
+	GtkAssistantClass *assistant_class;
+
+	g_type_class_add_private (class, sizeof (EMailConfigAssistantPrivate));
+
+	object_class = G_OBJECT_CLASS (class);
+	object_class->set_property = mail_config_assistant_set_property;
+	object_class->get_property = mail_config_assistant_get_property;
+	object_class->dispose = mail_config_assistant_dispose;
+	object_class->finalize = mail_config_assistant_finalize;
+	object_class->constructed = mail_config_assistant_constructed;
+
+	container_class = GTK_CONTAINER_CLASS (class);
+	container_class->remove = mail_config_assistant_remove;
+
+	assistant_class = GTK_ASSISTANT_CLASS (class);
+	assistant_class->close = mail_config_assistant_close;
+	assistant_class->cancel = mail_config_assistant_cancel;
+
+	g_object_class_install_property (
+		object_class,
+		PROP_ACCOUNT_SOURCE,
+		g_param_spec_object (
+			"account-source",
+			"Account Source",
+			"Mail account source being edited",
+			E_TYPE_SOURCE,
+			G_PARAM_READABLE |
+			G_PARAM_STATIC_STRINGS));
+
+	g_object_class_install_property (
+		object_class,
+		PROP_IDENTITY_SOURCE,
+		g_param_spec_object (
+			"identity-source",
+			"Identity Source",
+			"Mail identity source being edited",
+			E_TYPE_SOURCE,
+			G_PARAM_READABLE |
+			G_PARAM_STATIC_STRINGS));
+
+	g_object_class_install_property (
+		object_class,
+		PROP_SESSION,
+		g_param_spec_object (
+			"session",
+			"Session",
+			"Mail session",
+			E_TYPE_MAIL_SESSION,
+			G_PARAM_READWRITE |
+			G_PARAM_CONSTRUCT_ONLY |
+			G_PARAM_STATIC_STRINGS));
+
+	g_object_class_install_property (
+		object_class,
+		PROP_TRANSPORT_SOURCE,
+		g_param_spec_object (
+			"transport-source",
+			"Transport Source",
+			"Mail transport source being edited",
+			E_TYPE_SOURCE,
+			G_PARAM_READABLE |
+			G_PARAM_STATIC_STRINGS));
+}
+
+static void
+e_mail_config_assistant_init (EMailConfigAssistant *assistant)
+{
+	assistant->priv = E_MAIL_CONFIG_ASSISTANT_GET_PRIVATE (assistant);
+
+	assistant->priv->account_sources =
+		g_ptr_array_new_with_free_func (
+		(GDestroyNotify) g_object_unref);
+
+	assistant->priv->transport_sources =
+		g_ptr_array_new_with_free_func (
+		(GDestroyNotify) g_object_unref);
+}
+
+GtkWidget *
+e_mail_config_assistant_new (EMailSession *session)
+{
+	g_return_val_if_fail (E_IS_MAIL_SESSION (session), NULL);
+
+	return g_object_new (
+		E_TYPE_MAIL_CONFIG_ASSISTANT,
+		"session", session, NULL);
+}
+
+EMailSession *
+e_mail_config_assistant_get_session (EMailConfigAssistant *assistant)
+{
+	g_return_val_if_fail (E_IS_MAIL_CONFIG_ASSISTANT (assistant), NULL);
+
+	return assistant->priv->session;
+}
+
+ESource *
+e_mail_config_assistant_get_account_source (EMailConfigAssistant *assistant)
+{
+	EMailConfigServicePage *page;
+
+	g_return_val_if_fail (E_IS_MAIL_CONFIG_ASSISTANT (assistant), NULL);
+
+	page = assistant->priv->receiving_page;
+
+	if (!gtk_widget_get_visible (GTK_WIDGET (page)))
+		return NULL;
+
+	return e_mail_config_service_page_get_active_source (page);
+}
+
+ESource *
+e_mail_config_assistant_get_identity_source (EMailConfigAssistant *assistant)
+{
+	g_return_val_if_fail (E_IS_MAIL_CONFIG_ASSISTANT (assistant), NULL);
+
+	return assistant->priv->identity_source;
+}
+
+ESource *
+e_mail_config_assistant_get_transport_source (EMailConfigAssistant *assistant)
+{
+	EMailConfigServicePage *page;
+
+	g_return_val_if_fail (E_IS_MAIL_CONFIG_ASSISTANT (assistant), NULL);
+
+	page = assistant->priv->sending_page;
+
+	if (!gtk_widget_get_visible (GTK_WIDGET (page)))
+		return NULL;
+
+	return e_mail_config_service_page_get_active_source (page);
+}
+
+void
+e_mail_config_assistant_add_page (EMailConfigAssistant *assistant,
+                                  EMailConfigPage *page)
+{
+	EMailConfigPageInterface *page_interface;
+	GtkAssistantPageType page_type;
+	GtkWidget *page_widget;
+	gint n_pages, position;
+	const gchar *page_title;
+	gboolean complete;
+
+	g_return_if_fail (E_IS_MAIL_CONFIG_ASSISTANT (assistant));
+	g_return_if_fail (E_IS_MAIL_CONFIG_PAGE (page));
+
+	page_widget = GTK_WIDGET (page);
+	page_interface = E_MAIL_CONFIG_PAGE_GET_INTERFACE (page);
+	page_type = page_interface->page_type;
+	page_title = page_interface->title;
+
+	/* Determine the position to insert the page. */
+	n_pages = gtk_assistant_get_n_pages (GTK_ASSISTANT (assistant));
+	for (position = 0; position < n_pages; position++) {
+		GtkWidget *nth_page;
+
+		nth_page = gtk_assistant_get_nth_page (
+			GTK_ASSISTANT (assistant), position);
+		if (e_mail_config_page_compare (page_widget, nth_page) < 0)
+			break;
+	}
+
+	gtk_widget_show (page_widget);
+
+	/* Some pages can be clicked through unchanged. */
+	complete = e_mail_config_page_check_complete (page);
+
+	gtk_assistant_insert_page (
+		GTK_ASSISTANT (assistant), page_widget, position);
+	gtk_assistant_set_page_type (
+		GTK_ASSISTANT (assistant), page_widget, page_type);
+	gtk_assistant_set_page_title (
+		GTK_ASSISTANT (assistant), page_widget, page_title);
+	gtk_assistant_set_page_complete (
+		GTK_ASSISTANT (assistant), page_widget, complete);
+
+	/* XXX GtkAssistant has no equivalent to GtkNotebook's
+	 *     "page-added" and "page-removed" signals.  Fortunately
+	 *     removing a page does trigger GtkContainer::remove, so
+	 *     we can override that method and disconnect our signal
+	 *     handler before chaining up.  But I don't see any way
+	 *     for a subclass to intercept GtkAssistant pages being
+	 *     added, so we have to connect our signal handler here.
+	 *     Not really an issue, I'm just being pedantic. */
+
+	g_signal_connect (
+		page, "changed",
+		G_CALLBACK (mail_config_assistant_page_changed),
+		assistant);
+}
+
diff --git a/mail/e-mail-config-assistant.h b/mail/e-mail-config-assistant.h
new file mode 100644
index 0000000..b9f0534
--- /dev/null
+++ b/mail/e-mail-config-assistant.h
@@ -0,0 +1,80 @@
+/*
+ * e-mail-config-assistant.h
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) version 3.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with the program; if not, see <http://www.gnu.org/licenses/>
+ *
+ */
+
+#ifndef E_MAIL_CONFIG_ASSISTANT_H
+#define E_MAIL_CONFIG_ASSISTANT_H
+
+#include <gtk/gtk.h>
+
+#include <mail/e-mail-config-page.h>
+#include <libemail-engine/e-mail-session.h>
+
+/* Standard GObject macros */
+#define E_TYPE_MAIL_CONFIG_ASSISTANT \
+	(e_mail_config_assistant_get_type ())
+#define E_MAIL_CONFIG_ASSISTANT(obj) \
+	(G_TYPE_CHECK_INSTANCE_CAST \
+	((obj), E_TYPE_MAIL_CONFIG_ASSISTANT, EMailConfigAssistant))
+#define E_MAIL_CONFIG_ASSISTANT_CLASS(cls) \
+	(G_TYPE_CHECK_CLASS_CAST \
+	((cls), E_TYPE_MAIL_CONFIG_ASSISTANT, EMailConfigAssistantClass))
+#define E_IS_MAIL_CONFIG_ASSISTANT(obj) \
+	(G_TYPE_CHECK_INSTANCE_TYPE \
+	((obj), E_TYPE_MAIL_CONFIG_ASSISTANT))
+#define E_IS_MAIL_CONFIG_ASSISTANT_CLASS(cls) \
+	(G_TYPE_CHECK_CLASS_TYPE \
+	((cls), E_TYPE_MAIL_CONFIG_ASSISTANT))
+#define E_MAIL_CONFIG_ASSISTANT_GET_CLASS(obj) \
+	(G_TYPE_INSTANCE_GET_CLASS \
+	((obj), E_TYPE_MAIL_CONFIG_ASSISTANT, EMailConfigAssistantClass))
+
+G_BEGIN_DECLS
+
+typedef struct _EMailConfigAssistant EMailConfigAssistant;
+typedef struct _EMailConfigAssistantClass EMailConfigAssistantClass;
+typedef struct _EMailConfigAssistantPrivate EMailConfigAssistantPrivate;
+
+struct _EMailConfigAssistant {
+	GtkAssistant parent;
+	EMailConfigAssistantPrivate *priv;
+};
+
+struct _EMailConfigAssistantClass {
+	GtkAssistantClass parent_class;
+};
+
+GType		e_mail_config_assistant_get_type
+					(void) G_GNUC_CONST;
+GtkWidget *	e_mail_config_assistant_new
+					(EMailSession *session);
+EMailSession *	e_mail_config_assistant_get_session
+					(EMailConfigAssistant *assistant);
+ESource *	e_mail_config_assistant_get_account_source
+					(EMailConfigAssistant *assistant);
+ESource *	e_mail_config_assistant_get_identity_source
+					(EMailConfigAssistant *assistant);
+ESource *	e_mail_config_assistant_get_transport_source
+					(EMailConfigAssistant *assistant);
+void		e_mail_config_assistant_add_page
+					(EMailConfigAssistant *assistant,
+					 EMailConfigPage *page);
+
+G_END_DECLS
+
+#endif /* E_MAIL_CONFIG_ASSISTANT_H */
+
diff --git a/mail/e-mail-config-auth-check.c b/mail/e-mail-config-auth-check.c
new file mode 100644
index 0000000..b573290
--- /dev/null
+++ b/mail/e-mail-config-auth-check.c
@@ -0,0 +1,505 @@
+/*
+ * e-mail-config-auth-check.c
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) version 3.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with the program; if not, see <http://www.gnu.org/licenses/>
+ *
+ */
+
+#include "e-mail-config-auth-check.h"
+
+#include <config.h>
+#include <glib/gi18n-lib.h>
+
+#include <libevolution-utils/e-alert.h>
+#include <e-util/e-mktemp.h>
+#include <misc/e-auth-combo-box.h>
+
+#define E_MAIL_CONFIG_AUTH_CHECK_GET_PRIVATE(obj) \
+	(G_TYPE_INSTANCE_GET_PRIVATE \
+	((obj), E_TYPE_MAIL_CONFIG_AUTH_CHECK, EMailConfigAuthCheckPrivate))
+
+typedef struct _AsyncContext AsyncContext;
+
+struct _EMailConfigAuthCheckPrivate {
+	EMailConfigServiceBackend *backend;
+	ESource *scratch_source;
+	gchar *active_mechanism;
+
+	GtkWidget *combo_box;  /* not referenced */
+};
+
+struct _AsyncContext {
+	EMailConfigAuthCheck *auth_check;
+	CamelSession *temporary_session;
+	EActivity *activity;
+};
+
+enum {
+	PROP_0,
+	PROP_ACTIVE_MECHANISM,
+	PROP_BACKEND,
+	PROP_SCRATCH_SOURCE
+};
+
+G_DEFINE_TYPE (
+	EMailConfigAuthCheck,
+	e_mail_config_auth_check,
+	GTK_TYPE_BOX)
+
+static void
+async_context_free (AsyncContext *async_context)
+{
+	if (async_context->auth_check != NULL)
+		g_object_unref (async_context->auth_check);
+
+	if (async_context->temporary_session != NULL)
+		g_object_unref (async_context->temporary_session);
+
+	if (async_context->activity != NULL)
+		g_object_unref (async_context->activity);
+
+	g_slice_free (AsyncContext, async_context);
+}
+
+static void
+mail_config_auth_check_update_done_cb (GObject *source_object,
+                                       GAsyncResult *result,
+                                       gpointer user_data)
+{
+	AsyncContext *async_context = user_data;
+	EMailConfigAuthCheck *auth_check;
+	EAlertSink *alert_sink;
+	GList *available_authtypes;
+	GError *error = NULL;
+
+	auth_check = async_context->auth_check;
+	alert_sink = e_activity_get_alert_sink (async_context->activity);
+
+	available_authtypes = camel_service_query_auth_types_finish (
+		CAMEL_SERVICE (source_object), result, &error);
+
+	if (e_activity_handle_cancellation (async_context->activity, error)) {
+		g_warn_if_fail (available_authtypes == NULL);
+		g_error_free (error);
+
+	} else if (error != NULL) {
+		g_warn_if_fail (available_authtypes == NULL);
+		e_alert_submit (
+			alert_sink,
+			"mail:checking-service-error",
+			error->message, NULL);
+		g_error_free (error);
+
+	} else {
+		e_auth_combo_box_update_available (
+			E_AUTH_COMBO_BOX (auth_check->priv->combo_box),
+			available_authtypes);
+		g_list_free (available_authtypes);
+	}
+
+	gtk_widget_set_sensitive (GTK_WIDGET (auth_check), TRUE);
+
+	async_context_free (async_context);
+}
+
+static void
+mail_config_auth_check_update (EMailConfigAuthCheck *auth_check)
+{
+	EActivity *activity;
+	EMailConfigServicePage *page;
+	EMailConfigServiceBackend *backend;
+	EMailConfigServicePageClass *page_class;
+	EMailConfigServiceBackendClass *backend_class;
+	ESource *source;
+	CamelService *service;
+	CamelSession *session;
+	CamelSettings *settings;
+	GCancellable *cancellable;
+	AsyncContext *async_context;
+	gchar *temp_dir;
+	GError *error = NULL;
+
+	backend = e_mail_config_auth_check_get_backend (auth_check);
+	source = e_mail_config_auth_check_get_scratch_source (auth_check);
+	page = e_mail_config_service_backend_get_page (backend);
+	settings = e_mail_config_service_page_get_settings (page, source);
+
+	page_class = E_MAIL_CONFIG_SERVICE_PAGE_GET_CLASS (page);
+	backend_class = E_MAIL_CONFIG_SERVICE_BACKEND_GET_CLASS (backend);
+
+	temp_dir = e_mkdtemp ("evolution-auth-check-XXXXXX");
+
+	/* Create a temporary session for our temporary service.
+	 * Use the same temporary directory for "user-data-dir" and
+	 * "user-cache-dir".  For our purposes it shouldn't matter. */
+	session = g_object_new (
+		CAMEL_TYPE_SESSION,
+		"user-data-dir", temp_dir,
+		"user-cache-dir", temp_dir,
+		NULL);
+
+	/* This returns a BORROWED reference to the CamelService. */
+	service = camel_session_add_service (
+		session, "fake-uid",
+		backend_class->backend_name,
+		page_class->provider_type, &error);
+
+	g_free (temp_dir);
+
+	if (error != NULL) {
+		g_warn_if_fail (service == NULL);
+		e_alert_submit (
+			E_ALERT_SINK (page),
+			"mail:checking-service-error",
+			error->message, NULL);
+		g_error_free (error);
+		return;
+	}
+
+	g_return_if_fail (CAMEL_IS_SERVICE (service));
+
+	camel_service_set_settings (service, settings);
+
+	activity = e_mail_config_service_page_new_activity (page);
+	cancellable = e_activity_get_cancellable (activity);
+
+	gtk_widget_set_sensitive (GTK_WIDGET (auth_check), FALSE);
+
+	async_context = g_slice_new (AsyncContext);
+	async_context->auth_check = g_object_ref (auth_check);
+	async_context->temporary_session = session;  /* takes ownership */
+	async_context->activity = activity;          /* takes ownership */
+
+	camel_service_query_auth_types (
+		service, G_PRIORITY_DEFAULT, cancellable,
+		mail_config_auth_check_update_done_cb, async_context);
+}
+
+static void
+mail_config_auth_check_clicked_cb (GtkButton *button,
+                                   EMailConfigAuthCheck *auth_check)
+{
+	mail_config_auth_check_update (auth_check);
+}
+
+static void
+mail_config_auth_check_init_mechanism (EMailConfigAuthCheck *auth_check)
+{
+	ESource *source;
+	EMailConfigServicePage *page;
+	EMailConfigServiceBackend *backend;
+	CamelProvider *provider;
+	CamelSettings *settings;
+	const gchar *auth_mechanism = NULL;
+
+	/* Pick an initial active mechanism name by examining both
+	 * the corresponding CamelNetworkSettings and CamelProvider. */
+
+	backend = e_mail_config_auth_check_get_backend (auth_check);
+	source = e_mail_config_auth_check_get_scratch_source (auth_check);
+
+	page = e_mail_config_service_backend_get_page (backend);
+	provider = e_mail_config_service_backend_get_provider (backend);
+
+	settings = e_mail_config_service_page_get_settings (page, source);
+	g_return_if_fail (CAMEL_IS_NETWORK_SETTINGS (settings));
+
+	auth_mechanism =
+		camel_network_settings_get_auth_mechanism (
+		CAMEL_NETWORK_SETTINGS (settings));
+
+	/* If CamelNetworkSettings does not have a mechanism name set,
+	 * choose from the CamelProvider's list of supported mechanisms. */
+	if (auth_mechanism == NULL && provider != NULL) {
+		if (provider->authtypes != NULL) {
+			CamelServiceAuthType *auth_type;
+			auth_type = provider->authtypes->data;
+			auth_mechanism = auth_type->authproto;
+		}
+	}
+
+	if (auth_mechanism != NULL)
+		e_mail_config_auth_check_set_active_mechanism (
+			auth_check, auth_mechanism);
+}
+
+static void
+mail_config_auth_check_set_backend (EMailConfigAuthCheck *auth_check,
+                                    EMailConfigServiceBackend *backend)
+{
+	g_return_if_fail (E_IS_MAIL_CONFIG_SERVICE_BACKEND (backend));
+	g_return_if_fail (auth_check->priv->backend == NULL);
+
+	auth_check->priv->backend = g_object_ref (backend);
+}
+
+static void
+mail_config_auth_check_set_scratch_source (EMailConfigAuthCheck *auth_check,
+                                           ESource *scratch_source)
+{
+	g_return_if_fail (E_IS_SOURCE (scratch_source));
+	g_return_if_fail (auth_check->priv->scratch_source == NULL);
+
+	auth_check->priv->scratch_source = g_object_ref (scratch_source);
+}
+
+static void
+mail_config_auth_check_set_property (GObject *object,
+                                     guint property_id,
+                                     const GValue *value,
+                                     GParamSpec *pspec)
+{
+	switch (property_id) {
+		case PROP_ACTIVE_MECHANISM:
+			e_mail_config_auth_check_set_active_mechanism (
+				E_MAIL_CONFIG_AUTH_CHECK (object),
+				g_value_get_string (value));
+			return;
+
+		case PROP_BACKEND:
+			mail_config_auth_check_set_backend (
+				E_MAIL_CONFIG_AUTH_CHECK (object),
+				g_value_get_object (value));
+			return;
+
+		case PROP_SCRATCH_SOURCE:
+			mail_config_auth_check_set_scratch_source (
+				E_MAIL_CONFIG_AUTH_CHECK (object),
+				g_value_get_object (value));
+			return;
+	}
+
+	G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+}
+
+static void
+mail_config_auth_check_get_property (GObject *object,
+                                     guint property_id,
+                                     GValue *value,
+                                     GParamSpec *pspec)
+{
+	switch (property_id) {
+		case PROP_ACTIVE_MECHANISM:
+			g_value_set_string (
+				value,
+				e_mail_config_auth_check_get_active_mechanism (
+				E_MAIL_CONFIG_AUTH_CHECK (object)));
+			return;
+
+		case PROP_BACKEND:
+			g_value_set_object (
+				value,
+				e_mail_config_auth_check_get_backend (
+				E_MAIL_CONFIG_AUTH_CHECK (object)));
+			return;
+
+		case PROP_SCRATCH_SOURCE:
+			g_value_set_object (
+				value,
+				e_mail_config_auth_check_get_scratch_source (
+				E_MAIL_CONFIG_AUTH_CHECK (object)));
+			return;
+	}
+
+	G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+}
+
+static void
+mail_config_auth_check_dispose (GObject *object)
+{
+	EMailConfigAuthCheckPrivate *priv;
+
+	priv = E_MAIL_CONFIG_AUTH_CHECK_GET_PRIVATE (object);
+
+	if (priv->backend != NULL) {
+		g_object_unref (priv->backend);
+		priv->backend = NULL;
+	}
+
+	if (priv->scratch_source != NULL) {
+		g_object_unref (priv->scratch_source);
+		priv->scratch_source = NULL;
+	}
+
+	/* Chain up to parent's dispose() method. */
+	G_OBJECT_CLASS (e_mail_config_auth_check_parent_class)->
+		dispose (object);
+}
+
+static void
+mail_config_auth_check_finalize (GObject *object)
+{
+	EMailConfigAuthCheckPrivate *priv;
+
+	priv = E_MAIL_CONFIG_AUTH_CHECK_GET_PRIVATE (object);
+
+	g_free (priv->active_mechanism);
+
+	/* Chain up to parent's finalize() method. */
+	G_OBJECT_CLASS (e_mail_config_auth_check_parent_class)->
+		finalize (object);
+}
+
+static void
+mail_config_auth_check_constructed (GObject *object)
+{
+	EMailConfigAuthCheck *auth_check;
+	EMailConfigServiceBackend *backend;
+	CamelProvider *provider;
+	GtkWidget *widget;
+	const gchar *text;
+
+	/* Chain up to parent's constructed() method. */
+	G_OBJECT_CLASS (e_mail_config_auth_check_parent_class)->
+		constructed (object);
+
+	auth_check = E_MAIL_CONFIG_AUTH_CHECK (object);
+	backend = e_mail_config_auth_check_get_backend (auth_check);
+	provider = e_mail_config_service_backend_get_provider (backend);
+
+	widget = e_auth_combo_box_new ();
+	e_auth_combo_box_set_provider (E_AUTH_COMBO_BOX (widget), provider);
+	gtk_box_pack_start (GTK_BOX (object), widget, FALSE, FALSE, 0);
+	auth_check->priv->combo_box = widget;  /* do not reference */
+	gtk_widget_show (widget);
+
+	g_object_bind_property (
+		widget, "active-id",
+		auth_check, "active-mechanism",
+		G_BINDING_BIDIRECTIONAL |
+		G_BINDING_SYNC_CREATE);
+
+	text = _("Check for Supported Types");
+	widget = gtk_button_new_with_label (text);
+	gtk_box_pack_start (GTK_BOX (object), widget, FALSE, FALSE, 0);
+	gtk_widget_show (widget);
+
+	g_signal_connect (
+		widget, "clicked",
+		G_CALLBACK (mail_config_auth_check_clicked_cb),
+		auth_check);
+
+	mail_config_auth_check_init_mechanism (auth_check);
+}
+
+static void
+e_mail_config_auth_check_class_init (EMailConfigAuthCheckClass *class)
+{
+	GObjectClass *object_class;
+
+	g_type_class_add_private (class, sizeof (EMailConfigAuthCheckPrivate));
+
+	object_class = G_OBJECT_CLASS (class);
+	object_class->set_property = mail_config_auth_check_set_property;
+	object_class->get_property = mail_config_auth_check_get_property;
+	object_class->dispose = mail_config_auth_check_dispose;
+	object_class->finalize = mail_config_auth_check_finalize;
+	object_class->constructed = mail_config_auth_check_constructed;
+
+	g_object_class_install_property (
+		object_class,
+		PROP_ACTIVE_MECHANISM,
+		g_param_spec_string (
+			"active-mechanism",
+			"Active Mechanism",
+			"Active authentication mechanism",
+			NULL,
+			G_PARAM_READWRITE |
+			G_PARAM_STATIC_STRINGS));
+
+	g_object_class_install_property (
+		object_class,
+		PROP_BACKEND,
+		g_param_spec_object (
+			"backend",
+			"Backend",
+			"Mail configuration backend",
+			E_TYPE_MAIL_CONFIG_SERVICE_BACKEND,
+			G_PARAM_READWRITE |
+			G_PARAM_CONSTRUCT_ONLY |
+			G_PARAM_STATIC_STRINGS));
+
+	g_object_class_install_property (
+		object_class,
+		PROP_SCRATCH_SOURCE,
+		g_param_spec_object (
+			"scratch-source",
+			"Scratch Source",
+			"The ESource being edited",
+			E_TYPE_SOURCE,
+			G_PARAM_READWRITE |
+			G_PARAM_CONSTRUCT_ONLY |
+			G_PARAM_STATIC_STRINGS));
+}
+
+static void
+e_mail_config_auth_check_init (EMailConfigAuthCheck *auth_check)
+{
+	auth_check->priv = E_MAIL_CONFIG_AUTH_CHECK_GET_PRIVATE (auth_check);
+
+	gtk_orientable_set_orientation (
+		GTK_ORIENTABLE (auth_check),
+		GTK_ORIENTATION_HORIZONTAL);
+
+	gtk_box_set_spacing (GTK_BOX (auth_check), 6);
+}
+
+GtkWidget *
+e_mail_config_auth_check_new (EMailConfigServiceBackend *backend,
+                              ESource *scratch_source)
+{
+	g_return_val_if_fail (E_IS_MAIL_CONFIG_SERVICE_BACKEND (backend), NULL);
+	g_return_val_if_fail (E_IS_SOURCE (scratch_source), NULL);
+
+	return g_object_new (
+		E_TYPE_MAIL_CONFIG_AUTH_CHECK,
+		"backend", backend, "scratch-source", scratch_source, NULL);
+}
+
+EMailConfigServiceBackend *
+e_mail_config_auth_check_get_backend (EMailConfigAuthCheck *auth_check)
+{
+	g_return_val_if_fail (E_IS_MAIL_CONFIG_AUTH_CHECK (auth_check), NULL);
+
+	return auth_check->priv->backend;
+}
+
+ESource *
+e_mail_config_auth_check_get_scratch_source (EMailConfigAuthCheck *auth_check)
+{
+	g_return_val_if_fail (E_IS_MAIL_CONFIG_AUTH_CHECK (auth_check), NULL);
+
+	return auth_check->priv->scratch_source;
+}
+
+const gchar *
+e_mail_config_auth_check_get_active_mechanism (EMailConfigAuthCheck *auth_check)
+{
+	g_return_val_if_fail (E_IS_MAIL_CONFIG_AUTH_CHECK (auth_check), NULL);
+
+	return auth_check->priv->active_mechanism;
+}
+
+void
+e_mail_config_auth_check_set_active_mechanism (EMailConfigAuthCheck *auth_check,
+                                               const gchar *active_mechanism)
+{
+	g_return_if_fail (E_IS_MAIL_CONFIG_AUTH_CHECK (auth_check));
+
+	g_free (auth_check->priv->active_mechanism);
+	auth_check->priv->active_mechanism = g_strdup (active_mechanism);
+
+	g_object_notify (G_OBJECT (auth_check), "active-mechanism");
+}
+
diff --git a/mail/e-mail-config-auth-check.h b/mail/e-mail-config-auth-check.h
new file mode 100644
index 0000000..f413ec7
--- /dev/null
+++ b/mail/e-mail-config-auth-check.h
@@ -0,0 +1,76 @@
+/*
+ * e-mail-config-auth-check.h
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) version 3.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with the program; if not, see <http://www.gnu.org/licenses/>
+ *
+ */
+
+#ifndef E_MAIL_CONFIG_AUTH_CHECK_H
+#define E_MAIL_CONFIG_AUTH_CHECK_H
+
+#include <mail/e-mail-config-service-backend.h>
+
+/* Standard GObject macros */
+#define E_TYPE_MAIL_CONFIG_AUTH_CHECK \
+	(e_mail_config_auth_check_get_type ())
+#define E_MAIL_CONFIG_AUTH_CHECK(obj) \
+	(G_TYPE_CHECK_INSTANCE_CAST \
+	((obj), E_TYPE_MAIL_CONFIG_AUTH_CHECK, EMailConfigAuthCheck))
+#define E_MAIL_CONFIG_AUTH_CHECK_CLASS(cls) \
+	(G_TYPE_CHECK_CLASS_CAST \
+	((cls), E_TYPE_MAIL_CONFIG_AUTH_CHECK, EMailConfigAuthCheckClass))
+#define E_IS_MAIL_CONFIG_AUTH_CHECK(obj) \
+	(G_TYPE_CHECK_INSTANCE_TYPE \
+	((obj), E_TYPE_MAIL_CONFIG_AUTH_CHECK))
+#define E_IS_MAIL_CONFIG_AUTH_CHECK_CLASS(cls) \
+	(G_TYPE_CHECK_CLASS_TYPE \
+	((cls), E_TYPE_MAIL_CONFIG_AUTH_CHECK))
+#define E_MAIL_CONFIG_AUTH_CHECK_GET_CLASS(obj) \
+	(G_TYPE_INSTANCE_GET_CLASS \
+	((obj), E_TYPE_MAIL_CONFIG_AUTH_CHECK, EMailConfigAuthCheckClass))
+
+G_BEGIN_DECLS
+
+typedef struct _EMailConfigAuthCheck EMailConfigAuthCheck;
+typedef struct _EMailConfigAuthCheckClass EMailConfigAuthCheckClass;
+typedef struct _EMailConfigAuthCheckPrivate EMailConfigAuthCheckPrivate;
+
+struct _EMailConfigAuthCheck {
+	GtkBox parent;
+	EMailConfigAuthCheckPrivate *priv;
+};
+
+struct _EMailConfigAuthCheckClass {
+	GtkBoxClass parent_class;
+};
+
+GType		e_mail_config_auth_check_get_type
+					(void) G_GNUC_CONST;
+GtkWidget *	e_mail_config_auth_check_new
+					(EMailConfigServiceBackend *backend,
+					 ESource *scratch_source);
+EMailConfigServiceBackend *
+		e_mail_config_auth_check_get_backend
+					(EMailConfigAuthCheck *auth_check);
+ESource *	e_mail_config_auth_check_get_scratch_source
+					(EMailConfigAuthCheck *auth_check);
+const gchar *	e_mail_config_auth_check_get_active_mechanism
+					(EMailConfigAuthCheck *auth_check);
+void		e_mail_config_auth_check_set_active_mechanism
+					(EMailConfigAuthCheck *auth_check,
+					 const gchar *active_mechanism);
+
+G_END_DECLS
+
+#endif /* E_MAIL_CONFIG_AUTH_CHECK_H */
diff --git a/mail/e-mail-config-confirm-page.c b/mail/e-mail-config-confirm-page.c
new file mode 100644
index 0000000..62de334
--- /dev/null
+++ b/mail/e-mail-config-confirm-page.c
@@ -0,0 +1,199 @@
+/*
+ * e-mail-config-confirm-page.h
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) version 3.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with the program; if not, see <http://www.gnu.org/licenses/>
+ *
+ */
+
+#include "e-mail-config-confirm-page.h"
+
+#include <config.h>
+#include <glib/gi18n-lib.h>
+
+#define E_MAIL_CONFIG_CONFIRM_PAGE_GET_PRIVATE(obj) \
+	(G_TYPE_INSTANCE_GET_PRIVATE \
+	((obj), E_TYPE_MAIL_CONFIG_CONFIRM_PAGE, EMailConfigConfirmPagePrivate))
+
+struct _EMailConfigConfirmPagePrivate {
+	gchar *text;
+};
+
+enum {
+	PROP_0,
+	PROP_TEXT
+};
+
+/* Forward Declarations */
+static void	e_mail_config_confirm_page_interface_init
+					(EMailConfigPageInterface *interface);
+
+G_DEFINE_TYPE_WITH_CODE (
+	EMailConfigConfirmPage,
+	e_mail_config_confirm_page,
+	GTK_TYPE_BOX,
+	G_IMPLEMENT_INTERFACE (
+		E_TYPE_MAIL_CONFIG_PAGE,
+		e_mail_config_confirm_page_interface_init))
+
+static void
+mail_config_confirm_page_set_property (GObject *object,
+                                       guint property_id,
+                                       const GValue *value,
+                                       GParamSpec *pspec)
+{
+	switch (property_id) {
+		case PROP_TEXT:
+			e_mail_config_confirm_page_set_text (
+				E_MAIL_CONFIG_CONFIRM_PAGE (object),
+				g_value_get_string (value));
+			return;
+	}
+
+	G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+}
+
+static void
+mail_config_confirm_page_get_property (GObject *object,
+                                       guint property_id,
+                                       GValue *value,
+                                       GParamSpec *pspec)
+{
+	switch (property_id) {
+		case PROP_TEXT:
+			g_value_set_string (
+				value,
+				e_mail_config_confirm_page_get_text (
+				E_MAIL_CONFIG_CONFIRM_PAGE (object)));
+			return;
+	}
+
+	G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+}
+
+static void
+mail_config_confirm_page_finalize (GObject *object)
+{
+	EMailConfigConfirmPagePrivate *priv;
+
+	priv = E_MAIL_CONFIG_CONFIRM_PAGE_GET_PRIVATE (object);
+
+	g_free (priv->text);
+
+	/* Chain up to parent's finalize() method. */
+	G_OBJECT_CLASS (e_mail_config_confirm_page_parent_class)->
+		finalize (object);
+}
+
+static void
+mail_config_confirm_page_constructed (GObject *object)
+{
+	EMailConfigConfirmPage *page;
+	GtkWidget *widget;
+
+	page = E_MAIL_CONFIG_CONFIRM_PAGE (object);
+
+	/* Chain up to parent's constructed() method. */
+	G_OBJECT_CLASS (e_mail_config_confirm_page_parent_class)->
+		constructed (object);
+
+	gtk_orientable_set_orientation (
+		GTK_ORIENTABLE (page), GTK_ORIENTATION_VERTICAL);
+
+	gtk_box_set_spacing (GTK_BOX (page), 12);
+
+	gtk_widget_set_valign (GTK_WIDGET (page), GTK_ALIGN_CENTER);
+
+	widget = gtk_label_new (NULL);
+	gtk_label_set_line_wrap (GTK_LABEL (widget), TRUE);
+	gtk_misc_set_alignment (GTK_MISC (widget), 0.0, 0.5);
+	gtk_box_pack_start (GTK_BOX (page), widget, FALSE, FALSE, 0);
+	gtk_widget_show (widget);
+
+	g_object_bind_property (
+		page, "text",
+		widget, "label",
+		G_BINDING_BIDIRECTIONAL |
+		G_BINDING_SYNC_CREATE);
+}
+
+static void
+e_mail_config_confirm_page_class_init (EMailConfigConfirmPageClass *class)
+{
+	GObjectClass *object_class;
+
+	g_type_class_add_private (
+		class, sizeof (EMailConfigConfirmPagePrivate));
+
+	object_class = G_OBJECT_CLASS (class);
+	object_class->set_property = mail_config_confirm_page_set_property;
+	object_class->get_property = mail_config_confirm_page_get_property;
+	object_class->finalize = mail_config_confirm_page_finalize;
+	object_class->constructed = mail_config_confirm_page_constructed;
+
+	g_object_class_install_property (
+		object_class,
+		PROP_TEXT,
+		g_param_spec_string (
+			"text",
+			"Text",
+			"Confirmation message",
+			_("Congratulations, your mail configuration is "
+			  "complete.\n\nYou are now ready to send and "
+			  "receive email using Evolution.\n\nClick "
+			  "\"Apply\" to save your settings."),
+			G_PARAM_READWRITE |
+			G_PARAM_CONSTRUCT |
+			G_PARAM_STATIC_STRINGS));
+}
+
+static void
+e_mail_config_confirm_page_interface_init (EMailConfigPageInterface *interface)
+{
+	interface->title = _("Done");
+	interface->page_type = GTK_ASSISTANT_PAGE_CONFIRM;
+	interface->sort_order = E_MAIL_CONFIG_CONFIRM_PAGE_SORT_ORDER;
+}
+
+static void
+e_mail_config_confirm_page_init (EMailConfigConfirmPage *page)
+{
+	page->priv = E_MAIL_CONFIG_CONFIRM_PAGE_GET_PRIVATE (page);
+}
+
+EMailConfigPage *
+e_mail_config_confirm_page_new (void)
+{
+	return g_object_new (E_TYPE_MAIL_CONFIG_CONFIRM_PAGE, NULL);
+}
+
+const gchar *
+e_mail_config_confirm_page_get_text (EMailConfigConfirmPage *page)
+{
+	g_return_val_if_fail (E_IS_MAIL_CONFIG_CONFIRM_PAGE (page), NULL);
+
+	return page->priv->text;
+}
+
+void
+e_mail_config_confirm_page_set_text (EMailConfigConfirmPage *page,
+                                     const gchar *text)
+{
+	g_return_if_fail (E_IS_MAIL_CONFIG_CONFIRM_PAGE (page));
+
+	g_free (page->priv->text);
+	page->priv->text = g_strdup ((text != NULL) ? text : "");
+
+	g_object_notify (G_OBJECT (page), "text");
+}
+
diff --git a/mail/e-mail-config-confirm-page.h b/mail/e-mail-config-confirm-page.h
new file mode 100644
index 0000000..d4bae94
--- /dev/null
+++ b/mail/e-mail-config-confirm-page.h
@@ -0,0 +1,75 @@
+/*
+ * e-mail-config-confirm-page.h
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) version 3.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with the program; if not, see <http://www.gnu.org/licenses/>
+ *
+ */
+
+#ifndef E_MAIL_CONFIG_CONFIRM_PAGE_H
+#define E_MAIL_CONFIG_CONFIRM_PAGE_H
+
+#include <gtk/gtk.h>
+
+#include <mail/e-mail-config-page.h>
+
+/* Standard GObject macros */
+#define E_TYPE_MAIL_CONFIG_CONFIRM_PAGE \
+	(e_mail_config_confirm_page_get_type ())
+#define E_MAIL_CONFIG_CONFIRM_PAGE(obj) \
+	(G_TYPE_CHECK_INSTANCE_CAST \
+	((obj), E_TYPE_MAIL_CONFIG_CONFIRM_PAGE, EMailConfigConfirmPage))
+#define E_MAIL_CONFIG_CONFIRM_PAGE_CLASS(cls) \
+	(G_TYPE_CHECK_CLASS_CAST \
+	((cls), E_TYPE_MAIL_CONFIG_CONFIRM_PAGE, EMailConfigConfirmPageClass))
+#define E_IS_MAIL_CONFIG_CONFIRM_PAGE(obj) \
+	(G_TYPE_CHECK_INSTANCE_TYPE \
+	((obj), E_TYPE_MAIL_CONFIG_CONFIRM_PAGE))
+#define E_IS_MAIL_CONFIG_CONFIRM_PAGE_CLASS(cls) \
+	(G_TYPE_CHECK_CLASS_TYPE \
+	((cls), E_TYPE_MAIL_CONFIG_CONFIRM_PAGE))
+#define E_MAIL_CONFIG_CONFIRM_PAGE_GET_CLASS(obj) \
+	(G_TYPE_INSTANCE_GET_CLASS \
+	((obj), E_TYPE_MAIL_CONFIG_CONFIRM_PAGE, EMailConfigConfirmPageClass))
+
+#define E_MAIL_CONFIG_CONFIRM_PAGE_SORT_ORDER (600)
+
+G_BEGIN_DECLS
+
+typedef struct _EMailConfigConfirmPage EMailConfigConfirmPage;
+typedef struct _EMailConfigConfirmPageClass EMailConfigConfirmPageClass;
+typedef struct _EMailConfigConfirmPagePrivate EMailConfigConfirmPagePrivate;
+
+struct _EMailConfigConfirmPage {
+	GtkBox parent;
+	EMailConfigConfirmPagePrivate *priv;
+};
+
+struct _EMailConfigConfirmPageClass {
+	GtkBoxClass parent_class;
+};
+
+GType		e_mail_config_confirm_page_get_type
+						(void) G_GNUC_CONST;
+EMailConfigPage *
+		e_mail_config_confirm_page_new	(void);
+const gchar *	e_mail_config_confirm_page_get_text
+						(EMailConfigConfirmPage *page);
+void		e_mail_config_confirm_page_set_text
+						(EMailConfigConfirmPage *page,
+						 const gchar *text);
+
+G_END_DECLS
+
+#endif /* E_MAIL_CONFIG_CONFIRM_PAGE_H */
+
diff --git a/mail/e-mail-config-defaults-page.c b/mail/e-mail-config-defaults-page.c
new file mode 100644
index 0000000..34b8013
--- /dev/null
+++ b/mail/e-mail-config-defaults-page.c
@@ -0,0 +1,854 @@
+/*
+ * e-mail-config-defaults-page.c
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) version 3.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with the program; if not, see <http://www.gnu.org/licenses/>
+ *
+ */
+
+#include "e-mail-config-defaults-page.h"
+
+#include <config.h>
+#include <glib/gi18n-lib.h>
+
+#include <libedataserver/e-source-camel.h>
+#include <libedataserver/e-source-enumtypes.h>
+#include <libedataserver/e-source-mail-account.h>
+#include <libedataserver/e-source-mail-composition.h>
+#include <libedataserver/e-source-mail-submission.h>
+#include <libedataserver/e-source-mdn.h>
+#include <libedataserver/e-data-server-util.h>
+
+#include <libemail-engine/e-mail-folder-utils.h>
+
+#include <mail/e-mail-config-page.h>
+#include <mail/em-folder-selection-button.h>
+
+#define E_MAIL_CONFIG_DEFAULTS_PAGE_GET_PRIVATE(obj) \
+	(G_TYPE_INSTANCE_GET_PRIVATE \
+	((obj), E_TYPE_MAIL_CONFIG_DEFAULTS_PAGE, EMailConfigDefaultsPagePrivate))
+
+struct _EMailConfigDefaultsPagePrivate {
+	EMailSession *session;
+	ESource *account_source;
+	ESource *identity_source;
+
+	GtkWidget *drafts_button;  /* not referenced */
+	GtkWidget *sent_button;    /* not referenced */
+	GtkWidget *trash_toggle;   /* not referenced */
+	GtkWidget *junk_toggle;    /* not referenced */
+};
+
+enum {
+	PROP_0,
+	PROP_ACCOUNT_SOURCE,
+	PROP_IDENTITY_SOURCE,
+	PROP_SESSION
+};
+
+/* Forward Declarations */
+static void	e_mail_config_defaults_page_interface_init
+					(EMailConfigPageInterface *interface);
+
+G_DEFINE_TYPE_WITH_CODE (
+	EMailConfigDefaultsPage,
+	e_mail_config_defaults_page,
+	GTK_TYPE_BOX,
+	G_IMPLEMENT_INTERFACE (
+		E_TYPE_MAIL_CONFIG_PAGE,
+		e_mail_config_defaults_page_interface_init))
+
+static CamelSettings *
+mail_config_defaults_page_get_settings (EMailConfigDefaultsPage *page)
+{
+	ESource *source;
+	ESourceCamel *camel_ext;
+	ESourceBackend *backend_ext;
+	const gchar *backend_name;
+	const gchar *extension_name;
+
+	source = e_mail_config_defaults_page_get_account_source (page);
+
+	extension_name = E_SOURCE_EXTENSION_MAIL_ACCOUNT;
+	backend_ext = e_source_get_extension (source, extension_name);
+	backend_name = e_source_backend_get_backend_name (backend_ext);
+
+	extension_name = e_source_camel_get_extension_name (backend_name);
+	camel_ext = e_source_get_extension (source, extension_name);
+
+	return e_source_camel_get_settings (camel_ext);
+}
+
+static CamelStore *
+mail_config_defaults_page_get_store (EMailConfigDefaultsPage *page)
+{
+	ESource *source;
+	EMailSession *session;
+	CamelService *service;
+	const gchar *uid;
+
+	session = e_mail_config_defaults_page_get_session (page);
+	source = e_mail_config_defaults_page_get_account_source (page);
+
+	uid = e_source_get_uid (source);
+	service = camel_session_get_service (CAMEL_SESSION (session), uid);
+
+	return CAMEL_IS_STORE (service) ? CAMEL_STORE (service) : NULL;
+}
+
+static gboolean
+mail_config_defaults_page_addrs_to_string (GBinding *binding,
+                                           const GValue *source_value,
+                                           GValue *target_value,
+                                           gpointer unused)
+{
+	gchar **strv;
+
+	strv = g_value_dup_boxed (source_value);
+
+	if (strv != NULL) {
+		gchar *string = g_strjoinv ("; ", strv);
+		g_value_set_string (target_value, string);
+		g_free (string);
+	} else {
+		g_value_set_string (target_value, "");
+	}
+
+	g_strfreev (strv);
+
+	return TRUE;
+}
+
+static gboolean
+mail_config_defaults_page_string_to_addrs (GBinding *binding,
+                                           const GValue *source_value,
+                                           GValue *target_value,
+                                           gpointer unused)
+{
+	CamelInternetAddress *address;
+	const gchar *string;
+	gchar **strv;
+	gint n_addresses, ii;
+
+	string = g_value_get_string (source_value);
+
+	address = camel_internet_address_new ();
+	n_addresses = camel_address_decode (CAMEL_ADDRESS (address), string);
+
+	if (n_addresses < 0) {
+		g_object_unref (address);
+		return FALSE;
+
+	} else if (n_addresses == 0) {
+		g_value_set_boxed (target_value, NULL);
+		g_object_unref (address);
+		return TRUE;
+	}
+
+	strv = g_new0 (gchar *, n_addresses + 1);
+
+	for (ii = 0; ii < n_addresses; ii++) {
+		const gchar *name = NULL;
+		const gchar *addr = NULL;
+
+		camel_internet_address_get (address, ii, &name, &addr);
+		strv[ii] = camel_internet_address_format_address (name, addr);
+	}
+
+	g_value_take_boxed (target_value, strv);
+
+	return TRUE;
+}
+
+static gboolean
+mail_config_defaults_page_folder_name_to_uri (GBinding *binding,
+                                              const GValue *source_value,
+                                              GValue *target_value,
+                                              gpointer data)
+{
+	EMailConfigDefaultsPage *page;
+	CamelStore *store;
+	const gchar *folder_name;
+	gchar *folder_uri = NULL;
+
+	page = E_MAIL_CONFIG_DEFAULTS_PAGE (data);
+	store = mail_config_defaults_page_get_store (page);
+	g_return_val_if_fail (CAMEL_IS_STORE (store), FALSE);
+
+	folder_name = g_value_get_string (source_value);
+
+	if (folder_name != NULL)
+		folder_uri = e_mail_folder_uri_build (store, folder_name);
+
+	g_value_set_string (target_value, folder_uri);
+
+	g_free (folder_uri);
+
+	return TRUE;
+}
+
+static gboolean
+mail_config_defaults_page_folder_uri_to_name (GBinding *binding,
+                                              const GValue *source_value,
+                                              GValue *target_value,
+                                              gpointer data)
+{
+	EMailConfigDefaultsPage *page;
+	EMailSession *session;
+	const gchar *folder_uri;
+	gchar *folder_name = NULL;
+	GError *error = NULL;
+
+	page = E_MAIL_CONFIG_DEFAULTS_PAGE (data);
+	session = e_mail_config_defaults_page_get_session (page);
+
+	folder_uri = g_value_get_string (source_value);
+
+	if (folder_uri == NULL) {
+		g_value_set_string (target_value, NULL);
+		return TRUE;
+	}
+
+	e_mail_folder_uri_parse (
+		CAMEL_SESSION (session), folder_uri,
+		NULL, &folder_name, &error);
+
+	if (error != NULL) {
+		g_warn_if_fail (folder_name == NULL);
+		g_warning ("%s: %s", G_STRFUNC, error->message);
+		g_error_free (error);
+		return FALSE;
+	}
+
+	g_return_val_if_fail (folder_name != NULL, FALSE);
+
+	g_value_set_string (target_value, folder_name);
+
+	g_free (folder_name);
+
+	return TRUE;
+}
+
+static void
+mail_config_defaults_page_restore_folders (EMailConfigDefaultsPage *page)
+{
+	EMFolderSelectionButton *button;
+	EMailSession *session;
+	EMailLocalFolder type;
+	const gchar *folder_uri;
+
+	session = e_mail_config_defaults_page_get_session (page);
+
+	type = E_MAIL_LOCAL_FOLDER_DRAFTS;
+	button = EM_FOLDER_SELECTION_BUTTON (page->priv->drafts_button);
+	folder_uri = e_mail_session_get_local_folder_uri (session, type);
+	em_folder_selection_button_set_folder_uri (button, folder_uri);
+
+	type = E_MAIL_LOCAL_FOLDER_SENT;
+	button = EM_FOLDER_SELECTION_BUTTON (page->priv->sent_button);
+	folder_uri = e_mail_session_get_local_folder_uri (session, type);
+	em_folder_selection_button_set_folder_uri (button, folder_uri);
+}
+
+static void
+mail_config_defaults_page_restore_real_folder (GtkToggleButton *toggle_button)
+{
+	gtk_toggle_button_set_active (toggle_button, FALSE);
+}
+
+static GtkWidget *
+mail_config_defaults_page_add_real_folder (EMailConfigDefaultsPage *page,
+                                           GtkSizeGroup *size_group,
+                                           GtkButton *revert_button,
+                                           const gchar *toggle_label,
+                                           const gchar *dialog_caption,
+                                           const gchar *property_name,
+                                           const gchar *use_property_name)
+{
+	GtkWidget *box;
+	GtkWidget *check_button;
+	GtkWidget *folder_button;
+	EMailSession *session;
+	CamelSettings *settings;
+	CamelStore *store;
+	GObjectClass *class;
+
+	store = mail_config_defaults_page_get_store (page);
+	session = e_mail_config_defaults_page_get_session (page);
+	settings = mail_config_defaults_page_get_settings (page);
+
+	g_return_val_if_fail (CAMEL_IS_STORE (store), NULL);
+	g_return_val_if_fail (CAMEL_IS_SETTINGS (settings), NULL);
+
+	/* These folder settings are backend-specific, so check if
+	 * the CamelSettings class has the property names we need. */
+
+	class = G_OBJECT_GET_CLASS (settings);
+
+	if (g_object_class_find_property (class, property_name) == NULL)
+		return NULL;
+
+	if (g_object_class_find_property (class, use_property_name) == NULL)
+		return NULL;
+
+	/* We're good to go. */
+
+	box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
+
+	check_button = gtk_check_button_new_with_mnemonic (toggle_label);
+	g_object_set (check_button, "xalign", 1.0, NULL);
+	gtk_size_group_add_widget (size_group, check_button);
+	gtk_box_pack_start (GTK_BOX (box), check_button, FALSE, FALSE, 0);
+	gtk_widget_show (check_button);
+
+	g_object_bind_property (
+		settings, use_property_name,
+		check_button, "active",
+		G_BINDING_BIDIRECTIONAL |
+		G_BINDING_SYNC_CREATE);
+
+	folder_button = em_folder_selection_button_new (
+		session, "", dialog_caption);
+	em_folder_selection_button_set_store (
+		EM_FOLDER_SELECTION_BUTTON (folder_button), store);
+	gtk_box_pack_start (GTK_BOX (box), folder_button, TRUE, TRUE, 0);
+	gtk_widget_show (folder_button);
+
+	/* XXX CamelSettings only stores the folder's path name, but the
+	 *     EMFolderSelectionButton requires a full folder URI, so we
+	 *     have to do some fancy transforms for the binding to work. */
+	g_object_bind_property_full (
+		settings, property_name,
+		folder_button, "folder-uri",
+		G_BINDING_BIDIRECTIONAL |
+		G_BINDING_SYNC_CREATE,
+		mail_config_defaults_page_folder_name_to_uri,
+		mail_config_defaults_page_folder_uri_to_name,
+		g_object_ref (page),
+		(GDestroyNotify) g_object_unref);
+
+	g_object_bind_property (
+		check_button, "active",
+		folder_button, "sensitive",
+		G_BINDING_SYNC_CREATE);
+
+	g_signal_connect_swapped (
+		revert_button, "clicked",
+		G_CALLBACK (mail_config_defaults_page_restore_real_folder),
+		check_button);
+
+	return box;
+}
+
+static void
+mail_config_defaults_page_set_account_source (EMailConfigDefaultsPage *page,
+                                              ESource *account_source)
+{
+	g_return_if_fail (E_IS_SOURCE (account_source));
+	g_return_if_fail (page->priv->account_source == NULL);
+
+	page->priv->account_source = g_object_ref (account_source);
+}
+
+static void
+mail_config_defaults_page_set_identity_source (EMailConfigDefaultsPage *page,
+                                               ESource *identity_source)
+{
+	g_return_if_fail (E_IS_SOURCE (identity_source));
+	g_return_if_fail (page->priv->identity_source == NULL);
+
+	page->priv->identity_source = g_object_ref (identity_source);
+}
+
+static void
+mail_config_defaults_page_set_session (EMailConfigDefaultsPage *page,
+                                       EMailSession *session)
+{
+	g_return_if_fail (E_IS_MAIL_SESSION (session));
+	g_return_if_fail (page->priv->session == NULL);
+
+	page->priv->session = g_object_ref (session);
+}
+
+static void
+mail_config_defaults_page_set_property (GObject *object,
+                                        guint property_id,
+                                        const GValue *value,
+                                        GParamSpec *pspec)
+{
+	switch (property_id) {
+		case PROP_ACCOUNT_SOURCE:
+			mail_config_defaults_page_set_account_source (
+				E_MAIL_CONFIG_DEFAULTS_PAGE (object),
+				g_value_get_object (value));
+			return;
+
+		case PROP_IDENTITY_SOURCE:
+			mail_config_defaults_page_set_identity_source (
+				E_MAIL_CONFIG_DEFAULTS_PAGE (object),
+				g_value_get_object (value));
+			return;
+
+		case PROP_SESSION:
+			mail_config_defaults_page_set_session (
+				E_MAIL_CONFIG_DEFAULTS_PAGE (object),
+				g_value_get_object (value));
+			return;
+	}
+
+	G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+}
+
+static void
+mail_config_defaults_page_get_property (GObject *object,
+                                        guint property_id,
+                                        GValue *value,
+                                        GParamSpec *pspec)
+{
+	switch (property_id) {
+		case PROP_ACCOUNT_SOURCE:
+			g_value_set_object (
+				value,
+				e_mail_config_defaults_page_get_account_source (
+				E_MAIL_CONFIG_DEFAULTS_PAGE (object)));
+			return;
+
+		case PROP_IDENTITY_SOURCE:
+			g_value_set_object (
+				value,
+				e_mail_config_defaults_page_get_identity_source (
+				E_MAIL_CONFIG_DEFAULTS_PAGE (object)));
+			return;
+
+		case PROP_SESSION:
+			g_value_set_object (
+				value,
+				e_mail_config_defaults_page_get_session (
+				E_MAIL_CONFIG_DEFAULTS_PAGE (object)));
+			return;
+	}
+
+	G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+}
+
+static void
+mail_config_defaults_page_dispose (GObject *object)
+{
+	EMailConfigDefaultsPagePrivate *priv;
+
+	priv = E_MAIL_CONFIG_DEFAULTS_PAGE_GET_PRIVATE (object);
+
+	if (priv->identity_source != NULL) {
+		g_object_unref (priv->identity_source);
+		priv->identity_source = NULL;
+	}
+
+	if (priv->session != NULL) {
+		g_object_unref (priv->session);
+		priv->session = NULL;
+	}
+
+	/* Chain up to parent's dispose() method. */
+	G_OBJECT_CLASS (e_mail_config_defaults_page_parent_class)->
+		dispose (object);
+}
+
+static void
+mail_config_defaults_page_constructed (GObject *object)
+{
+	EMailConfigDefaultsPage *page;
+	EMailSession *session;
+	ESource *source;
+	ESourceMailComposition *composition_ext;
+	ESourceMailSubmission *submission_ext;
+	ESourceMDN *mdn_ext;
+	GtkLabel *label;
+	GtkButton *button;
+	GtkWidget *widget;
+	GtkWidget *container;
+	GtkSizeGroup *size_group;
+	GEnumClass *enum_class;
+	GEnumValue *enum_value;
+	EMdnResponsePolicy policy;
+	const gchar *extension_name;
+	const gchar *text;
+	gchar *markup;
+
+	page = E_MAIL_CONFIG_DEFAULTS_PAGE (object);
+
+	/* Chain up to parent's constructed() method. */
+	G_OBJECT_CLASS (e_mail_config_defaults_page_parent_class)->
+		constructed (object);
+
+	session = e_mail_config_defaults_page_get_session (page);
+	source = e_mail_config_defaults_page_get_identity_source (page);
+
+	extension_name = E_SOURCE_EXTENSION_MAIL_COMPOSITION;
+	composition_ext = e_source_get_extension (source, extension_name);
+
+	extension_name = E_SOURCE_EXTENSION_MAIL_SUBMISSION;
+	submission_ext = e_source_get_extension (source, extension_name);
+
+	extension_name = E_SOURCE_EXTENSION_MDN;
+	mdn_ext = e_source_get_extension (source, extension_name);
+
+	gtk_orientable_set_orientation (
+		GTK_ORIENTABLE (page), GTK_ORIENTATION_VERTICAL);
+
+	gtk_box_set_spacing (GTK_BOX (page), 12);
+
+	size_group = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL);
+
+	/*** Special Folders ***/
+
+	widget = gtk_grid_new ();
+	gtk_grid_set_row_spacing (GTK_GRID (widget), 6);
+	gtk_grid_set_column_spacing (GTK_GRID (widget), 6);
+	gtk_box_pack_start (GTK_BOX (page), widget, FALSE, FALSE, 0);
+	gtk_widget_show (widget);
+
+	container = widget;
+
+	text = _("Special Folders");
+	markup = g_markup_printf_escaped ("<b>%s</b>", text);
+	widget = gtk_label_new (markup);
+	gtk_label_set_use_markup (GTK_LABEL (widget), TRUE);
+	gtk_misc_set_alignment (GTK_MISC (widget), 0.0, 0.5);
+	gtk_grid_attach (GTK_GRID (container), widget, 0, 0, 2, 1);
+	gtk_widget_show (widget);
+	g_free (markup);
+
+	text = _("Draft Messages _Folder:");
+	widget = gtk_label_new_with_mnemonic (text);
+	gtk_widget_set_margin_left (widget, 12);
+	gtk_size_group_add_widget (size_group, widget);
+	gtk_misc_set_alignment (GTK_MISC (widget), 1.0, 0.5);
+	gtk_grid_attach (GTK_GRID (container), widget, 0, 1, 1, 1);
+	gtk_widget_show (widget);
+
+	label = GTK_LABEL (widget);
+
+	text = _("Choose a folder for saving draft messages.");
+	widget = em_folder_selection_button_new (session, "", text);
+	gtk_widget_set_hexpand (widget, TRUE);
+	gtk_label_set_mnemonic_widget (label, widget);
+	gtk_grid_attach (GTK_GRID (container), widget, 1, 1, 1, 1);
+	page->priv->drafts_button = widget;  /* not referenced */
+	gtk_widget_show (widget);
+
+	g_object_bind_property (
+		composition_ext, "drafts-folder",
+		widget, "folder-uri",
+		G_BINDING_BIDIRECTIONAL |
+		G_BINDING_SYNC_CREATE);
+
+	text = _("Sent _Messages Folder:");
+	widget = gtk_label_new_with_mnemonic (text);
+	gtk_widget_set_margin_left (widget, 12);
+	gtk_size_group_add_widget (size_group, widget);
+	gtk_misc_set_alignment (GTK_MISC (widget), 1.0, 0.5);
+	gtk_grid_attach (GTK_GRID (container), widget, 0, 2, 1, 1);
+	gtk_widget_show (widget);
+
+	label = GTK_LABEL (widget);
+
+	text = _("Choose a folder for saving sent messages.");
+	widget = em_folder_selection_button_new (session, "", text);
+	gtk_widget_set_hexpand (widget, TRUE);
+	gtk_label_set_mnemonic_widget (label, widget);
+	gtk_grid_attach (GTK_GRID (container), widget, 1, 2, 1, 1);
+	page->priv->sent_button = widget;  /* not referenced */
+	gtk_widget_show (widget);
+
+	g_object_bind_property (
+		submission_ext, "sent-folder",
+		widget, "folder-uri",
+		G_BINDING_BIDIRECTIONAL |
+		G_BINDING_SYNC_CREATE);
+
+	widget = gtk_button_new_with_mnemonic (_("_Restore Defaults"));
+	gtk_widget_set_halign (widget, GTK_ALIGN_START);
+	gtk_grid_attach (GTK_GRID (container), widget, 1, 5, 1, 1);
+	gtk_widget_show (widget);
+
+	g_signal_connect_swapped (
+		widget, "clicked",
+		G_CALLBACK (mail_config_defaults_page_restore_folders),
+		page);
+
+	button = GTK_BUTTON (widget);
+
+	widget = mail_config_defaults_page_add_real_folder (
+		page, size_group, button,
+		_("Use a Real Folder for _Trash:"),
+		_("Choose a folder for deleted messages."),
+		"real-trash-path", "use-real-trash-path");
+	if (widget != NULL) {
+		gtk_grid_attach (GTK_GRID (container), widget, 0, 3, 2, 1);
+		gtk_widget_show (widget);
+	}
+
+	widget = mail_config_defaults_page_add_real_folder (
+		page, size_group, button,
+		_("Use a Real Folder for _Junk:"),
+		_("Choose a folder for junk messages."),
+		"real-junk-path", "use-real-junk-path");
+	if (widget != NULL) {
+		gtk_grid_attach (GTK_GRID (container), widget, 0, 4, 2, 1);
+		gtk_widget_show (widget);
+	}
+
+	/*** Composing Messages ***/
+
+	widget = gtk_grid_new ();
+	gtk_grid_set_row_spacing (GTK_GRID (widget), 6);
+	gtk_grid_set_column_spacing (GTK_GRID (widget), 6);
+	gtk_box_pack_start (GTK_BOX (page), widget, FALSE, FALSE, 0);
+	gtk_widget_show (widget);
+
+	container = widget;
+
+	text = _("Composing Messages");
+	markup = g_markup_printf_escaped ("<b>%s</b>", text);
+	widget = gtk_label_new (markup);
+	gtk_label_set_use_markup (GTK_LABEL (widget), TRUE);
+	gtk_misc_set_alignment (GTK_MISC (widget), 0.0, 0.5);
+	gtk_grid_attach (GTK_GRID (container), widget, 0, 0, 1, 1);
+	gtk_widget_show (widget);
+	g_free (markup);
+
+	text = _("Alway_s carbon-copy (cc) to:");
+	widget = gtk_label_new_with_mnemonic (text);
+	gtk_widget_set_margin_left (widget, 12);
+	gtk_misc_set_alignment (GTK_MISC (widget), 0.0, 0.5);
+	gtk_grid_attach (GTK_GRID (container), widget, 0, 1, 1, 1);
+	gtk_widget_show (widget);
+
+	label = GTK_LABEL (widget);
+
+	widget = gtk_entry_new ();
+	gtk_widget_set_hexpand (widget, TRUE);
+	gtk_widget_set_margin_left (widget, 12);
+	gtk_label_set_mnemonic_widget (label, widget);
+	gtk_grid_attach (GTK_GRID (container), widget, 0, 2, 1, 1);
+	gtk_widget_show (widget);
+
+	g_object_bind_property_full (
+		composition_ext, "cc",
+		widget, "text",
+		G_BINDING_BIDIRECTIONAL |
+		G_BINDING_SYNC_CREATE,
+		mail_config_defaults_page_addrs_to_string,
+		mail_config_defaults_page_string_to_addrs,
+		NULL, (GDestroyNotify) NULL);
+
+	text = _("Always _blind carbon-copy (bcc) to:");
+	widget = gtk_label_new_with_mnemonic (text);
+	gtk_widget_set_margin_left (widget, 12);
+	gtk_misc_set_alignment (GTK_MISC (widget), 0.0, 0.5);
+	gtk_grid_attach (GTK_GRID (container), widget, 0, 3, 1, 1);
+	gtk_widget_show (widget);
+
+	label = GTK_LABEL (widget);
+
+	widget = gtk_entry_new ();
+	gtk_widget_set_hexpand (widget, TRUE);
+	gtk_widget_set_margin_left (widget, 12);
+	gtk_label_set_mnemonic_widget (label, widget);
+	gtk_grid_attach (GTK_GRID (container), widget, 0, 4, 1, 1);
+	gtk_widget_show (widget);
+
+	g_object_bind_property_full (
+		composition_ext, "bcc",
+		widget, "text",
+		G_BINDING_BIDIRECTIONAL |
+		G_BINDING_SYNC_CREATE,
+		mail_config_defaults_page_addrs_to_string,
+		mail_config_defaults_page_string_to_addrs,
+		NULL, (GDestroyNotify) NULL);
+
+	/*** Message Receipts ***/
+
+	widget = gtk_grid_new ();
+	gtk_grid_set_row_spacing (GTK_GRID (widget), 6);
+	gtk_grid_set_column_spacing (GTK_GRID (widget), 6);
+	gtk_box_pack_start (GTK_BOX (page), widget, FALSE, FALSE, 0);
+	gtk_widget_show (widget);
+
+	container = widget;
+
+	text = _("Message Receipts");
+	markup = g_markup_printf_escaped ("<b>%s</b>", text);
+	widget = gtk_label_new (markup);
+	gtk_label_set_use_markup (GTK_LABEL (widget), TRUE);
+	gtk_misc_set_alignment (GTK_MISC (widget), 0.0, 0.5);
+	gtk_grid_attach (GTK_GRID (container), widget, 0, 0, 2, 1);
+	gtk_widget_show (widget);
+	g_free (markup);
+
+	text = _("S_end message receipts:");
+	widget = gtk_label_new_with_mnemonic (text);
+	gtk_widget_set_margin_left (widget, 12);
+	gtk_size_group_add_widget (size_group, widget);
+	gtk_misc_set_alignment (GTK_MISC (widget), 1.0, 0.5);
+	gtk_grid_attach (GTK_GRID (container), widget, 0, 1, 1, 1);
+	gtk_widget_show (widget);
+
+	label = GTK_LABEL (widget);
+
+	widget = gtk_combo_box_text_new ();
+	gtk_widget_set_hexpand (widget, TRUE);
+	gtk_label_set_mnemonic_widget (label, widget);
+	gtk_grid_attach (GTK_GRID (container), widget, 1, 1, 1, 1);
+	gtk_widget_show (widget);
+
+	/* XXX This is a pain in the butt, but we want to avoid hard-coding
+	 *     string values from the EMdnResponsePolicy enum class in case
+	 *     they change in the future. */
+	enum_class = g_type_class_ref (E_TYPE_MDN_RESPONSE_POLICY);
+	policy = E_MDN_RESPONSE_POLICY_NEVER;
+	enum_value = g_enum_get_value (enum_class, policy);
+	g_return_if_fail (enum_value != NULL);
+	gtk_combo_box_text_append (
+		GTK_COMBO_BOX_TEXT (widget),
+		enum_value->value_nick, _("Never"));
+	policy = E_MDN_RESPONSE_POLICY_ALWAYS;
+	enum_value = g_enum_get_value (enum_class, policy);
+	g_return_if_fail (enum_value != NULL);
+	gtk_combo_box_text_append (
+		GTK_COMBO_BOX_TEXT (widget),
+		enum_value->value_nick, _("Always"));
+	policy = E_MDN_RESPONSE_POLICY_ASK;
+	enum_value = g_enum_get_value (enum_class, policy);
+	g_return_if_fail (enum_value != NULL);
+	gtk_combo_box_text_append (
+		GTK_COMBO_BOX_TEXT (widget),
+		enum_value->value_nick, _("Ask for each message"));
+	g_type_class_unref (enum_class);
+
+	g_object_bind_property_full (
+		mdn_ext, "response-policy",
+		widget, "active-id",
+		G_BINDING_BIDIRECTIONAL |
+		G_BINDING_SYNC_CREATE,
+		e_binding_transform_enum_value_to_nick,
+		e_binding_transform_enum_nick_to_value,
+		NULL, (GDestroyNotify) NULL);
+
+	g_object_unref (size_group);
+}
+
+static void
+e_mail_config_defaults_page_class_init (EMailConfigDefaultsPageClass *class)
+{
+	GObjectClass *object_class;
+
+	g_type_class_add_private (
+		class, sizeof (EMailConfigDefaultsPagePrivate));
+
+	object_class = G_OBJECT_CLASS (class);
+	object_class->set_property = mail_config_defaults_page_set_property;
+	object_class->get_property = mail_config_defaults_page_get_property;
+	object_class->dispose = mail_config_defaults_page_dispose;
+	object_class->constructed = mail_config_defaults_page_constructed;
+
+	g_object_class_install_property (
+		object_class,
+		PROP_ACCOUNT_SOURCE,
+		g_param_spec_object (
+			"account-source",
+			"Account Source",
+			"Mail account source being edited",
+			E_TYPE_SOURCE,
+			G_PARAM_READWRITE |
+			G_PARAM_CONSTRUCT_ONLY |
+			G_PARAM_STATIC_STRINGS));
+
+	g_object_class_install_property (
+		object_class,
+		PROP_IDENTITY_SOURCE,
+		g_param_spec_object (
+			"identity-source",
+			"Identity Source",
+			"Mail identity source being edited",
+			E_TYPE_SOURCE,
+			G_PARAM_READWRITE |
+			G_PARAM_CONSTRUCT_ONLY |
+			G_PARAM_STATIC_STRINGS));
+
+	g_object_class_install_property (
+		object_class,
+		PROP_SESSION,
+		g_param_spec_object (
+			"session",
+			"Session",
+			"Mail session",
+			E_TYPE_MAIL_SESSION,
+			G_PARAM_READWRITE |
+			G_PARAM_CONSTRUCT_ONLY |
+			G_PARAM_STATIC_STRINGS));
+}
+
+static void
+e_mail_config_defaults_page_interface_init (EMailConfigPageInterface *interface)
+{
+	interface->title = _("Defaults");
+	interface->sort_order = E_MAIL_CONFIG_DEFAULTS_PAGE_SORT_ORDER;
+}
+
+static void
+e_mail_config_defaults_page_init (EMailConfigDefaultsPage *page)
+{
+	page->priv = E_MAIL_CONFIG_DEFAULTS_PAGE_GET_PRIVATE (page);
+}
+
+EMailConfigPage *
+e_mail_config_defaults_page_new (EMailSession *session,
+                                 ESource *account_source,
+                                 ESource *identity_source)
+{
+	g_return_val_if_fail (E_IS_MAIL_SESSION (session), NULL);
+	g_return_val_if_fail (E_IS_SOURCE (account_source), NULL);
+	g_return_val_if_fail (E_IS_SOURCE (identity_source), NULL);
+
+	return g_object_new (
+		E_TYPE_MAIL_CONFIG_DEFAULTS_PAGE,
+		"account-source", account_source,
+		"identity-source", identity_source,
+		"session", session, NULL);
+}
+
+EMailSession *
+e_mail_config_defaults_page_get_session (EMailConfigDefaultsPage *page)
+{
+	g_return_val_if_fail (E_IS_MAIL_CONFIG_DEFAULTS_PAGE (page), NULL);
+
+	return page->priv->session;
+}
+
+ESource *
+e_mail_config_defaults_page_get_account_source (EMailConfigDefaultsPage *page)
+{
+	g_return_val_if_fail (E_IS_MAIL_CONFIG_DEFAULTS_PAGE (page), NULL);
+
+	return page->priv->account_source;
+}
+
+ESource *
+e_mail_config_defaults_page_get_identity_source (EMailConfigDefaultsPage *page)
+{
+	g_return_val_if_fail (E_IS_MAIL_CONFIG_DEFAULTS_PAGE (page), NULL);
+
+	return page->priv->identity_source;
+}
+
diff --git a/mail/e-mail-config-defaults-page.h b/mail/e-mail-config-defaults-page.h
new file mode 100644
index 0000000..0f6371c
--- /dev/null
+++ b/mail/e-mail-config-defaults-page.h
@@ -0,0 +1,79 @@
+/*
+ * e-mail-config-defaults-page.h
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) version 3.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with the program; if not, see <http://www.gnu.org/licenses/>
+ *
+ */
+
+#ifndef E_MAIL_CONFIG_DEFAULTS_PAGE_H
+#define E_MAIL_CONFIG_DEFAULTS_PAGE_H
+
+#include <gtk/gtk.h>
+#include <libemail-engine/e-mail-session.h>
+
+#include <mail/e-mail-config-page.h>
+
+/* Standard GObject macros */
+#define E_TYPE_MAIL_CONFIG_DEFAULTS_PAGE \
+	(e_mail_config_defaults_page_get_type ())
+#define E_MAIL_CONFIG_DEFAULTS_PAGE(obj) \
+	(G_TYPE_CHECK_INSTANCE_CAST \
+	((obj), E_TYPE_MAIL_CONFIG_DEFAULTS_PAGE, EMailConfigDefaultsPage))
+#define E_MAIL_CONFIG_DEFAULT_PAGE_CLASS(cls) \
+	(G_TYPE_CHECK_CLASS_CAST \
+	((cls), E_TYPE_MAIL_CONFIG_DEFAULTS_PAGE, EMailConfigDefaultsPageClass))
+#define E_IS_MAIL_CONFIG_DEFAULTS_PAGE(obj) \
+	(G_TYPE_CHECK_INSTANCE_TYPE \
+	((obj), E_TYPE_MAIL_CONFIG_DEFAULTS_PAGE))
+#define E_IS_MAIL_CONFIG_DEFAULTS_PAGE_CLASS(cls) \
+	(G_TYPE_CHECK_CLASS_TYPE \
+	((cls), E_TYPE_MAIL_CONFIG_DEFAULTS_PAGE))
+#define E_MAIL_CONFIG_DEFAULTS_PAGE_GET_CLASS(obj) \
+	(G_TYPE_INSTANCE_GET_CLASS \
+	((obj), E_TYPE_MAIL_CONFIG_DEFAULTS_PAGE, EMailConfigDefaultsPageClass))
+
+#define E_MAIL_CONFIG_DEFAULTS_PAGE_SORT_ORDER (500)
+
+G_BEGIN_DECLS
+
+typedef struct _EMailConfigDefaultsPage EMailConfigDefaultsPage;
+typedef struct _EMailConfigDefaultsPageClass EMailConfigDefaultsPageClass;
+typedef struct _EMailConfigDefaultsPagePrivate EMailConfigDefaultsPagePrivate;
+
+struct _EMailConfigDefaultsPage {
+	GtkBox parent;
+	EMailConfigDefaultsPagePrivate *priv;
+};
+
+struct _EMailConfigDefaultsPageClass {
+	GtkBoxClass parent_class;
+};
+
+GType		e_mail_config_defaults_page_get_type
+						(void) G_GNUC_CONST;
+EMailConfigPage *
+		e_mail_config_defaults_page_new	(EMailSession *session,
+						 ESource *account_source,
+						 ESource *identity_source);
+EMailSession *	e_mail_config_defaults_page_get_session
+						(EMailConfigDefaultsPage *page);
+ESource *	e_mail_config_defaults_page_get_account_source
+						(EMailConfigDefaultsPage *page);
+ESource *	e_mail_config_defaults_page_get_identity_source
+						(EMailConfigDefaultsPage *page);
+
+G_END_DECLS
+
+#endif /* E_MAIL_CONFIG_DEFAULTS_PAGE_H */
+
diff --git a/mail/e-mail-config-identity-page.c b/mail/e-mail-config-identity-page.c
new file mode 100644
index 0000000..9850a56
--- /dev/null
+++ b/mail/e-mail-config-identity-page.c
@@ -0,0 +1,733 @@
+/*
+ * e-mail-config-identity-page.c
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) version 3.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with the program; if not, see <http://www.gnu.org/licenses/>
+ *
+ */
+
+#include "e-mail-config-identity-page.h"
+
+#include <config.h>
+#include <glib/gi18n-lib.h>
+
+#include <libedataserver/e-source-mail-identity.h>
+
+#include <e-util/e-marshal.h>
+#include <misc/e-mail-signature-combo-box.h>
+#include <misc/e-mail-signature-editor.h>
+
+#define E_MAIL_CONFIG_IDENTITY_PAGE_GET_PRIVATE(obj) \
+	(G_TYPE_INSTANCE_GET_PRIVATE \
+	((obj), E_TYPE_MAIL_CONFIG_IDENTITY_PAGE, EMailConfigIdentityPagePrivate))
+
+struct _EMailConfigIdentityPagePrivate {
+	ESource *identity_source;
+	ESourceRegistry *registry;
+	gboolean show_account_info;
+	gboolean show_instructions;
+	gboolean show_signatures;
+};
+
+enum {
+	PROP_0,
+	PROP_IDENTITY_SOURCE,
+	PROP_REGISTRY,
+	PROP_SHOW_ACCOUNT_INFO,
+	PROP_SHOW_INSTRUCTIONS,
+	PROP_SHOW_SIGNATURES
+};
+
+/* Forward Declarations */
+static void	e_mail_config_identity_page_interface_init
+					(EMailConfigPageInterface *interface);
+
+G_DEFINE_TYPE_WITH_CODE (
+	EMailConfigIdentityPage,
+	e_mail_config_identity_page,
+	GTK_TYPE_BOX,
+	G_IMPLEMENT_INTERFACE (
+		E_TYPE_MAIL_CONFIG_PAGE,
+		e_mail_config_identity_page_interface_init))
+
+static gboolean
+mail_config_identity_page_is_email (const gchar *email_address)
+{
+	const gchar *cp;
+
+	/* Make sure we have a '@' between a name and domain part. */
+	cp = strchr (email_address, '@');
+
+	return (cp != NULL && cp != email_address && *(cp + 1) != '\0');
+}
+
+static void
+mail_config_identity_page_add_signature_cb (GtkButton *button,
+                                            EMailConfigIdentityPage *page)
+{
+	ESourceRegistry *registry;
+	GtkWidget *editor;
+
+	registry = e_mail_config_identity_page_get_registry (page);
+
+	editor = e_mail_signature_editor_new (registry, NULL);
+	gtk_window_set_position (GTK_WINDOW (editor), GTK_WIN_POS_CENTER);
+	gtk_widget_show (editor);
+}
+
+static void
+mail_config_identity_page_set_registry (EMailConfigIdentityPage *page,
+                                        ESourceRegistry *registry)
+{
+	g_return_if_fail (E_IS_SOURCE_REGISTRY (registry));
+	g_return_if_fail (page->priv->registry == NULL);
+
+	page->priv->registry = g_object_ref (registry);
+}
+
+static void
+mail_config_identity_page_set_identity_source (EMailConfigIdentityPage *page,
+                                               ESource *identity_source)
+{
+	g_return_if_fail (E_IS_SOURCE (identity_source));
+	g_return_if_fail (page->priv->identity_source == NULL);
+
+	page->priv->identity_source = g_object_ref (identity_source);
+}
+
+static void
+mail_config_identity_page_set_property (GObject *object,
+                                        guint property_id,
+                                        const GValue *value,
+                                        GParamSpec *pspec)
+{
+	switch (property_id) {
+		case PROP_IDENTITY_SOURCE:
+			mail_config_identity_page_set_identity_source (
+				E_MAIL_CONFIG_IDENTITY_PAGE (object),
+				g_value_get_object (value));
+			return;
+
+		case PROP_REGISTRY:
+			mail_config_identity_page_set_registry (
+				E_MAIL_CONFIG_IDENTITY_PAGE (object),
+				g_value_get_object (value));
+			return;
+
+		case PROP_SHOW_ACCOUNT_INFO:
+			e_mail_config_identity_page_set_show_account_info (
+				E_MAIL_CONFIG_IDENTITY_PAGE (object),
+				g_value_get_boolean (value));
+			return;
+
+		case PROP_SHOW_INSTRUCTIONS:
+			e_mail_config_identity_page_set_show_instructions (
+				E_MAIL_CONFIG_IDENTITY_PAGE (object),
+				g_value_get_boolean (value));
+			return;
+
+		case PROP_SHOW_SIGNATURES:
+			e_mail_config_identity_page_set_show_signatures (
+				E_MAIL_CONFIG_IDENTITY_PAGE (object),
+				g_value_get_boolean (value));
+			return;
+	}
+
+	G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+}
+
+static void
+mail_config_identity_page_get_property (GObject *object,
+                                        guint property_id,
+                                        GValue *value,
+                                        GParamSpec *pspec)
+{
+	switch (property_id) {
+		case PROP_IDENTITY_SOURCE:
+			g_value_set_object (
+				value,
+				e_mail_config_identity_page_get_identity_source (
+				E_MAIL_CONFIG_IDENTITY_PAGE (object)));
+			return;
+
+		case PROP_REGISTRY:
+			g_value_set_object (
+				value,
+				e_mail_config_identity_page_get_registry (
+				E_MAIL_CONFIG_IDENTITY_PAGE (object)));
+			return;
+
+		case PROP_SHOW_ACCOUNT_INFO:
+			g_value_set_boolean (
+				value,
+				e_mail_config_identity_page_get_show_account_info (
+				E_MAIL_CONFIG_IDENTITY_PAGE (object)));
+			return;
+
+		case PROP_SHOW_INSTRUCTIONS:
+			g_value_set_boolean (
+				value,
+				e_mail_config_identity_page_get_show_instructions (
+				E_MAIL_CONFIG_IDENTITY_PAGE (object)));
+			return;
+
+		case PROP_SHOW_SIGNATURES:
+			g_value_set_boolean (
+				value,
+				e_mail_config_identity_page_get_show_signatures (
+				E_MAIL_CONFIG_IDENTITY_PAGE (object)));
+			return;
+	}
+
+	G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+}
+
+static void
+mail_config_identity_page_dispose (GObject *object)
+{
+	EMailConfigIdentityPagePrivate *priv;
+
+	priv = E_MAIL_CONFIG_IDENTITY_PAGE_GET_PRIVATE (object);
+
+	if (priv->identity_source != NULL) {
+		g_object_unref (priv->identity_source);
+		priv->identity_source = NULL;
+	}
+
+	if (priv->registry != NULL) {
+		g_object_unref (priv->registry);
+		priv->registry = NULL;
+	}
+
+	/* Chain up to parent's dispose() method. */
+	G_OBJECT_CLASS (e_mail_config_identity_page_parent_class)->
+		dispose (object);
+}
+
+static void
+mail_config_identity_page_constructed (GObject *object)
+{
+	EMailConfigIdentityPage *page;
+	ESource *source;
+	ESourceRegistry *registry;
+	ESourceMailIdentity *extension;
+	GtkLabel *label;
+	GtkWidget *widget;
+	GtkWidget *container;
+	GtkSizeGroup *size_group;
+	const gchar *extension_name;
+	const gchar *text;
+	gchar *markup;
+
+	page = E_MAIL_CONFIG_IDENTITY_PAGE (object);
+
+	/* Chain up to parent's constructed() method. */
+	G_OBJECT_CLASS (e_mail_config_identity_page_parent_class)->
+		constructed (object);
+
+	extension_name = E_SOURCE_EXTENSION_MAIL_IDENTITY;
+	registry = e_mail_config_identity_page_get_registry (page);
+	source = e_mail_config_identity_page_get_identity_source (page);
+	extension = e_source_get_extension (source, extension_name);
+
+	gtk_orientable_set_orientation (
+		GTK_ORIENTABLE (page), GTK_ORIENTATION_VERTICAL);
+
+	gtk_box_set_spacing (GTK_BOX (page), 12);
+
+	/* This keeps all mnemonic labels the same width. */
+	size_group = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL);
+	gtk_size_group_set_ignore_hidden (size_group, TRUE);
+
+	text = _("Please enter your name and email address below. "
+		 "The \"optional\" fields below do not need to be filled "
+		 "in, unless you wish to include this information in email "
+		 "you send.");
+	widget = gtk_label_new (text);
+	gtk_label_set_line_wrap (GTK_LABEL (widget), TRUE);
+	gtk_misc_set_alignment (GTK_MISC (widget), 0.0, 0.5);
+	gtk_box_pack_start (GTK_BOX (page), widget, FALSE, FALSE, 0);
+
+	g_object_bind_property (
+		page, "show-instructions",
+		widget, "visible",
+		G_BINDING_SYNC_CREATE);
+
+	/*** Account Information ***/
+
+	widget = gtk_grid_new ();
+	gtk_grid_set_row_spacing (GTK_GRID (widget), 6);
+	gtk_grid_set_column_spacing (GTK_GRID (widget), 6);
+	gtk_box_pack_start (GTK_BOX (page), widget, FALSE, FALSE, 0);
+
+	g_object_bind_property (
+		page, "show-account-info",
+		widget, "visible",
+		G_BINDING_SYNC_CREATE);
+
+	container = widget;
+
+	text = _("Account Information");
+	markup = g_markup_printf_escaped ("<b>%s</b>", text);
+	widget = gtk_label_new (markup);
+	gtk_label_set_use_markup (GTK_LABEL (widget), TRUE);
+	gtk_misc_set_alignment (GTK_MISC (widget), 0.0, 0.5);
+	gtk_grid_attach (GTK_GRID (container), widget, 0, 0, 2, 1);
+	gtk_widget_show (widget);
+	g_free (markup);
+
+	text = _("Type the name by which you would like to refer to "
+		 "this account.\nFor example, \"Work\" or \"Personal\".");
+	widget = gtk_label_new (text);
+	gtk_widget_set_margin_left (widget, 12);
+	gtk_misc_set_alignment (GTK_MISC (widget), 0.0, 0.5);
+	gtk_grid_attach (GTK_GRID (container), widget, 0, 1, 2, 1);
+	gtk_widget_show (widget);
+
+	text = _("_Name:");
+	widget = gtk_label_new_with_mnemonic (text);
+	gtk_widget_set_margin_left (widget, 12);
+	gtk_size_group_add_widget (size_group, widget);
+	gtk_misc_set_alignment (GTK_MISC (widget), 1.0, 0.5);
+	gtk_grid_attach (GTK_GRID (container), widget, 0, 2, 1, 1);
+	gtk_widget_show (widget);
+
+	label = GTK_LABEL (widget);
+
+	widget = gtk_entry_new ();
+	gtk_widget_set_hexpand (widget, TRUE);
+	gtk_label_set_mnemonic_widget (label, widget);
+	gtk_grid_attach (GTK_GRID (container), widget, 1, 2, 1, 1);
+	gtk_widget_show (widget);
+
+	g_object_bind_property (
+		source, "display-name",
+		widget, "text",
+		G_BINDING_BIDIRECTIONAL |
+		G_BINDING_SYNC_CREATE);
+
+	/* This entry affects the "check-complete" result. */
+	g_signal_connect_swapped (
+		widget, "changed",
+		G_CALLBACK (e_mail_config_page_changed), page);
+
+	/*** Required Information ***/
+
+	widget = gtk_grid_new ();
+	gtk_grid_set_row_spacing (GTK_GRID (widget), 6);
+	gtk_grid_set_column_spacing (GTK_GRID (widget), 6);
+	gtk_box_pack_start (GTK_BOX (page), widget, FALSE, FALSE, 0);
+	gtk_widget_show (widget);
+
+	container = widget;
+
+	text = _("Required Information");
+	markup = g_markup_printf_escaped ("<b>%s</b>", text);
+	widget = gtk_label_new (markup);
+	gtk_label_set_use_markup (GTK_LABEL (widget), TRUE);
+	gtk_misc_set_alignment (GTK_MISC (widget), 0.0, 0.5);
+	gtk_grid_attach (GTK_GRID (container), widget, 0, 0, 2, 1);
+	gtk_widget_show (widget);
+	g_free (markup);
+
+	text = _("Full Nam_e:");
+	widget = gtk_label_new_with_mnemonic (text);
+	gtk_widget_set_margin_left (widget, 12);
+	gtk_size_group_add_widget (size_group, widget);
+	gtk_misc_set_alignment (GTK_MISC (widget), 1.0, 0.5);
+	gtk_grid_attach (GTK_GRID (container), widget, 0, 1, 1, 1);
+	gtk_widget_show (widget);
+
+	label = GTK_LABEL (widget);
+
+	widget = gtk_entry_new ();
+	gtk_widget_set_hexpand (widget, TRUE);
+	gtk_label_set_mnemonic_widget (label, widget);
+	gtk_grid_attach (GTK_GRID (container), widget, 1, 1, 1, 1);
+	gtk_widget_show (widget);
+
+	g_object_bind_property (
+		extension, "name",
+		widget, "text",
+		G_BINDING_BIDIRECTIONAL |
+		G_BINDING_SYNC_CREATE);
+
+	/* This entry affects the "check-complete" result. */
+	g_signal_connect_swapped (
+		widget, "changed",
+		G_CALLBACK (e_mail_config_page_changed), page);
+
+	text = _("Email _Address:");
+	widget = gtk_label_new_with_mnemonic (text);
+	gtk_widget_set_margin_left (widget, 12);
+	gtk_size_group_add_widget (size_group, widget);
+	gtk_misc_set_alignment (GTK_MISC (widget), 1.0, 0.5);
+	gtk_grid_attach (GTK_GRID (container), widget, 0, 2, 1, 1);
+	gtk_widget_show (widget);
+
+	label = GTK_LABEL (widget);
+
+	widget = gtk_entry_new ();
+	gtk_widget_set_hexpand (widget, TRUE);
+	gtk_label_set_mnemonic_widget (label, widget);
+	gtk_grid_attach (GTK_GRID (container), widget, 1, 2, 1, 1);
+	gtk_widget_show (widget);
+
+	g_object_bind_property (
+		extension, "address",
+		widget, "text",
+		G_BINDING_BIDIRECTIONAL |
+		G_BINDING_SYNC_CREATE);
+
+	/* This entry affects the "check-complete" result. */
+	g_signal_connect_swapped (
+		widget, "changed",
+		G_CALLBACK (e_mail_config_page_changed), page);
+
+	/*** Optional Information ***/
+
+	widget = gtk_grid_new ();
+	gtk_grid_set_row_spacing (GTK_GRID (widget), 6);
+	gtk_grid_set_column_spacing (GTK_GRID (widget), 6);
+	gtk_box_pack_start (GTK_BOX (page), widget, FALSE, FALSE, 0);
+	gtk_widget_show (widget);
+
+	container = widget;
+
+	text = _("Optional Information");
+	markup = g_markup_printf_escaped ("<b>%s</b>", text);
+	widget = gtk_label_new (markup);
+	gtk_label_set_use_markup (GTK_LABEL (widget), TRUE);
+	gtk_misc_set_alignment (GTK_MISC (widget), 0.0, 0.5);
+	gtk_grid_attach (GTK_GRID (container), widget, 0, 0, 3, 1);
+	gtk_widget_show (widget);
+
+	text = _("Re_ply-To:");
+	widget = gtk_label_new_with_mnemonic (text);
+	gtk_widget_set_margin_left (widget, 12);
+	gtk_size_group_add_widget (size_group, widget);
+	gtk_misc_set_alignment (GTK_MISC (widget), 1.0, 0.5);
+	gtk_grid_attach (GTK_GRID (container), widget, 0, 1, 1, 1);
+	gtk_widget_show (widget);
+
+	label = GTK_LABEL (widget);
+
+	widget = gtk_entry_new ();
+	gtk_widget_set_hexpand (widget, TRUE);
+	gtk_label_set_mnemonic_widget (label, widget);
+	gtk_grid_attach (GTK_GRID (container), widget, 1, 1, 2, 1);
+	gtk_widget_show (widget);
+
+	g_object_bind_property (
+		extension, "reply-to",
+		widget, "text",
+		G_BINDING_BIDIRECTIONAL |
+		G_BINDING_SYNC_CREATE);
+
+	/* This entry affects the "check-complete" result. */
+	g_signal_connect_swapped (
+		widget, "changed",
+		G_CALLBACK (e_mail_config_page_changed), page);
+
+	text = _("Or_ganization:");
+	widget = gtk_label_new_with_mnemonic (text);
+	gtk_widget_set_margin_left (widget, 12);
+	gtk_size_group_add_widget (size_group, widget);
+	gtk_misc_set_alignment (GTK_MISC (widget), 1.0, 0.5);
+	gtk_grid_attach (GTK_GRID (container), widget, 0, 2, 1, 1);
+	gtk_widget_show (widget);
+
+	label = GTK_LABEL (widget);
+
+	widget = gtk_entry_new ();
+	gtk_widget_set_hexpand (widget, TRUE);
+	gtk_label_set_mnemonic_widget (label, widget);
+	gtk_grid_attach (GTK_GRID (container), widget, 1, 2, 2, 1);
+	gtk_widget_show (widget);
+
+	g_object_bind_property (
+		extension, "organization",
+		widget, "text",
+		G_BINDING_BIDIRECTIONAL |
+		G_BINDING_SYNC_CREATE);
+
+	text = _("Si_gnature:");
+	widget = gtk_label_new_with_mnemonic (text);
+	gtk_widget_set_margin_left (widget, 12);
+	gtk_size_group_add_widget (size_group, widget);
+	gtk_misc_set_alignment (GTK_MISC (widget), 1.0, 0.5);
+	gtk_grid_attach (GTK_GRID (container), widget, 0, 3, 1, 1);
+	gtk_widget_show (widget);
+
+	g_object_bind_property (
+		page, "show-signatures",
+		widget, "visible",
+		G_BINDING_SYNC_CREATE);
+
+	label = GTK_LABEL (widget);
+
+	widget = e_mail_signature_combo_box_new (registry);
+	gtk_widget_set_hexpand (widget, TRUE);
+	gtk_widget_set_halign (widget, GTK_ALIGN_START);
+	gtk_label_set_mnemonic_widget (label, widget);
+	gtk_grid_attach (GTK_GRID (container), widget, 1, 3, 1, 1);
+	gtk_widget_show (widget);
+
+	g_object_bind_property (
+		extension, "signature-uid",
+		widget, "active-id",
+		G_BINDING_BIDIRECTIONAL |
+		G_BINDING_SYNC_CREATE);
+
+	g_object_bind_property (
+		page, "show-signatures",
+		widget, "visible",
+		G_BINDING_SYNC_CREATE);
+
+	text = _("Add Ne_w Signature...");
+	widget = gtk_button_new_with_mnemonic (text);
+	gtk_grid_attach (GTK_GRID (container), widget, 2, 3, 1, 1);
+	gtk_widget_show (widget);
+
+	g_object_bind_property (
+		page, "show-signatures",
+		widget, "visible",
+		G_BINDING_SYNC_CREATE);
+
+	g_signal_connect (
+		widget, "clicked",
+		G_CALLBACK (mail_config_identity_page_add_signature_cb), page);
+
+	g_object_unref (size_group);
+}
+
+static gboolean
+mail_config_identity_page_check_complete (EMailConfigPage *page)
+{
+	EMailConfigIdentityPage *id_page;
+	ESource *source;
+	ESourceMailIdentity *extension;
+	const gchar *extension_name;
+	const gchar *name;
+	const gchar *address;
+	const gchar *reply_to;
+	const gchar *display_name;
+
+	id_page = E_MAIL_CONFIG_IDENTITY_PAGE (page);
+	extension_name = E_SOURCE_EXTENSION_MAIL_IDENTITY;
+	source = e_mail_config_identity_page_get_identity_source (id_page);
+	extension = e_source_get_extension (source, extension_name);
+
+	name = e_source_mail_identity_get_name (extension);
+	address = e_source_mail_identity_get_address (extension);
+	reply_to = e_source_mail_identity_get_reply_to (extension);
+
+	display_name = e_source_get_display_name (source);
+
+	if (name == NULL)
+		return FALSE;
+
+	if (address == NULL)
+		return FALSE;
+
+	if (!mail_config_identity_page_is_email (address))
+		return FALSE;
+
+	/* A NULL reply_to string is allowed. */
+	if (reply_to != NULL && !mail_config_identity_page_is_email (reply_to))
+		return FALSE;
+
+	/* Only enforce when account information is visible. */
+	if (e_mail_config_identity_page_get_show_account_info (id_page))
+		if (display_name == NULL || *display_name == '\0')
+			return FALSE;
+
+	return TRUE;
+}
+
+static void
+e_mail_config_identity_page_class_init (EMailConfigIdentityPageClass *class)
+{
+	GObjectClass *object_class;
+
+	g_type_class_add_private (
+		class, sizeof (EMailConfigIdentityPagePrivate));
+
+	object_class = G_OBJECT_CLASS (class);
+	object_class->set_property = mail_config_identity_page_set_property;
+	object_class->get_property = mail_config_identity_page_get_property;
+	object_class->dispose = mail_config_identity_page_dispose;
+	object_class->constructed = mail_config_identity_page_constructed;
+
+	g_object_class_install_property (
+		object_class,
+		PROP_REGISTRY,
+		g_param_spec_object (
+			"registry",
+			"Registry",
+			"Registry of data sources",
+			E_TYPE_SOURCE_REGISTRY,
+			G_PARAM_READWRITE |
+			G_PARAM_CONSTRUCT_ONLY |
+			G_PARAM_STATIC_STRINGS));
+
+	g_object_class_install_property (
+		object_class,
+		PROP_IDENTITY_SOURCE,
+		g_param_spec_object (
+			"identity-source",
+			"Identity Source",
+			"Mail identity source being edited",
+			E_TYPE_SOURCE,
+			G_PARAM_READWRITE |
+			G_PARAM_CONSTRUCT_ONLY |
+			G_PARAM_STATIC_STRINGS));
+
+	g_object_class_install_property (
+		object_class,
+		PROP_SHOW_ACCOUNT_INFO,
+		g_param_spec_boolean (
+			"show-account-info",
+			"Show Account Info",
+			"Show the \"Account Information\" section",
+			TRUE,
+			G_PARAM_READWRITE |
+			G_PARAM_CONSTRUCT |
+			G_PARAM_STATIC_STRINGS));
+
+	g_object_class_install_property (
+		object_class,
+		PROP_SHOW_INSTRUCTIONS,
+		g_param_spec_boolean (
+			"show-instructions",
+			"Show Instructions",
+			"Show helpful instructions",
+			TRUE,
+			G_PARAM_READWRITE |
+			G_PARAM_CONSTRUCT |
+			G_PARAM_STATIC_STRINGS));
+
+	g_object_class_install_property (
+		object_class,
+		PROP_SHOW_SIGNATURES,
+		g_param_spec_boolean (
+			"show-signatures",
+			"Show Signatures",
+			"Show mail signature options",
+			TRUE,
+			G_PARAM_READWRITE |
+			G_PARAM_CONSTRUCT |
+			G_PARAM_STATIC_STRINGS));
+}
+
+static void
+e_mail_config_identity_page_interface_init (EMailConfigPageInterface *interface)
+{
+	interface->title = _("Identity");
+	interface->sort_order = E_MAIL_CONFIG_IDENTITY_PAGE_SORT_ORDER;
+	interface->check_complete = mail_config_identity_page_check_complete;
+}
+
+static void
+e_mail_config_identity_page_init (EMailConfigIdentityPage *page)
+{
+	page->priv = E_MAIL_CONFIG_IDENTITY_PAGE_GET_PRIVATE (page);
+}
+
+EMailConfigPage *
+e_mail_config_identity_page_new (ESourceRegistry *registry,
+                                 ESource *identity_source)
+{
+	g_return_val_if_fail (E_IS_SOURCE_REGISTRY (registry), NULL);
+	g_return_val_if_fail (E_IS_SOURCE (identity_source), NULL);
+
+	return g_object_new (
+		E_TYPE_MAIL_CONFIG_IDENTITY_PAGE,
+		"registry", registry,
+		"identity-source", identity_source,
+		NULL);
+}
+
+ESourceRegistry *
+e_mail_config_identity_page_get_registry (EMailConfigIdentityPage *page)
+{
+	g_return_val_if_fail (E_IS_MAIL_CONFIG_IDENTITY_PAGE (page), NULL);
+
+	return page->priv->registry;
+}
+
+ESource *
+e_mail_config_identity_page_get_identity_source (EMailConfigIdentityPage *page)
+{
+	g_return_val_if_fail (E_IS_MAIL_CONFIG_IDENTITY_PAGE (page), NULL);
+
+	return page->priv->identity_source;
+}
+
+gboolean
+e_mail_config_identity_page_get_show_account_info (EMailConfigIdentityPage *page)
+{
+	g_return_val_if_fail (E_IS_MAIL_CONFIG_IDENTITY_PAGE (page), FALSE);
+
+	return page->priv->show_account_info;
+}
+
+void
+e_mail_config_identity_page_set_show_account_info (EMailConfigIdentityPage *page,
+                                                   gboolean show_account_info)
+{
+	g_return_if_fail (E_IS_MAIL_CONFIG_IDENTITY_PAGE (page));
+
+	page->priv->show_account_info = show_account_info;
+
+	g_object_notify (G_OBJECT (page), "show-account-info");
+}
+
+gboolean
+e_mail_config_identity_page_get_show_instructions (EMailConfigIdentityPage *page)
+{
+	g_return_val_if_fail (E_IS_MAIL_CONFIG_IDENTITY_PAGE (page), FALSE);
+
+	return page->priv->show_instructions;
+}
+
+void
+e_mail_config_identity_page_set_show_instructions (EMailConfigIdentityPage *page,
+                                                   gboolean show_instructions)
+{
+	g_return_if_fail (E_IS_MAIL_CONFIG_IDENTITY_PAGE (page));
+
+	page->priv->show_instructions = show_instructions;
+
+	g_object_notify (G_OBJECT (page), "show-instructions");
+}
+
+gboolean
+e_mail_config_identity_page_get_show_signatures (EMailConfigIdentityPage *page)
+{
+	g_return_val_if_fail (E_IS_MAIL_CONFIG_IDENTITY_PAGE (page), FALSE);
+
+	return page->priv->show_signatures;
+}
+
+void
+e_mail_config_identity_page_set_show_signatures (EMailConfigIdentityPage *page,
+                                                 gboolean show_signatures)
+{
+	g_return_if_fail (E_IS_MAIL_CONFIG_IDENTITY_PAGE (page));
+
+	page->priv->show_signatures = show_signatures;
+
+	g_object_notify (G_OBJECT (page), "show-signatures");
+}
+
diff --git a/mail/e-mail-config-identity-page.h b/mail/e-mail-config-identity-page.h
new file mode 100644
index 0000000..51d879e
--- /dev/null
+++ b/mail/e-mail-config-identity-page.h
@@ -0,0 +1,91 @@
+/*
+ * e-mail-config-identity-page.h
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) version 3.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with the program; if not, see <http://www.gnu.org/licenses/>
+ *
+ */
+
+#ifndef E_MAIL_CONFIG_IDENTITY_PAGE_H
+#define E_MAIL_CONFIG_IDENTITY_PAGE_H
+
+#include <gtk/gtk.h>
+#include <libedataserver/e-source-registry.h>
+
+#include <mail/e-mail-config-page.h>
+
+/* Standard GObject macros */
+#define E_TYPE_MAIL_CONFIG_IDENTITY_PAGE \
+	(e_mail_config_identity_page_get_type ())
+#define E_MAIL_CONFIG_IDENTITY_PAGE(obj) \
+	(G_TYPE_CHECK_INSTANCE_CAST \
+	((obj), E_TYPE_MAIL_CONFIG_IDENTITY_PAGE, EMailConfigIdentityPage))
+#define E_MAIL_CONFIG_IDENTITY_PAGE_CLASS(cls) \
+	(G_TYPE_CHECK_CLASS_CAST \
+	((cls), E_TYPE_MAIL_CONFIG_IDENTITY_PAGE, EMailConfigIdentityPageClass))
+#define E_IS_MAIL_CONFIG_IDENTITY_PAGE(obj) \
+	(G_TYPE_CHECK_INSTANCE_TYPE \
+	((obj), E_TYPE_MAIL_CONFIG_IDENTITY_PAGE))
+#define E_IS_MAIL_CONFIG_IDENTITY_PAGE_CLASS(cls) \
+	(G_TYPE_CHECK_CLASS_TYPE \
+	((cls), E_TYPE_MAIL_CONFIG_IDENTITY_PAGE))
+#define E_MAIL_CONFIG_IDENTITY_PAGE_GET_CLASS(obj) \
+	(G_TYPE_INSTANCE_GET_CLASS \
+	((obj), E_TYPE_MAIL_CONFIG_IDENTITY_PAGE, EMailConfigIdentityPageClass))
+
+#define E_MAIL_CONFIG_IDENTITY_PAGE_SORT_ORDER (100)
+
+G_BEGIN_DECLS
+
+typedef struct _EMailConfigIdentityPage EMailConfigIdentityPage;
+typedef struct _EMailConfigIdentityPageClass EMailConfigIdentityPageClass;
+typedef struct _EMailConfigIdentityPagePrivate EMailConfigIdentityPagePrivate;
+
+struct _EMailConfigIdentityPage {
+	GtkBox parent;
+	EMailConfigIdentityPagePrivate *priv;
+};
+
+struct _EMailConfigIdentityPageClass {
+	GtkBoxClass parent_class;
+};
+
+GType		e_mail_config_identity_page_get_type
+						(void) G_GNUC_CONST;
+EMailConfigPage *
+		e_mail_config_identity_page_new	(ESourceRegistry *registry,
+						 ESource *identity_source);
+ESourceRegistry *
+		e_mail_config_identity_page_get_registry
+						(EMailConfigIdentityPage *page);
+ESource *	e_mail_config_identity_page_get_identity_source
+						(EMailConfigIdentityPage *page);
+gboolean	e_mail_config_identity_page_get_show_account_info
+						(EMailConfigIdentityPage *page);
+void		e_mail_config_identity_page_set_show_account_info
+						(EMailConfigIdentityPage *page,
+						 gboolean show_account_info);
+gboolean	e_mail_config_identity_page_get_show_instructions
+						(EMailConfigIdentityPage *page);
+void		e_mail_config_identity_page_set_show_instructions
+						(EMailConfigIdentityPage *page,
+						 gboolean show_instructions);
+gboolean	e_mail_config_identity_page_get_show_signatures
+						(EMailConfigIdentityPage *page);
+void		e_mail_config_identity_page_set_show_signatures
+						(EMailConfigIdentityPage *page,
+						 gboolean show_signatures);
+
+G_END_DECLS
+
+#endif /* E_MAIL_CONFIG_IDENTITY_PAGE_H */
diff --git a/mail/e-mail-config-notebook.c b/mail/e-mail-config-notebook.c
new file mode 100644
index 0000000..c8df35e
--- /dev/null
+++ b/mail/e-mail-config-notebook.c
@@ -0,0 +1,676 @@
+/*
+ * e-mail-config-notebook.c
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) version 3.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with the program; if not, see <http://www.gnu.org/licenses/>
+ *
+ */
+
+#include "e-mail-config-notebook.h"
+
+#include <libebackend/e-extensible.h>
+
+#include <mail/e-mail-config-defaults-page.h>
+#include <mail/e-mail-config-identity-page.h>
+#include <mail/e-mail-config-provider-page.h>
+#include <mail/e-mail-config-receiving-page.h>
+#include <mail/e-mail-config-security-page.h>
+#include <mail/e-mail-config-sending-page.h>
+
+#define E_MAIL_CONFIG_NOTEBOOK_GET_PRIVATE(obj) \
+	(G_TYPE_INSTANCE_GET_PRIVATE \
+	((obj), E_TYPE_MAIL_CONFIG_NOTEBOOK, EMailConfigNotebookPrivate))
+
+typedef struct _AsyncContext AsyncContext;
+
+struct _EMailConfigNotebookPrivate {
+	EMailSession *session;
+	ESource *account_source;
+	ESource *identity_source;
+	ESource *transport_source;
+};
+
+struct _AsyncContext {
+	ESourceRegistry *registry;
+	GCancellable *cancellable;
+	GQueue *source_queue;
+};
+
+enum {
+	PROP_0,
+	PROP_ACCOUNT_SOURCE,
+	PROP_COMPLETE,
+	PROP_IDENTITY_SOURCE,
+	PROP_SESSION,
+	PROP_TRANSPORT_SOURCE
+};
+
+G_DEFINE_TYPE_WITH_CODE (
+	EMailConfigNotebook,
+	e_mail_config_notebook,
+	GTK_TYPE_NOTEBOOK,
+	G_IMPLEMENT_INTERFACE (
+		E_TYPE_EXTENSIBLE, NULL))
+
+static void
+async_context_free (AsyncContext *async_context)
+{
+	if (async_context->registry != NULL)
+		g_object_unref (async_context->registry);
+
+	if (async_context->cancellable != NULL)
+		g_object_unref (async_context->cancellable);
+
+	g_queue_free_full (
+		async_context->source_queue,
+		(GDestroyNotify) g_object_unref);
+
+	g_slice_free (AsyncContext, async_context);
+}
+
+static void
+mail_config_notebook_sort_pages (EMailConfigNotebook *notebook)
+{
+	GList *list, *link;
+	gint ii = 0;
+
+	list = g_list_sort (
+		gtk_container_get_children (GTK_CONTAINER (notebook)),
+		(GCompareFunc) e_mail_config_page_compare);
+
+	for (link = list; link != NULL; link = g_list_next (link))
+		gtk_notebook_reorder_child (
+			GTK_NOTEBOOK (notebook),
+			GTK_WIDGET (link->data), ii++);
+
+	g_list_free (list);
+}
+
+static void
+mail_config_notebook_page_changed (EMailConfigPage *page,
+                                   EMailConfigNotebook *notebook)
+{
+	g_object_notify (G_OBJECT (notebook), "complete");
+}
+
+static void
+mail_config_notebook_set_account_source (EMailConfigNotebook *notebook,
+                                         ESource *account_source)
+{
+	g_return_if_fail (E_IS_SOURCE (account_source));
+	g_return_if_fail (notebook->priv->account_source == NULL);
+
+	notebook->priv->account_source = g_object_ref (account_source);
+}
+
+static void
+mail_config_notebook_set_identity_source (EMailConfigNotebook *notebook,
+                                          ESource *identity_source)
+{
+	g_return_if_fail (E_IS_SOURCE (identity_source));
+	g_return_if_fail (notebook->priv->identity_source == NULL);
+
+	notebook->priv->identity_source = g_object_ref (identity_source);
+}
+
+static void
+mail_config_notebook_set_session (EMailConfigNotebook *notebook,
+                                  EMailSession *session)
+{
+	g_return_if_fail (E_IS_MAIL_SESSION (session));
+	g_return_if_fail (notebook->priv->session == NULL);
+
+	notebook->priv->session = g_object_ref (session);
+}
+
+static void
+mail_config_notebook_set_transport_source (EMailConfigNotebook *notebook,
+                                           ESource *transport_source)
+{
+	g_return_if_fail (E_IS_SOURCE (transport_source));
+	g_return_if_fail (notebook->priv->transport_source == NULL);
+
+	notebook->priv->transport_source = g_object_ref (transport_source);
+}
+
+static void
+mail_config_notebook_set_property (GObject *object,
+                                   guint property_id,
+                                   const GValue *value,
+                                   GParamSpec *pspec)
+{
+	switch (property_id) {
+		case PROP_ACCOUNT_SOURCE:
+			mail_config_notebook_set_account_source (
+				E_MAIL_CONFIG_NOTEBOOK (object),
+				g_value_get_object (value));
+			return;
+
+		case PROP_IDENTITY_SOURCE:
+			mail_config_notebook_set_identity_source (
+				E_MAIL_CONFIG_NOTEBOOK (object),
+				g_value_get_object (value));
+			return;
+
+		case PROP_SESSION:
+			mail_config_notebook_set_session (
+				E_MAIL_CONFIG_NOTEBOOK (object),
+				g_value_get_object (value));
+			return;
+
+		case PROP_TRANSPORT_SOURCE:
+			mail_config_notebook_set_transport_source (
+				E_MAIL_CONFIG_NOTEBOOK (object),
+				g_value_get_object (value));
+			return;
+	}
+
+	G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+}
+
+static void
+mail_config_notebook_get_property (GObject *object,
+                                   guint property_id,
+                                   GValue *value,
+                                   GParamSpec *pspec)
+{
+	switch (property_id) {
+		case PROP_ACCOUNT_SOURCE:
+			g_value_set_object (
+				value,
+				e_mail_config_notebook_get_account_source (
+				E_MAIL_CONFIG_NOTEBOOK (object)));
+			return;
+
+		case PROP_COMPLETE:
+			g_value_set_boolean (
+				value,
+				e_mail_config_notebook_check_complete (
+				E_MAIL_CONFIG_NOTEBOOK (object)));
+			return;
+
+		case PROP_IDENTITY_SOURCE:
+			g_value_set_object (
+				value,
+				e_mail_config_notebook_get_identity_source (
+				E_MAIL_CONFIG_NOTEBOOK (object)));
+			return;
+
+		case PROP_SESSION:
+			g_value_set_object (
+				value,
+				e_mail_config_notebook_get_session (
+				E_MAIL_CONFIG_NOTEBOOK (object)));
+			return;
+
+		case PROP_TRANSPORT_SOURCE:
+			g_value_set_object (
+				value,
+				e_mail_config_notebook_get_transport_source (
+				E_MAIL_CONFIG_NOTEBOOK (object)));
+			return;
+	}
+
+	G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+}
+
+static void
+mail_config_notebook_dispose (GObject *object)
+{
+	EMailConfigNotebookPrivate *priv;
+
+	priv = E_MAIL_CONFIG_NOTEBOOK_GET_PRIVATE (object);
+
+	if (priv->session != NULL) {
+		g_object_ref (priv->session);
+		priv->session = NULL;
+	}
+
+	if (priv->account_source != NULL) {
+		g_object_ref (priv->account_source);
+		priv->account_source = NULL;
+	}
+
+	if (priv->identity_source != NULL) {
+		g_object_ref (priv->identity_source);
+		priv->identity_source = NULL;
+	}
+
+	if (priv->transport_source != NULL) {
+		g_object_ref (priv->transport_source);
+		priv->transport_source = NULL;
+	}
+
+	/* Chain up to parent's dispose() method. */
+	G_OBJECT_CLASS (e_mail_config_notebook_parent_class)->
+		dispose (object);
+}
+
+static void
+mail_config_notebook_constructed (GObject *object)
+{
+	EMailConfigNotebook *notebook;
+	ESourceRegistry *registry;
+	CamelProvider *provider;
+	EMailSession *session;
+	EMailConfigPage *page;
+
+	notebook = E_MAIL_CONFIG_NOTEBOOK (object);
+
+	/* Chain up to parent's constructed() method. */
+	G_OBJECT_CLASS (e_mail_config_notebook_parent_class)->
+		constructed (object);
+
+	session = e_mail_config_notebook_get_session (notebook);
+	registry = e_mail_session_get_registry (session);
+
+	/*** Identity Page ***/
+
+	page = e_mail_config_identity_page_new (
+		registry, notebook->priv->identity_source);
+	e_mail_config_identity_page_set_show_instructions (
+		E_MAIL_CONFIG_IDENTITY_PAGE (page), FALSE);
+	e_mail_config_notebook_add_page (notebook, page);
+
+	/*** Receiving Page ***/
+
+	page = e_mail_config_receiving_page_new (registry);
+	e_mail_config_service_page_add_scratch_source (
+		E_MAIL_CONFIG_SERVICE_PAGE (page),
+		notebook->priv->account_source);
+	e_mail_config_notebook_add_page (notebook, page);
+
+	provider = e_mail_config_service_page_get_provider (
+		E_MAIL_CONFIG_SERVICE_PAGE (page),
+		notebook->priv->account_source);
+
+	/*** Receiving Options (conditional) ***/
+
+	/* Note: We exclude this page if it has no options,
+	 *       but we don't know that until we create it. */
+	page = e_mail_config_provider_page_new (
+		notebook->priv->account_source);
+	if (e_mail_config_provider_page_is_empty (
+			E_MAIL_CONFIG_PROVIDER_PAGE (page))) {
+		g_object_unref (g_object_ref_sink (page));
+	} else {
+		e_mail_config_notebook_add_page (notebook, page);
+	}
+
+	/*** Sending Page (conditional) ***/
+
+	if (!CAMEL_PROVIDER_IS_STORE_AND_TRANSPORT (provider)) {
+		page = e_mail_config_sending_page_new (registry);
+		e_mail_config_service_page_add_scratch_source (
+			E_MAIL_CONFIG_SERVICE_PAGE (page),
+			notebook->priv->transport_source);
+		e_mail_config_notebook_add_page (notebook, page);
+	}
+
+	/*** Defaults Page ***/
+
+	page = e_mail_config_defaults_page_new (
+		session,
+		notebook->priv->account_source,
+		notebook->priv->identity_source);
+	e_mail_config_notebook_add_page (notebook, page);
+
+	/*** Security Page ***/
+
+	page = e_mail_config_security_page_new (
+		notebook->priv->identity_source);
+	e_mail_config_notebook_add_page (notebook, page);
+
+	e_extensible_load_extensions (E_EXTENSIBLE (notebook));
+}
+
+static void
+mail_config_notebook_page_removed (GtkNotebook *notebook,
+                                   GtkWidget *child,
+                                   guint page_num)
+{
+	/* Do not chain up.  GtkNotebook does not implement this method. */
+
+	if (E_IS_MAIL_CONFIG_PAGE (child))
+		g_signal_handlers_disconnect_by_func (
+			child, mail_config_notebook_page_changed,
+			E_MAIL_CONFIG_NOTEBOOK (notebook));
+}
+
+static void
+mail_config_notebook_page_added (GtkNotebook *notebook,
+                                 GtkWidget *child,
+                                 guint page_num)
+{
+	/* Do not chain up.  GtkNotebook does not implement this method. */
+
+	if (E_IS_MAIL_CONFIG_PAGE (child))
+		g_signal_connect (
+			child, "changed",
+			G_CALLBACK (mail_config_notebook_page_changed),
+			E_MAIL_CONFIG_NOTEBOOK (notebook));
+}
+
+static void
+e_mail_config_notebook_class_init (EMailConfigNotebookClass *class)
+{
+	GObjectClass *object_class;
+	GtkNotebookClass *notebook_class;
+
+	g_type_class_add_private (class, sizeof (EMailConfigNotebookPrivate));
+
+	object_class = G_OBJECT_CLASS (class);
+	object_class->set_property = mail_config_notebook_set_property;
+	object_class->get_property = mail_config_notebook_get_property;
+	object_class->dispose = mail_config_notebook_dispose;
+	object_class->constructed = mail_config_notebook_constructed;
+
+	notebook_class = GTK_NOTEBOOK_CLASS (class);
+	notebook_class->page_removed = mail_config_notebook_page_removed;
+	notebook_class->page_added = mail_config_notebook_page_added;
+
+	g_object_class_install_property (
+		object_class,
+		PROP_ACCOUNT_SOURCE,
+		g_param_spec_object (
+			"account-source",
+			"Account Source",
+			"Mail account source being edited",
+			E_TYPE_SOURCE,
+			G_PARAM_READWRITE |
+			G_PARAM_CONSTRUCT_ONLY |
+			G_PARAM_STATIC_STRINGS));
+
+	g_object_class_install_property (
+		object_class,
+		PROP_COMPLETE,
+		g_param_spec_boolean (
+			"complete",
+			"Complete",
+			"Whether all required fields are complete",
+			FALSE,  /* default is not used */
+			G_PARAM_READABLE |
+			G_PARAM_STATIC_STRINGS));
+
+	g_object_class_install_property (
+		object_class,
+		PROP_IDENTITY_SOURCE,
+		g_param_spec_object (
+			"identity-source",
+			"Identity Source",
+			"Mail identity source being edited",
+			E_TYPE_SOURCE,
+			G_PARAM_READWRITE |
+			G_PARAM_CONSTRUCT_ONLY |
+			G_PARAM_STATIC_STRINGS));
+
+	g_object_class_install_property (
+		object_class,
+		PROP_SESSION,
+		g_param_spec_object (
+			"session",
+			"Session",
+			"Mail session",
+			E_TYPE_MAIL_SESSION,
+			G_PARAM_READWRITE |
+			G_PARAM_CONSTRUCT_ONLY |
+			G_PARAM_STATIC_STRINGS));
+
+	g_object_class_install_property (
+		object_class,
+		PROP_TRANSPORT_SOURCE,
+		g_param_spec_object (
+			"transport-source",
+			"Transport Source",
+			"Mail transport source being edited",
+			E_TYPE_SOURCE,
+			G_PARAM_READWRITE |
+			G_PARAM_CONSTRUCT_ONLY |
+			G_PARAM_STATIC_STRINGS));
+}
+
+static void
+e_mail_config_notebook_init (EMailConfigNotebook *notebook)
+{
+	notebook->priv = E_MAIL_CONFIG_NOTEBOOK_GET_PRIVATE (notebook);
+}
+
+GtkWidget *
+e_mail_config_notebook_new (EMailSession *session,
+                            ESource *account_source,
+                            ESource *identity_source,
+                            ESource *transport_source)
+{
+	g_return_val_if_fail (E_IS_MAIL_SESSION (session), NULL);
+	g_return_val_if_fail (E_IS_SOURCE (account_source), NULL);
+	g_return_val_if_fail (E_IS_SOURCE (identity_source), NULL);
+	g_return_val_if_fail (E_IS_SOURCE (transport_source), NULL);
+
+	return g_object_new (
+		E_TYPE_MAIL_CONFIG_NOTEBOOK,
+		"session", session,
+		"account-source", account_source,
+		"identity-source", identity_source,
+		"transport-source", transport_source,
+		NULL);
+}
+
+EMailSession *
+e_mail_config_notebook_get_session (EMailConfigNotebook *notebook)
+{
+	g_return_val_if_fail (E_IS_MAIL_CONFIG_NOTEBOOK (notebook), NULL);
+
+	return notebook->priv->session;
+}
+
+ESource *
+e_mail_config_notebook_get_account_source (EMailConfigNotebook *notebook)
+{
+	g_return_val_if_fail (E_IS_MAIL_CONFIG_NOTEBOOK (notebook), NULL);
+
+	return notebook->priv->account_source;
+}
+
+ESource *
+e_mail_config_notebook_get_identity_source (EMailConfigNotebook *notebook)
+{
+	g_return_val_if_fail (E_IS_MAIL_CONFIG_NOTEBOOK (notebook), NULL);
+
+	return notebook->priv->identity_source;
+}
+
+ESource *
+e_mail_config_notebook_get_transport_source (EMailConfigNotebook *notebook)
+{
+	g_return_val_if_fail (E_IS_MAIL_CONFIG_NOTEBOOK (notebook), NULL);
+
+	return notebook->priv->transport_source;
+}
+
+void
+e_mail_config_notebook_add_page (EMailConfigNotebook *notebook,
+                                 EMailConfigPage *page)
+{
+	EMailConfigPageInterface *page_interface;
+	GtkWidget *tab_label;
+
+	g_return_if_fail (E_IS_MAIL_CONFIG_NOTEBOOK (notebook));
+	g_return_if_fail (E_IS_MAIL_CONFIG_PAGE (page));
+
+	page_interface = E_MAIL_CONFIG_PAGE_GET_INTERFACE (page);
+	tab_label = gtk_label_new (page_interface->title);
+
+	gtk_widget_show (GTK_WIDGET (page));
+
+	gtk_notebook_append_page (
+		GTK_NOTEBOOK (notebook),
+		GTK_WIDGET (page), tab_label);
+
+	mail_config_notebook_sort_pages (notebook);
+}
+
+gboolean
+e_mail_config_notebook_check_complete (EMailConfigNotebook *notebook)
+{
+	GList *list, *link;
+	gboolean complete = TRUE;
+
+	g_return_val_if_fail (E_IS_MAIL_CONFIG_NOTEBOOK (notebook), FALSE);
+
+	list = gtk_container_get_children (GTK_CONTAINER (notebook));
+
+	for (link = list; link != NULL; link = g_list_next (link)) {
+		if (E_IS_MAIL_CONFIG_PAGE (link->data)) {
+			EMailConfigPage *page;
+			page = E_MAIL_CONFIG_PAGE (link->data);
+			complete = e_mail_config_page_check_complete (page);
+
+			if (!complete)
+				break;
+		}
+	}
+
+	g_list_free (list);
+
+	return complete;
+}
+
+/********************** e_mail_config_notebook_commit() **********************/
+
+static void
+mail_config_notebook_commit_cb (GObject *object,
+                                GAsyncResult *result,
+                                gpointer user_data)
+{
+	GSimpleAsyncResult *simple;
+	AsyncContext *async_context;
+	ESource *next_source;
+	GError *error = NULL;
+
+	simple = G_SIMPLE_ASYNC_RESULT (user_data);
+	async_context = g_simple_async_result_get_op_res_gpointer (simple);
+
+	e_source_registry_commit_source_finish (
+		E_SOURCE_REGISTRY (object), result, NULL, &error);
+
+	if (error != NULL) {
+		g_simple_async_result_take_error (simple, error);
+		g_simple_async_result_complete (simple);
+		g_object_unref (simple);
+		return;
+	}
+
+	next_source = g_queue_pop_head (async_context->source_queue);
+
+	if (next_source == NULL) {
+		g_simple_async_result_complete (simple);
+		g_object_unref (simple);
+		return;
+	}
+
+	e_source_registry_commit_source (
+		async_context->registry, next_source,
+		async_context->cancellable,
+		mail_config_notebook_commit_cb, simple);
+
+	g_object_unref (next_source);
+}
+
+void
+e_mail_config_notebook_commit (EMailConfigNotebook *notebook,
+                               GCancellable *cancellable,
+                               GAsyncReadyCallback callback,
+                               gpointer user_data)
+{
+	GSimpleAsyncResult *simple;
+	AsyncContext *async_context;
+	ESourceRegistry *registry;
+	EMailSession *session;
+	ESource *source;
+	GList *list, *link;
+	GQueue *queue;
+
+	g_return_if_fail (E_IS_MAIL_CONFIG_NOTEBOOK (notebook));
+
+	session = e_mail_config_notebook_get_session (notebook);
+	registry = e_mail_session_get_registry (session);
+
+	queue = g_queue_new ();
+
+	/* Queue the three main data sources for the account. */
+	source = e_mail_config_notebook_get_account_source (notebook);
+	g_queue_push_tail (queue, g_object_ref (source));
+	source = e_mail_config_notebook_get_identity_source (notebook);
+	g_queue_push_tail (queue, g_object_ref (source));
+	source = e_mail_config_notebook_get_transport_source (notebook);
+	g_queue_push_tail (queue, g_object_ref (source));
+
+	list = gtk_container_get_children (GTK_CONTAINER (notebook));
+
+	/* Tell all EMailConfigPages to commit their UI state to their
+	 * scratch ESources and push any additional data sources on to
+	 * the given source queue, such as calendars or address books
+	 * to be bundled with the mail account. */
+	for (link = list; link != NULL; link = g_list_next (link)) {
+		if (E_IS_MAIL_CONFIG_PAGE (link->data)) {
+			EMailConfigPage *page;
+			page = E_MAIL_CONFIG_PAGE (link->data);
+			e_mail_config_page_commit_changes (page, queue);
+		}
+	}
+
+	g_list_free (list);
+
+	async_context = g_slice_new0 (AsyncContext);
+	async_context->registry = g_object_ref (registry);
+	async_context->source_queue = queue;  /* takes ownership */
+
+	if (G_IS_CANCELLABLE (cancellable))
+		async_context->cancellable = g_object_ref (cancellable);
+
+	simple = g_simple_async_result_new (
+		G_OBJECT (notebook), callback, user_data,
+		e_mail_config_notebook_commit);
+
+	g_simple_async_result_set_op_res_gpointer (
+		simple, async_context, (GDestroyNotify) async_context_free);
+
+	source = g_queue_pop_head (async_context->source_queue);
+	g_return_if_fail (E_IS_SOURCE (source));
+
+	e_source_registry_commit_source (
+		async_context->registry, source,
+		async_context->cancellable,
+		mail_config_notebook_commit_cb, simple);
+
+	g_object_unref (source);
+}
+
+gboolean
+e_mail_config_notebook_commit_finish (EMailConfigNotebook *notebook,
+                                      GAsyncResult *result,
+                                      GError **error)
+{
+	GSimpleAsyncResult *simple;
+
+	g_return_val_if_fail (
+		g_simple_async_result_is_valid (
+		result, G_OBJECT (notebook),
+		e_mail_config_notebook_commit), FALSE);
+
+	simple = G_SIMPLE_ASYNC_RESULT (result);
+
+	/* Assume success unless a GError is set. */
+	return !g_simple_async_result_propagate_error (simple, error);
+}
+
diff --git a/mail/e-mail-config-notebook.h b/mail/e-mail-config-notebook.h
new file mode 100644
index 0000000..1d92ef8
--- /dev/null
+++ b/mail/e-mail-config-notebook.h
@@ -0,0 +1,95 @@
+/*
+ * e-mail-config-notebook.h
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) version 3.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with the program; if not, see <http://www.gnu.org/licenses/>
+ *
+ */
+
+#ifndef E_MAIL_CONFIG_NOTEBOOK_H
+#define E_MAIL_CONFIG_NOTEBOOK_H
+
+#include <gtk/gtk.h>
+
+#include <libemail-engine/e-mail-session.h>
+
+#include <mail/e-mail-config-page.h>
+
+/* Standard GObject macros */
+#define E_TYPE_MAIL_CONFIG_NOTEBOOK \
+	(e_mail_config_notebook_get_type ())
+#define E_MAIL_CONFIG_NOTEBOOK(obj) \
+	(G_TYPE_CHECK_INSTANCE_CAST \
+	((obj), E_TYPE_MAIL_CONFIG_NOTEBOOK, EMailConfigNotebook))
+#define E_MAIL_CONFIG_NOTEBOOK_CLASS(cls) \
+	(G_TYPE_CHECK_CLASS_CAST \
+	((cls), E_TYPE_MAIL_CONFIG_NOTEBOOK, EMailConfigNotebookClass))
+#define E_IS_MAIL_CONFIG_NOTEBOOK(obj) \
+	(G_TYPE_CHECK_INSTANCE_TYPE \
+	((obj), E_TYPE_MAIL_CONFIG_NOTEBOOK))
+#define E_IS_MAIL_CONFIG_NOTEBOOK_CLASS(cls) \
+	(G_TYPE_CHECK_CLASS_TYPE \
+	((cls), E_TYPE_MAIL_CONFIG_NOTEBOOK))
+#define E_MAIL_CONFIG_NOTEBOOK_GET_CLASS(obj) \
+	(G_TYPE_INSTANCE_GET_CLASS \
+	((obj), E_TYPE_MAIL_CONFIG_NOTEBOOK, EMailConfigNotebookClass))
+
+G_BEGIN_DECLS
+
+typedef struct _EMailConfigNotebook EMailConfigNotebook;
+typedef struct _EMailConfigNotebookClass EMailConfigNotebookClass;
+typedef struct _EMailConfigNotebookPrivate EMailConfigNotebookPrivate;
+
+struct _EMailConfigNotebook {
+	GtkNotebook parent;
+	EMailConfigNotebookPrivate *priv;
+};
+
+struct _EMailConfigNotebookClass {
+	GtkNotebookClass parent_class;
+};
+
+GType		e_mail_config_notebook_get_type
+					(void) G_GNUC_CONST;
+GtkWidget *	e_mail_config_notebook_new
+					(EMailSession *session,
+					 ESource *account_source,
+					 ESource *identity_source,
+					 ESource *transport_source);
+EMailSession *	e_mail_config_notebook_get_session
+					(EMailConfigNotebook *notebook);
+ESource *	e_mail_config_notebook_get_account_source
+					(EMailConfigNotebook *notebook);
+ESource *	e_mail_config_notebook_get_identity_source
+					(EMailConfigNotebook *notebook);
+ESource *	e_mail_config_notebook_get_transport_source
+					(EMailConfigNotebook *notebook);
+void		e_mail_config_notebook_add_page
+					(EMailConfigNotebook *notebook,
+					 EMailConfigPage *page);
+gboolean	e_mail_config_notebook_check_complete
+					(EMailConfigNotebook *notebook);
+void		e_mail_config_notebook_commit
+					(EMailConfigNotebook *notebook,
+					 GCancellable *cancellable,
+					 GAsyncReadyCallback callback,
+					 gpointer user_data);
+gboolean	e_mail_config_notebook_commit_finish
+					(EMailConfigNotebook *notebook,
+					 GAsyncResult *result,
+					 GError **error);
+
+G_END_DECLS
+
+#endif /* E_MAIL_CONFIG_NOTEBOOK_H */
+
diff --git a/mail/e-mail-config-page.c b/mail/e-mail-config-page.c
new file mode 100644
index 0000000..96966e8
--- /dev/null
+++ b/mail/e-mail-config-page.c
@@ -0,0 +1,158 @@
+/*
+ * e-mail-config-page.c
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) version 3.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with the program; if not, see <http://www.gnu.org/licenses/>
+ *
+ */
+
+#include "e-mail-config-page.h"
+
+#include <config.h>
+#include <glib/gi18n-lib.h>
+
+#include <e-util/e-marshal.h>
+
+enum {
+	CHANGED,
+	CHECK_COMPLETE,
+	COMMIT_CHANGES,
+	LAST_SIGNAL
+};
+
+static gulong signals[LAST_SIGNAL];
+
+G_DEFINE_INTERFACE (
+	EMailConfigPage,
+	e_mail_config_page,
+	GTK_TYPE_WIDGET)
+
+static gboolean
+mail_config_page_check_complete (EMailConfigPage *page)
+{
+	return TRUE;
+}
+
+static gboolean
+mail_config_page_check_complete_accumulator (GSignalInvocationHint *ihint,
+                                             GValue *return_accu,
+                                             const GValue *handler_return,
+                                             gpointer unused)
+{
+	gboolean v_boolean;
+
+	/* Abort emission if a handler returns FALSE. */
+	v_boolean = g_value_get_boolean (handler_return);
+	g_value_set_boolean (return_accu, v_boolean);
+
+	return v_boolean;
+}
+
+static void
+e_mail_config_page_default_init (EMailConfigPageInterface *interface)
+{
+	interface->title = _("Untitled");
+	interface->page_type = GTK_ASSISTANT_PAGE_CONTENT;
+
+	interface->check_complete = mail_config_page_check_complete;
+
+	signals[CHANGED] = g_signal_new (
+		"changed",
+		G_TYPE_FROM_INTERFACE (interface),
+		G_SIGNAL_RUN_LAST,
+		G_STRUCT_OFFSET (EMailConfigPageInterface, changed),
+		NULL, NULL,
+		g_cclosure_marshal_VOID__VOID,
+		G_TYPE_NONE, 0);
+
+	signals[CHECK_COMPLETE] = g_signal_new (
+		"check-complete",
+		G_TYPE_FROM_INTERFACE (interface),
+		G_SIGNAL_RUN_LAST,
+		G_STRUCT_OFFSET (EMailConfigPageInterface, check_complete),
+		mail_config_page_check_complete_accumulator, NULL,
+		e_marshal_BOOLEAN__VOID,
+		G_TYPE_BOOLEAN, 0);
+
+	signals[COMMIT_CHANGES] = g_signal_new (
+		"commit-changes",
+		G_TYPE_FROM_INTERFACE (interface),
+		G_SIGNAL_RUN_LAST,
+		G_STRUCT_OFFSET (EMailConfigPageInterface, commit_changes),
+		NULL, NULL,
+		g_cclosure_marshal_VOID__POINTER,
+		G_TYPE_NONE, 1,
+		G_TYPE_POINTER);
+}
+
+void
+e_mail_config_page_changed (EMailConfigPage *page)
+{
+	g_return_if_fail (E_IS_MAIL_CONFIG_PAGE (page));
+
+	g_signal_emit (page, signals[CHANGED], 0);
+}
+
+gboolean
+e_mail_config_page_check_complete (EMailConfigPage *page)
+{
+	gboolean complete;
+
+	g_return_val_if_fail (E_IS_MAIL_CONFIG_PAGE (page), FALSE);
+
+	g_signal_emit (page, signals[CHECK_COMPLETE], 0, &complete);
+
+	return complete;
+}
+
+void
+e_mail_config_page_commit_changes (EMailConfigPage *page,
+                                   GQueue *source_queue)
+{
+	g_return_if_fail (E_IS_MAIL_CONFIG_PAGE (page));
+	g_return_if_fail (source_queue != NULL);
+
+	g_signal_emit (page, signals[COMMIT_CHANGES], 0, source_queue);
+}
+
+gint
+e_mail_config_page_compare (GtkWidget *page_a,
+                            GtkWidget *page_b)
+{
+	EMailConfigPageInterface *interface_a = NULL;
+	EMailConfigPageInterface *interface_b = NULL;
+
+	if (E_IS_MAIL_CONFIG_PAGE (page_a))
+		interface_a = E_MAIL_CONFIG_PAGE_GET_INTERFACE (page_a);
+
+	if (E_IS_MAIL_CONFIG_PAGE (page_b))
+		interface_b = E_MAIL_CONFIG_PAGE_GET_INTERFACE (page_b);
+
+	if (interface_a == interface_b)
+		return 0;
+
+	if (interface_a != NULL && interface_b == NULL)
+		return -1;
+
+	if (interface_a == NULL && interface_b != NULL)
+		return 1;
+
+	if (interface_a->sort_order < interface_b->sort_order)
+		return -1;
+
+	if (interface_a->sort_order > interface_b->sort_order)
+		return 1;
+
+	return 0;
+}
+
diff --git a/mail/e-mail-config-page.h b/mail/e-mail-config-page.h
new file mode 100644
index 0000000..c7f4fae
--- /dev/null
+++ b/mail/e-mail-config-page.h
@@ -0,0 +1,69 @@
+/*
+ * e-mail-config-page.h
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) version 3.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with the program; if not, see <http://www.gnu.org/licenses/>
+ *
+ */
+
+#ifndef E_MAIL_CONFIG_PAGE_H
+#define E_MAIL_CONFIG_PAGE_H
+
+#include <gtk/gtk.h>
+
+/* Standard GObject macros */
+#define E_TYPE_MAIL_CONFIG_PAGE \
+	(e_mail_config_page_get_type ())
+#define E_MAIL_CONFIG_PAGE(obj) \
+	(G_TYPE_CHECK_INSTANCE_CAST \
+	((obj), E_TYPE_MAIL_CONFIG_PAGE, EMailConfigPage))
+#define E_IS_MAIL_CONFIG_PAGE(obj) \
+	(G_TYPE_CHECK_INSTANCE_TYPE \
+	((obj), E_TYPE_MAIL_CONFIG_PAGE))
+#define E_MAIL_CONFIG_PAGE_GET_INTERFACE(obj) \
+	(G_TYPE_INSTANCE_GET_INTERFACE \
+	((obj), E_TYPE_MAIL_CONFIG_PAGE, EMailConfigPageInterface))
+
+G_BEGIN_DECLS
+
+typedef struct _EMailConfigPage EMailConfigPage;
+typedef struct _EMailConfigPageInterface EMailConfigPageInterface;
+
+struct _EMailConfigPageInterface {
+	GTypeInterface parent_interface;
+
+	gint sort_order;
+	const gchar *title;
+	GtkAssistantPageType page_type;
+
+	/* Signals */
+	void		(*changed)		(EMailConfigPage *page);
+	gboolean	(*check_complete)	(EMailConfigPage *page);
+	void		(*commit_changes)	(EMailConfigPage *page,
+						 GQueue *source_queue);
+};
+
+GType		e_mail_config_page_get_type	(void) G_GNUC_CONST;
+void		e_mail_config_page_changed	(EMailConfigPage *page);
+gboolean	e_mail_config_page_check_complete
+						(EMailConfigPage *page);
+void		e_mail_config_page_commit_changes
+						(EMailConfigPage *page,
+						 GQueue *source_queue);
+gint		e_mail_config_page_compare	(GtkWidget *page_a,
+						 GtkWidget *page_b);
+
+G_END_DECLS
+
+#endif /* E_MAIL_CONFIG_PAGE_H */
+
diff --git a/mail/e-mail-config-provider-page.c b/mail/e-mail-config-provider-page.c
new file mode 100644
index 0000000..5604e22
--- /dev/null
+++ b/mail/e-mail-config-provider-page.c
@@ -0,0 +1,660 @@
+/*
+ * e-mail-config-provider-page.c
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) version 3.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with the program; if not, see <http://www.gnu.org/licenses/>
+ *
+ */
+
+#include "e-mail-config-provider-page.h"
+
+#include <config.h>
+#include <string.h>
+#include <glib/gi18n-lib.h>
+
+#include <camel/camel.h>
+#include <libedataserver/e-source-camel.h>
+#include <libedataserver/e-source-mail-account.h>
+#include <libedataserver/e-data-server-util.h>
+
+#define E_MAIL_CONFIG_PROVIDER_PAGE_GET_PRIVATE(obj) \
+	(G_TYPE_INSTANCE_GET_PRIVATE \
+	((obj), E_TYPE_MAIL_CONFIG_PROVIDER_PAGE, EMailConfigProviderPagePrivate))
+
+#define STANDARD_MARGIN   12
+#define DEPENDENCY_MARGIN 24
+
+struct _EMailConfigProviderPagePrivate {
+	ESource *scratch_source;
+	CamelProvider *provider;
+	CamelSettings *settings;
+	gboolean is_empty;
+};
+
+enum {
+	PROP_0,
+	PROP_SCRATCH_SOURCE
+};
+
+/* Forward Declarations */
+static void	e_mail_config_provider_page_interface_init
+					(EMailConfigPageInterface *interface);
+
+G_DEFINE_TYPE_WITH_CODE (
+	EMailConfigProviderPage,
+	e_mail_config_provider_page,
+	GTK_TYPE_BOX,
+	G_IMPLEMENT_INTERFACE (
+		E_TYPE_MAIL_CONFIG_PAGE,
+		e_mail_config_provider_page_interface_init))
+
+static void
+mail_config_provider_page_handle_dependency (EMailConfigProviderPage *page,
+                                             CamelProviderConfEntry *entry,
+                                             GtkWidget *widget)
+{
+	GBindingFlags binding_flags = G_BINDING_SYNC_CREATE;
+	const gchar *depname = entry->depname;
+	gint margin;
+
+	if (depname == NULL)
+		return;
+
+	if (*depname == '!') {
+		binding_flags |= G_BINDING_INVERT_BOOLEAN;
+		depname++;
+	}
+
+	g_object_bind_property (
+		page->priv->settings, depname,
+		widget, "sensitive",
+		binding_flags);
+
+	/* Further indent the widget to show its dependency. */
+	margin = gtk_widget_get_margin_left (widget);
+	gtk_widget_set_margin_left (widget, margin + DEPENDENCY_MARGIN);
+}
+
+static void
+mail_config_provider_page_add_section (EMailConfigProviderPage *page,
+                                       CamelProviderConfEntry *entry)
+{
+	GtkWidget *widget;
+	gchar *markup;
+
+	g_return_if_fail (entry->text != NULL);
+
+	markup = g_markup_printf_escaped ("<b>%s</b>", entry->text);
+
+	widget = gtk_label_new (markup);
+	gtk_label_set_use_markup (GTK_LABEL (widget), TRUE);
+	gtk_misc_set_alignment (GTK_MISC (widget), 0.0, 0.5);
+	gtk_box_pack_start (GTK_BOX (page), widget, FALSE, FALSE, 0);
+	gtk_widget_show (widget);
+
+	/* Skip the top margin if this is the first entry. */
+	if (entry != page->priv->provider->extra_conf)
+		gtk_widget_set_margin_top (widget, 6);
+
+	g_free (markup);
+}
+
+static void
+mail_config_provider_page_add_checkbox (EMailConfigProviderPage *page,
+                                        CamelProviderConfEntry *entry)
+{
+	GtkWidget *widget;
+
+	g_return_if_fail (entry->text != NULL);
+
+	widget = gtk_check_button_new_with_mnemonic (entry->text);
+	gtk_widget_set_margin_left (widget, STANDARD_MARGIN);
+	gtk_box_pack_start (GTK_BOX (page), widget, FALSE, FALSE, 0);
+	gtk_widget_show (widget);
+
+	g_object_bind_property (
+		page->priv->settings, entry->name,
+		widget, "active",
+		G_BINDING_BIDIRECTIONAL |
+		G_BINDING_SYNC_CREATE);
+
+	mail_config_provider_page_handle_dependency (page, entry, widget);
+}
+
+static void
+mail_config_provider_page_add_checkspin (EMailConfigProviderPage *page,
+                                         CamelProviderConfEntry *entry)
+{
+	GObjectClass *class;
+	GParamSpec *pspec;
+	GParamSpec *use_pspec;
+	GtkAdjustment *adjustment;
+	GtkWidget *hbox, *spin;
+	GtkWidget *prefix;
+	gchar *use_property_name;
+	gchar *pre, *post;
+
+	g_return_if_fail (entry->text != NULL);
+
+	/* The entry->name property (e.g. "foo") should be numeric for the
+	 * spin button.  If a "use" boolean property exists (e.g. "use-foo")
+	 * then a checkbox is also shown. */
+
+	class = G_OBJECT_GET_CLASS (page->priv->settings);
+	pspec = g_object_class_find_property (class, entry->name);
+	g_return_if_fail (pspec != NULL);
+
+	use_property_name = g_strconcat ("use-", entry->name, NULL);
+	use_pspec = g_object_class_find_property (class, use_property_name);
+	if (use_pspec != NULL && use_pspec->value_type != G_TYPE_BOOLEAN)
+		use_pspec = NULL;
+	g_free (use_property_name);
+
+	/* Make sure we can convert to and from doubles. */
+	g_return_if_fail (
+		g_value_type_transformable (
+		pspec->value_type, G_TYPE_DOUBLE));
+	g_return_if_fail (
+		g_value_type_transformable (
+		G_TYPE_DOUBLE, pspec->value_type));
+
+	if (G_IS_PARAM_SPEC_CHAR (pspec)) {
+		GParamSpecChar *pspec_char;
+		pspec_char = G_PARAM_SPEC_CHAR (pspec);
+		adjustment = gtk_adjustment_new (
+			(gdouble) pspec_char->default_value,
+			(gdouble) pspec_char->minimum,
+			(gdouble) pspec_char->maximum,
+			1.0, 1.0, 0.0);
+
+	} else if (G_IS_PARAM_SPEC_UCHAR (pspec)) {
+		GParamSpecUChar *pspec_uchar;
+		pspec_uchar = G_PARAM_SPEC_UCHAR (pspec);
+		adjustment = gtk_adjustment_new (
+			(gdouble) pspec_uchar->default_value,
+			(gdouble) pspec_uchar->minimum,
+			(gdouble) pspec_uchar->maximum,
+			1.0, 1.0, 0.0);
+
+	} else if (G_IS_PARAM_SPEC_INT (pspec)) {
+		GParamSpecInt *pspec_int;
+		pspec_int = G_PARAM_SPEC_INT (pspec);
+		adjustment = gtk_adjustment_new (
+			(gdouble) pspec_int->default_value,
+			(gdouble) pspec_int->minimum,
+			(gdouble) pspec_int->maximum,
+			1.0, 1.0, 0.0);
+
+	} else if (G_IS_PARAM_SPEC_UINT (pspec)) {
+		GParamSpecUInt *pspec_uint;
+		pspec_uint = G_PARAM_SPEC_UINT (pspec);
+		adjustment = gtk_adjustment_new (
+			(gdouble) pspec_uint->default_value,
+			(gdouble) pspec_uint->minimum,
+			(gdouble) pspec_uint->maximum,
+			1.0, 1.0, 0.0);
+
+	} else if (G_IS_PARAM_SPEC_LONG (pspec)) {
+		GParamSpecLong *pspec_long;
+		pspec_long = G_PARAM_SPEC_LONG (pspec);
+		adjustment = gtk_adjustment_new (
+			(gdouble) pspec_long->default_value,
+			(gdouble) pspec_long->minimum,
+			(gdouble) pspec_long->maximum,
+			1.0, 1.0, 0.0);
+
+	} else if (G_IS_PARAM_SPEC_ULONG (pspec)) {
+		GParamSpecULong *pspec_ulong;
+		pspec_ulong = G_PARAM_SPEC_ULONG (pspec);
+		adjustment = gtk_adjustment_new (
+			(gdouble) pspec_ulong->default_value,
+			(gdouble) pspec_ulong->minimum,
+			(gdouble) pspec_ulong->maximum,
+			1.0, 1.0, 0.0);
+
+	} else if (G_IS_PARAM_SPEC_FLOAT (pspec)) {
+		GParamSpecFloat *pspec_float;
+		pspec_float = G_PARAM_SPEC_FLOAT (pspec);
+		adjustment = gtk_adjustment_new (
+			(gdouble) pspec_float->default_value,
+			(gdouble) pspec_float->minimum,
+			(gdouble) pspec_float->maximum,
+			1.0, 1.0, 0.0);
+
+	} else if (G_IS_PARAM_SPEC_DOUBLE (pspec)) {
+		GParamSpecDouble *pspec_double;
+		pspec_double = G_PARAM_SPEC_DOUBLE (pspec);
+		adjustment = gtk_adjustment_new (
+			(gdouble) pspec_double->default_value,
+			(gdouble) pspec_double->minimum,
+			(gdouble) pspec_double->maximum,
+			1.0, 1.0, 0.0);
+
+	} else
+		g_return_if_reached ();
+
+	pre = g_alloca (strlen (entry->text) + 1);
+	strcpy (pre, entry->text);
+	post = strstr (pre, "%s");
+	if (post != NULL) {
+		*post = '\0';
+		post += 2;
+	}
+
+	hbox = gtk_hbox_new (FALSE, 3);
+	gtk_widget_set_margin_left (hbox, STANDARD_MARGIN);
+	gtk_box_pack_start (GTK_BOX (page), hbox, FALSE, FALSE, 0);
+	gtk_widget_show (hbox);
+
+	if (use_pspec != NULL) {
+		prefix = gtk_check_button_new_with_mnemonic (pre);
+
+		g_object_bind_property (
+			page->priv->settings, use_pspec->name,
+			prefix, "active",
+			G_BINDING_BIDIRECTIONAL |
+			G_BINDING_SYNC_CREATE);
+	} else {
+		prefix = gtk_label_new_with_mnemonic (pre);
+	}
+	gtk_box_pack_start (GTK_BOX (hbox), prefix, FALSE, TRUE, 0);
+	gtk_widget_show (prefix);
+
+	spin = gtk_spin_button_new (adjustment, 1.0, 0);
+	gtk_box_pack_start (GTK_BOX (hbox), spin, FALSE, TRUE, 0);
+	gtk_widget_show (spin);
+
+	g_object_bind_property (
+		page->priv->settings, entry->name,
+		spin, "value",
+		G_BINDING_BIDIRECTIONAL |
+		G_BINDING_SYNC_CREATE);
+
+	if (use_pspec != NULL)
+		g_object_bind_property (
+			prefix, "active",
+			spin, "sensitive",
+			G_BINDING_SYNC_CREATE);
+
+	if (post != NULL) {
+		GtkWidget *label = gtk_label_new_with_mnemonic (post);
+		gtk_label_set_mnemonic_widget (GTK_LABEL (label), prefix);
+		gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, TRUE, 0);
+		gtk_widget_show (label);
+	}
+
+	mail_config_provider_page_handle_dependency (page, entry, hbox);
+}
+
+static void
+mail_config_provider_page_add_entry (EMailConfigProviderPage *page,
+                                     CamelProviderConfEntry *entry)
+{
+	GtkWidget *hbox;
+	GtkWidget *input;
+	GtkWidget *label;
+
+	g_return_if_fail (entry->text != NULL);
+
+	hbox = gtk_hbox_new (FALSE, 0);
+	gtk_box_set_spacing (GTK_BOX (hbox), 6);
+	gtk_widget_set_margin_left (hbox, STANDARD_MARGIN);
+	gtk_box_pack_start (GTK_BOX (page), hbox, FALSE, FALSE, 0);
+	gtk_widget_show (hbox);
+
+	label = gtk_label_new_with_mnemonic (entry->text);
+	gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
+	gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
+	gtk_widget_show (label);
+
+	input = gtk_entry_new ();
+	gtk_label_set_mnemonic_widget (GTK_LABEL (label), input);
+	gtk_box_pack_start (GTK_BOX (hbox), input, TRUE, TRUE, 0);
+	gtk_widget_show (input);
+
+	g_object_bind_property (
+		page->priv->settings, entry->name,
+		input, "text",
+		G_BINDING_BIDIRECTIONAL |
+		G_BINDING_SYNC_CREATE);
+
+	g_object_bind_property (
+		input, "sensitive",
+		label, "sensitive",
+		G_BINDING_SYNC_CREATE);
+
+	mail_config_provider_page_handle_dependency (page, entry, hbox);
+}
+
+static void
+mail_config_provider_page_add_options (EMailConfigProviderPage *page,
+                                       CamelProviderConfEntry *entry)
+{
+	CamelProvider *provider;
+	GtkCellRenderer *renderer;
+	GtkListStore *store;
+	GtkWidget *hbox;
+	GtkWidget *combo;
+	GtkWidget *label;
+	gchar **tokens;
+	guint length, ii;
+
+	/* The 'value' string is of the format:
+	 *
+	 *   'nick0:caption0:nick1:caption1:...nickN:captionN'
+	 *
+	 * where 'nick' is the nickname a GEnumValue and 'caption'
+	 * is the localized combo box item displayed to the user. */
+
+	g_return_if_fail (entry->text != NULL);
+	g_return_if_fail (entry->value != NULL);
+
+	provider = page->priv->provider;
+
+	hbox = gtk_hbox_new (FALSE, 0);
+	gtk_box_set_spacing (GTK_BOX (hbox), 6);
+	gtk_widget_set_margin_left (hbox, STANDARD_MARGIN);
+	gtk_box_pack_start (GTK_BOX (page), hbox, FALSE, FALSE, 0);
+	gtk_widget_show (hbox);
+
+	label = gtk_label_new_with_mnemonic (entry->text);
+	gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
+	gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
+	gtk_widget_show (label);
+
+	/* 0: 'nick', 1: caption */
+	store = gtk_list_store_new (2, G_TYPE_STRING, G_TYPE_STRING);
+
+	tokens = g_strsplit (entry->value, ":", -1);
+	length = g_strv_length (tokens);
+
+	/* Take the strings two at a time. */
+	for (ii = 0; ii + 1 < length; ii += 2) {
+		GtkTreeIter iter;
+		const gchar *nick;
+		const gchar *caption;
+
+		nick = tokens[ii + 0];
+		caption = tokens[ii + 1];
+
+		/* Localize the caption. */
+		caption = dgettext (provider->translation_domain, caption);
+
+		gtk_list_store_append (store, &iter);
+		gtk_list_store_set (store, &iter, 0, nick, 1, caption, -1);
+	}
+
+	g_strfreev (tokens);
+
+	combo = gtk_combo_box_new_with_model (GTK_TREE_MODEL (store));
+	gtk_combo_box_set_id_column (GTK_COMBO_BOX (combo), 0);
+	gtk_label_set_mnemonic_widget (GTK_LABEL (label), combo);
+	gtk_box_pack_start (GTK_BOX (hbox), combo, FALSE, FALSE, 0);
+	gtk_widget_show (combo);
+
+	g_object_bind_property_full (
+		page->priv->settings, entry->name,
+		combo, "active-id",
+		G_BINDING_BIDIRECTIONAL |
+		G_BINDING_SYNC_CREATE,
+		e_binding_transform_enum_value_to_nick,
+		e_binding_transform_enum_nick_to_value,
+		NULL, (GDestroyNotify) NULL);
+
+	renderer = gtk_cell_renderer_text_new ();
+	gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (combo), renderer, TRUE);
+	gtk_cell_layout_set_attributes (
+		GTK_CELL_LAYOUT (combo), renderer, "text", 1, NULL);
+
+	mail_config_provider_page_handle_dependency (page, entry, hbox);
+}
+
+static void
+mail_config_provider_page_add_widgets (EMailConfigProviderPage *page)
+{
+	CamelProviderConfEntry *entries;
+	gint ii;
+
+	/* Note the "text" member of each CamelProviderConfEntry is
+	 * already localized, so we can use it directly in widgets. */
+
+	entries = page->priv->provider->extra_conf;
+
+	/* Loop until we see CAMEL_PROVIDER_CONF_END. */
+	for (ii = 0; entries[ii].type != CAMEL_PROVIDER_CONF_END; ii++) {
+
+		/* Skip entries with no name. */
+		if (entries[ii].name == NULL)
+			continue;
+
+		switch (entries[ii].type) {
+			case CAMEL_PROVIDER_CONF_SECTION_START:
+				mail_config_provider_page_add_section (
+					page, &entries[ii]);
+				break;
+
+			case CAMEL_PROVIDER_CONF_CHECKBOX:
+				mail_config_provider_page_add_checkbox (
+					page, &entries[ii]);
+				break;
+
+			case CAMEL_PROVIDER_CONF_CHECKSPIN:
+				mail_config_provider_page_add_checkspin (
+					page, &entries[ii]);
+				break;
+
+			case CAMEL_PROVIDER_CONF_ENTRY:
+				mail_config_provider_page_add_entry (
+					page, &entries[ii]);
+				break;
+
+			case CAMEL_PROVIDER_CONF_OPTIONS:
+				mail_config_provider_page_add_options (
+					page, &entries[ii]);
+				break;
+
+			default:
+				break;  /* skip it */
+		}
+	}
+}
+
+static void
+mail_config_provider_page_set_scratch_source (EMailConfigProviderPage *page,
+                                              ESource *scratch_source)
+{
+	g_return_if_fail (E_IS_SOURCE (scratch_source));
+	g_return_if_fail (page->priv->scratch_source == NULL);
+
+	page->priv->scratch_source = g_object_ref (scratch_source);
+}
+
+static void
+mail_config_provider_page_set_property (GObject *object,
+                                        guint property_id,
+                                        const GValue *value,
+                                        GParamSpec *pspec)
+{
+	switch (property_id) {
+		case PROP_SCRATCH_SOURCE:
+			mail_config_provider_page_set_scratch_source (
+				E_MAIL_CONFIG_PROVIDER_PAGE (object),
+				g_value_get_object (value));
+			return;
+	}
+
+	G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+}
+
+static void
+mail_config_provider_page_get_property (GObject *object,
+                                        guint property_id,
+                                        GValue *value,
+                                        GParamSpec *pspec)
+{
+	switch (property_id) {
+		case PROP_SCRATCH_SOURCE:
+			g_value_set_object (
+				value,
+				e_mail_config_provider_page_get_scratch_source (
+				E_MAIL_CONFIG_PROVIDER_PAGE (object)));
+			return;
+	}
+
+	G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+}
+
+static void
+mail_config_provider_page_dispose (GObject *object)
+{
+	EMailConfigProviderPagePrivate *priv;
+
+	priv = E_MAIL_CONFIG_PROVIDER_PAGE_GET_PRIVATE (object);
+
+	if (priv->scratch_source != NULL) {
+		g_object_unref (priv->scratch_source);
+		priv->scratch_source = NULL;
+	}
+
+	if (priv->settings != NULL) {
+		g_object_unref (priv->settings);
+		priv->settings = NULL;
+	}
+
+	/* Chain up parent's dispose() method. */
+	G_OBJECT_CLASS (e_mail_config_provider_page_parent_class)->
+		dispose (object);
+}
+
+static void
+mail_config_provider_page_constructed (GObject *object)
+{
+	EMailConfigProviderPage *page;
+	ESource *source;
+	ESourceCamel *camel_extension;
+	ESourceBackend *backend_extension;
+	const gchar *backend_name;
+	const gchar *extension_name;
+	GError *error = NULL;
+
+	page = E_MAIL_CONFIG_PROVIDER_PAGE (object);
+	source = e_mail_config_provider_page_get_scratch_source (page);
+
+	/* Chain up parent's constructed() method. */
+	G_OBJECT_CLASS (e_mail_config_provider_page_parent_class)->
+		constructed (object);
+
+	gtk_box_set_spacing (GTK_BOX (object), 6);
+
+	gtk_orientable_set_orientation (
+		GTK_ORIENTABLE (object), GTK_ORIENTATION_VERTICAL);
+
+	extension_name = E_SOURCE_EXTENSION_MAIL_ACCOUNT;
+	backend_extension = e_source_get_extension (source, extension_name);
+	backend_name = e_source_backend_get_backend_name (backend_extension);
+	page->priv->provider = camel_provider_get (backend_name, &error);
+
+	if (error != NULL) {
+		g_warn_if_fail (page->priv->provider == NULL);
+		g_warning ("%s: %s", G_STRFUNC, error->message);
+		g_clear_error (&error);
+		page->priv->is_empty = TRUE;
+		return;
+	}
+
+	g_return_if_fail (page->priv->provider != NULL);
+
+	if (page->priv->provider->extra_conf == NULL) {
+		page->priv->is_empty = TRUE;
+		return;
+	}
+
+	extension_name = e_source_camel_get_extension_name (backend_name);
+	camel_extension = e_source_get_extension (source, extension_name);
+	page->priv->settings = e_source_camel_get_settings (camel_extension);
+
+	if (page->priv->settings == NULL) {
+		page->priv->is_empty = TRUE;
+		return;
+	}
+
+	g_object_ref (page->priv->settings);
+
+	mail_config_provider_page_add_widgets (page);
+}
+
+static void
+e_mail_config_provider_page_class_init (EMailConfigProviderPageClass *class)
+{
+	GObjectClass *object_class;
+
+	g_type_class_add_private (class, sizeof (EMailConfigProviderPagePrivate));
+
+	object_class = G_OBJECT_CLASS (class);
+	object_class->set_property = mail_config_provider_page_set_property;
+	object_class->get_property = mail_config_provider_page_get_property;
+	object_class->dispose = mail_config_provider_page_dispose;
+	object_class->constructed = mail_config_provider_page_constructed;
+
+	g_object_class_install_property (
+		object_class,
+		PROP_SCRATCH_SOURCE,
+		g_param_spec_object (
+			"scratch-source",
+			"Scratch Source",
+			"The data source being edited",
+			E_TYPE_SOURCE,
+			G_PARAM_READWRITE |
+			G_PARAM_CONSTRUCT_ONLY |
+			G_PARAM_STATIC_STRINGS));
+}
+
+static void
+e_mail_config_provider_page_interface_init (EMailConfigPageInterface *interface)
+{
+	interface->title = _("Receiving Options");
+	interface->sort_order = E_MAIL_CONFIG_PROVIDER_PAGE_SORT_ORDER;
+}
+
+static void
+e_mail_config_provider_page_init (EMailConfigProviderPage *page)
+{
+	page->priv = E_MAIL_CONFIG_PROVIDER_PAGE_GET_PRIVATE (page);
+}
+
+EMailConfigPage *
+e_mail_config_provider_page_new (ESource *scratch_source)
+{
+	g_return_val_if_fail (E_IS_SOURCE (scratch_source), NULL);
+
+	return g_object_new (
+		E_TYPE_MAIL_CONFIG_PROVIDER_PAGE,
+		"scratch-source", scratch_source, NULL);
+}
+
+gboolean
+e_mail_config_provider_page_is_empty (EMailConfigProviderPage *page)
+{
+	g_return_val_if_fail (E_IS_MAIL_CONFIG_PROVIDER_PAGE (page), TRUE);
+
+	return page->priv->is_empty;
+}
+
+ESource *
+e_mail_config_provider_page_get_scratch_source (EMailConfigProviderPage *page)
+{
+	g_return_val_if_fail (E_IS_MAIL_CONFIG_PROVIDER_PAGE (page), NULL);
+
+	return page->priv->scratch_source;
+}
+
diff --git a/mail/e-mail-config-provider-page.h b/mail/e-mail-config-provider-page.h
new file mode 100644
index 0000000..3e22647
--- /dev/null
+++ b/mail/e-mail-config-provider-page.h
@@ -0,0 +1,75 @@
+/*
+ * e-mail-config-provider-page.h
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) version 3.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with the program; if not, see <http://www.gnu.org/licenses/>
+ *
+ */
+
+#ifndef E_MAIL_CONFIG_PROVIDER_PAGE_H
+#define E_MAIL_CONFIG_PROVIDER_PAGE_H
+
+#include <gtk/gtk.h>
+#include <libedataserver/e-source.h>
+
+#include <mail/e-mail-config-page.h>
+
+/* Standard GObject macros */
+#define E_TYPE_MAIL_CONFIG_PROVIDER_PAGE \
+	(e_mail_config_provider_page_get_type ())
+#define E_MAIL_CONFIG_PROVIDER_PAGE(obj) \
+	(G_TYPE_CHECK_INSTANCE_CAST \
+	((obj), E_TYPE_MAIL_CONFIG_PROVIDER_PAGE, EMailConfigProviderPage))
+#define E_MAIL_CONFIG_PROVIDER_PAGE_CLASS(cls) \
+	(G_TYPE_CHECK_CLASS_CAST \
+	((cls), E_TYPE_MAIL_CONFIG_PROVIDER_PAGE, EMailConfigProviderPageClass))
+#define E_IS_MAIL_CONFIG_PROVIDER_PAGE(obj) \
+	(G_TYPE_CHECK_INSTANCE_TYPE \
+	((obj), E_TYPE_MAIL_CONFIG_PROVIDER_PAGE))
+#define E_IS_MAIL_CONFIG_PROVIDER_PAGE_CLASS(cls) \
+	(G_TYPE_CHECK_CLASS_TYPE \
+	((cls), E_TYPE_MAIL_CONFIG_PROVIDER_PAGE))
+#define E_MAIL_CONFIG_PROVIDER_PAGE_GET_CLASS(obj) \
+	(G_TYPE_INSTANCE_GET_CLASS \
+	((obj), E_TYPE_MAIL_CONFIG_PROVIDER_PAGE, EMailConfigProviderPageClass))
+
+#define E_MAIL_CONFIG_PROVIDER_PAGE_SORT_ORDER (300)
+
+G_BEGIN_DECLS
+
+typedef struct _EMailConfigProviderPage EMailConfigProviderPage;
+typedef struct _EMailConfigProviderPageClass EMailConfigProviderPageClass;
+typedef struct _EMailConfigProviderPagePrivate EMailConfigProviderPagePrivate;
+
+struct _EMailConfigProviderPage {
+	GtkBox parent;
+	EMailConfigProviderPagePrivate *priv;
+};
+
+struct _EMailConfigProviderPageClass {
+	GtkBoxClass parent_class;
+};
+
+GType		e_mail_config_provider_page_get_type
+					(void) G_GNUC_CONST;
+EMailConfigPage *
+		e_mail_config_provider_page_new
+					(ESource *scratch_source);
+gboolean	e_mail_config_provider_page_is_empty
+					(EMailConfigProviderPage *page);
+ESource *	e_mail_config_provider_page_get_scratch_source
+					(EMailConfigProviderPage *page);
+
+G_END_DECLS
+
+#endif /* E_MAIL_CONFIG_PROVIDER_PAGE_H */
diff --git a/mail/e-mail-config-receiving-page.c b/mail/e-mail-config-receiving-page.c
new file mode 100644
index 0000000..b84d1ea
--- /dev/null
+++ b/mail/e-mail-config-receiving-page.c
@@ -0,0 +1,69 @@
+/*
+ * e-mail-config-receiving-page.c
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) version 3.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with the program; if not, see <http://www.gnu.org/licenses/>
+ *
+ */
+
+#include "e-mail-config-receiving-page.h"
+
+#include <config.h>
+#include <glib/gi18n-lib.h>
+
+#include <libedataserver/e-source-mail-account.h>
+
+/* Forward Declarations */
+static void	e_mail_config_receiving_page_interface_init
+					(EMailConfigPageInterface *interface);
+
+G_DEFINE_TYPE_WITH_CODE (
+	EMailConfigReceivingPage,
+	e_mail_config_receiving_page,
+	E_TYPE_MAIL_CONFIG_SERVICE_PAGE,
+	G_IMPLEMENT_INTERFACE (
+		E_TYPE_MAIL_CONFIG_PAGE,
+		e_mail_config_receiving_page_interface_init))
+
+static void
+e_mail_config_receiving_page_class_init (EMailConfigReceivingPageClass *class)
+{
+	EMailConfigServicePageClass *service_page_class;
+
+	service_page_class = E_MAIL_CONFIG_SERVICE_PAGE_CLASS (class);
+	service_page_class->extension_name = E_SOURCE_EXTENSION_MAIL_ACCOUNT;
+	service_page_class->provider_type = CAMEL_PROVIDER_STORE;
+}
+
+static void
+e_mail_config_receiving_page_interface_init (EMailConfigPageInterface *interface)
+{
+	interface->title = _("Receiving Email");
+	interface->sort_order = E_MAIL_CONFIG_RECEIVING_PAGE_SORT_ORDER;
+}
+
+static void
+e_mail_config_receiving_page_init (EMailConfigReceivingPage *page)
+{
+}
+
+EMailConfigPage *
+e_mail_config_receiving_page_new (ESourceRegistry *registry)
+{
+	g_return_val_if_fail (E_IS_SOURCE_REGISTRY (registry), NULL);
+
+	return g_object_new (
+		E_TYPE_MAIL_CONFIG_RECEIVING_PAGE,
+		"registry", registry, NULL);
+}
+
diff --git a/mail/e-mail-config-receiving-page.h b/mail/e-mail-config-receiving-page.h
new file mode 100644
index 0000000..626da30
--- /dev/null
+++ b/mail/e-mail-config-receiving-page.h
@@ -0,0 +1,69 @@
+/*
+ * e-mail-config-receiving-page.h
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) version 3.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with the program; if not, see <http://www.gnu.org/licenses/>
+ *
+ */
+
+#ifndef E_MAIL_CONFIG_RECEIVING_PAGE_H
+#define E_MAIL_CONFIG_RECEIVING_PAGE_H
+
+#include <mail/e-mail-config-page.h>
+#include <mail/e-mail-config-service-page.h>
+
+/* Standard GObject macros */
+#define E_TYPE_MAIL_CONFIG_RECEIVING_PAGE \
+	(e_mail_config_receiving_page_get_type ())
+#define E_MAIL_CONFIG_RECEIVING_PAGE(obj) \
+	(G_TYPE_CHECK_INSTANCE_CAST \
+	((obj), E_TYPE_MAIL_CONFIG_RECEIVING_PAGE, EMailConfigReceivingPage))
+#define E_MAIL_CONFIG_RECEIVING_PAGE_CLASS(cls) \
+	(G_TYPE_CHECK_CLASS_CAST \
+	((cls), E_TYPE_MAIL_CONFIG_RECEIVING_PAGE, EMailConfigReceivingPageClass))
+#define E_IS_MAIL_CONFIG_RECEIVING_PAGE(obj) \
+	(G_TYPE_CHECK_INSTANCE_TYPE \
+	((obj), E_TYPE_MAIL_CONFIG_RECEIVING_PAGE))
+#define E_IS_MAIL_CONFIG_RECEIVING_PAGE_CLASS(cls) \
+	(G_TYPE_CHECK_CLASS_TYPE \
+	((cls), E_TYPE_MAIL_CONFIG_RECEIVING_PAGE))
+#define E_MAIL_CONFIG_RECEIVING_PAGE_GET_CLASS(obj) \
+	(G_TYPE_INSTANCE_GET_CLASS \
+	((obj), E_TYPE_MAIL_CONFIG_RECEIVING_PAGE, EMailConfigReceivingPageClass))
+
+#define E_MAIL_CONFIG_RECEIVING_PAGE_SORT_ORDER (200)
+
+G_BEGIN_DECLS
+
+typedef struct _EMailConfigReceivingPage EMailConfigReceivingPage;
+typedef struct _EMailConfigReceivingPageClass EMailConfigReceivingPageClass;
+typedef struct _EMailConfigReceivingPagePrivate EMailConfigReceivingPagePrivate;
+
+struct _EMailConfigReceivingPage {
+	EMailConfigServicePage parent;
+};
+
+struct _EMailConfigReceivingPageClass {
+	EMailConfigServicePageClass parent_class;
+};
+
+GType		e_mail_config_receiving_page_get_type
+						(void) G_GNUC_CONST;
+EMailConfigPage *
+		e_mail_config_receiving_page_new
+						(ESourceRegistry *registry);
+
+G_END_DECLS
+
+#endif /* E_MAIL_CONFIG_RECEIVING_PAGE_H */
+
diff --git a/mail/e-mail-config-security-page.c b/mail/e-mail-config-security-page.c
new file mode 100644
index 0000000..dafa8e2
--- /dev/null
+++ b/mail/e-mail-config-security-page.c
@@ -0,0 +1,667 @@
+/*
+ * e-mail-config-security-page.c
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) version 3.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with the program; if not, see <http://www.gnu.org/licenses/>
+ *
+ */
+
+#include "e-mail-config-security-page.h"
+
+#include <config.h>
+#include <glib/gi18n-lib.h>
+
+#include <libedataserver/e-source-mail-composition.h>
+#include <libedataserver/e-source-openpgp.h>
+#include <libedataserver/e-source-smime.h>
+
+#if defined (HAVE_NSS)
+#include <smime/gui/e-cert-selector.h>
+#endif /* HAVE_NSS */
+
+#define E_MAIL_CONFIG_SECURITY_PAGE_GET_PRIVATE(obj) \
+	(G_TYPE_INSTANCE_GET_PRIVATE \
+	((obj), E_TYPE_MAIL_CONFIG_SECURITY_PAGE, EMailConfigSecurityPagePrivate))
+
+struct _EMailConfigSecurityPagePrivate {
+	ESource *identity_source;
+};
+
+enum {
+	PROP_0,
+	PROP_IDENTITY_SOURCE
+};
+
+/* Forward Declarations */
+static void	e_mail_config_security_page_interface_init
+					(EMailConfigPageInterface *interface);
+
+G_DEFINE_TYPE_WITH_CODE (
+	EMailConfigSecurityPage,
+	e_mail_config_security_page,
+	GTK_TYPE_BOX,
+	G_IMPLEMENT_INTERFACE (
+		E_TYPE_MAIL_CONFIG_PAGE,
+		e_mail_config_security_page_interface_init))
+
+static gboolean
+mail_config_security_page_string_has_text (GBinding *binding,
+                                           const GValue *source_value,
+                                           GValue *target_value,
+                                           gpointer unused)
+{
+	const gchar *string;
+	gchar *stripped;
+
+	string = g_value_get_string (source_value);
+
+	if (string == NULL)
+		string = "";
+
+	stripped = g_strstrip (g_strdup (string));
+	g_value_set_boolean (target_value, *stripped != '\0');
+	g_free (stripped);
+
+	return TRUE;
+}
+
+static void
+mail_config_security_page_cert_selected (ECertSelector *selector,
+                                         const gchar *key,
+                                         GtkEntry *entry)
+{
+	if (key != NULL)
+		gtk_entry_set_text (entry, key);
+
+	gtk_widget_destroy (GTK_WIDGET (selector));
+}
+
+static void
+mail_config_security_page_select_encrypt_cert (GtkButton *button,
+                                               GtkEntry *entry)
+{
+	GtkWidget *selector;
+	gpointer parent;
+
+	parent = gtk_widget_get_toplevel (GTK_WIDGET (button));
+	parent = GTK_IS_WIDGET (parent) ? parent : NULL;
+
+	selector = e_cert_selector_new (
+		E_CERT_SELECTOR_RECIPIENT,
+		gtk_entry_get_text (entry));
+	gtk_window_set_transient_for (
+		GTK_WINDOW (selector), parent);
+	gtk_widget_show (selector);
+
+	g_signal_connect (
+		selector, "selected",
+		G_CALLBACK (mail_config_security_page_cert_selected),
+		entry);
+}
+
+static void
+mail_config_security_page_select_sign_cert (GtkButton *button,
+                                            GtkEntry *entry)
+{
+	GtkWidget *selector;
+	gpointer parent;
+
+	parent = gtk_widget_get_toplevel (GTK_WIDGET (button));
+	parent = GTK_IS_WIDGET (parent) ? parent : NULL;
+
+	selector = e_cert_selector_new (
+		E_CERT_SELECTOR_SIGNER,
+		gtk_entry_get_text (entry));
+	gtk_window_set_transient_for (
+		GTK_WINDOW (selector), parent);
+	gtk_widget_show (selector);
+
+	g_signal_connect (
+		selector, "selected",
+		G_CALLBACK (mail_config_security_page_cert_selected),
+		entry);
+}
+
+static void
+mail_config_security_page_clear_cert (GtkButton *button,
+                                      GtkEntry *entry)
+{
+	gtk_entry_set_text (entry, "");
+}
+
+static void
+mail_config_security_page_set_identity_source (EMailConfigSecurityPage *page,
+                                               ESource *identity_source)
+{
+	g_return_if_fail (E_IS_SOURCE (identity_source));
+	g_return_if_fail (page->priv->identity_source == NULL);
+
+	page->priv->identity_source = g_object_ref (identity_source);
+}
+
+static void
+mail_config_security_page_set_property (GObject *object,
+                                        guint property_id,
+                                        const GValue *value,
+                                        GParamSpec *pspec)
+{
+	switch (property_id) {
+		case PROP_IDENTITY_SOURCE:
+			mail_config_security_page_set_identity_source (
+				E_MAIL_CONFIG_SECURITY_PAGE (object),
+				g_value_get_object (value));
+			return;
+	}
+
+	G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+}
+
+static void
+mail_config_security_page_get_property (GObject *object,
+                                        guint property_id,
+                                        GValue *value,
+                                        GParamSpec *pspec)
+{
+	switch (property_id) {
+		case PROP_IDENTITY_SOURCE:
+			g_value_set_object (
+				value,
+				e_mail_config_security_page_get_identity_source (
+				E_MAIL_CONFIG_SECURITY_PAGE (object)));
+			return;
+	}
+
+	G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+}
+
+static void
+mail_config_security_page_dispose (GObject *object)
+{
+	EMailConfigSecurityPagePrivate *priv;
+
+	priv = E_MAIL_CONFIG_SECURITY_PAGE_GET_PRIVATE (object);
+
+	if (priv->identity_source != NULL) {
+		g_object_unref (priv->identity_source);
+		priv->identity_source = NULL;
+	}
+
+	/* Chain up to parent's dispose() method. */
+	G_OBJECT_CLASS (e_mail_config_security_page_parent_class)->
+		dispose (object);
+}
+
+static void
+mail_config_security_page_constructed (GObject *object)
+{
+	EMailConfigSecurityPage *page;
+	ESource *source;
+	ESourceMailComposition *composition_ext;
+	ESourceOpenPGP *openpgp_ext;
+	GtkEntry *entry;
+	GtkLabel *label;
+	GtkWidget *widget;
+	GtkWidget *container;
+	GtkSizeGroup *size_group;
+	const gchar *extension_name;
+	const gchar *text;
+	gchar *markup;
+
+#if defined (HAVE_NSS)
+	ESourceSMIME *smime_ext;
+#endif /* HAVE_NSS */
+
+	page = E_MAIL_CONFIG_SECURITY_PAGE (object);
+
+	/* Chain up to parent's constructed() method. */
+	G_OBJECT_CLASS (e_mail_config_security_page_parent_class)->
+		constructed (object);
+
+	source = e_mail_config_security_page_get_identity_source (page);
+
+	extension_name = E_SOURCE_EXTENSION_MAIL_COMPOSITION;
+	composition_ext = e_source_get_extension (source, extension_name);
+
+	extension_name = E_SOURCE_EXTENSION_OPENPGP;
+	openpgp_ext = e_source_get_extension (source, extension_name);
+
+#if defined (HAVE_NSS)
+	extension_name = E_SOURCE_EXTENSION_SMIME;
+	smime_ext = e_source_get_extension (source, extension_name);
+#endif /* HAVE_NSS */
+
+	gtk_orientable_set_orientation (
+		GTK_ORIENTABLE (page), GTK_ORIENTATION_VERTICAL);
+
+	gtk_box_set_spacing (GTK_BOX (page), 12);
+
+	size_group = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL);
+
+	/*** General ***/
+
+	widget = gtk_grid_new ();
+	gtk_grid_set_row_spacing (GTK_GRID (widget), 6);
+	gtk_grid_set_column_spacing (GTK_GRID (widget), 6);
+	gtk_box_pack_start (GTK_BOX (page), widget, FALSE, FALSE, 0);
+	gtk_widget_show (widget);
+
+	container = widget;
+
+	text = _("General");
+	markup = g_markup_printf_escaped ("<b>%s</b>", text);
+	widget = gtk_label_new (markup);
+	gtk_label_set_use_markup (GTK_LABEL (widget), TRUE);
+	gtk_misc_set_alignment (GTK_MISC (widget), 0.0, 0.5);
+	gtk_grid_attach (GTK_GRID (container), widget, 0, 0, 1, 1);
+	gtk_widget_show (widget);
+
+	text = _("_Do not sign meeting requests (for Outlook compatibility)");
+	widget = gtk_check_button_new_with_mnemonic (text);
+	gtk_widget_set_margin_left (widget, 12);
+	gtk_grid_attach (GTK_GRID (container), widget, 0, 1, 1, 1);
+	gtk_widget_show (widget);
+
+	g_object_bind_property (
+		composition_ext, "sign-imip",
+		widget, "active",
+		G_BINDING_BIDIRECTIONAL |
+		G_BINDING_SYNC_CREATE);
+
+	/*** Pretty Good Privacy (OpenPGP) ***/
+
+	widget = gtk_grid_new ();
+	gtk_grid_set_row_spacing (GTK_GRID (widget), 6);
+	gtk_grid_set_column_spacing (GTK_GRID (widget), 6);
+	gtk_box_pack_start (GTK_BOX (page), widget, FALSE, FALSE, 0);
+	gtk_widget_show (widget);
+
+	container = widget;
+
+	text = _("Pretty Good Privacy (OpenPGP)");
+	markup = g_markup_printf_escaped ("<b>%s</b>", text);
+	widget = gtk_label_new (markup);
+	gtk_label_set_use_markup (GTK_LABEL (widget), TRUE);
+	gtk_misc_set_alignment (GTK_MISC (widget), 0.0, 0.5);
+	gtk_grid_attach (GTK_GRID (container), widget, 0, 0, 2, 1);
+	gtk_widget_show (widget);
+
+	text = _("OpenPGP _Key ID:");
+	widget = gtk_label_new_with_mnemonic (text);
+	gtk_widget_set_margin_left (widget, 12);
+	gtk_size_group_add_widget (size_group, widget);
+	gtk_misc_set_alignment (GTK_MISC (widget), 1.0, 0.5);
+	gtk_grid_attach (GTK_GRID (container), widget, 0, 1, 1, 1);
+	gtk_widget_show (widget);
+
+	label = GTK_LABEL (widget);
+
+	widget = gtk_entry_new ();
+	gtk_widget_set_hexpand (widget, TRUE);
+	gtk_label_set_mnemonic_widget (label, widget);
+	gtk_grid_attach (GTK_GRID (container), widget, 1, 1, 1, 1);
+	gtk_widget_show (widget);
+
+	g_object_bind_property (
+		openpgp_ext, "key-id",
+		widget, "text",
+		G_BINDING_SYNC_CREATE |
+		G_BINDING_BIDIRECTIONAL);
+
+	text = _("Si_gning algorithm:");
+	widget = gtk_label_new_with_mnemonic (text);
+	gtk_widget_set_margin_left (widget, 12);
+	gtk_size_group_add_widget (size_group, widget);
+	gtk_misc_set_alignment (GTK_MISC (widget), 1.0, 0.5);
+	gtk_grid_attach (GTK_GRID (container), widget, 0, 2, 1, 1);
+	gtk_widget_show (widget);
+
+	label = GTK_LABEL (widget);
+
+	widget = gtk_combo_box_text_new ();
+	gtk_combo_box_text_append (
+		GTK_COMBO_BOX_TEXT (widget),
+		"", _("Default"));
+	gtk_combo_box_text_append (
+		GTK_COMBO_BOX_TEXT (widget),
+		"sha1", _("SHA1"));
+	gtk_combo_box_text_append (
+		GTK_COMBO_BOX_TEXT (widget),
+		"sha256", _("SHA256"));
+	gtk_combo_box_text_append (
+		GTK_COMBO_BOX_TEXT (widget),
+		"sha384", _("SHA384"));
+	gtk_combo_box_text_append (
+		GTK_COMBO_BOX_TEXT (widget),
+		"sha512", _("SHA512"));
+	gtk_widget_set_halign (widget, GTK_ALIGN_START);
+	gtk_label_set_mnemonic_widget (label, widget);
+	gtk_grid_attach (GTK_GRID (container), widget, 1, 2, 1, 1);
+	gtk_widget_show (widget);
+
+	g_object_bind_property (
+		openpgp_ext, "signing-algorithm",
+		widget, "active-id",
+		G_BINDING_SYNC_CREATE |
+		G_BINDING_BIDIRECTIONAL);
+
+	/* Make sure the combo box has an active item. */
+	if (gtk_combo_box_get_active_id (GTK_COMBO_BOX (widget)) == NULL)
+		gtk_combo_box_set_active (GTK_COMBO_BOX (widget), 0);
+
+	text = _("Al_ways sign outgoing messages when using this account");
+	widget = gtk_check_button_new_with_mnemonic (text);
+	gtk_widget_set_margin_left (widget, 12);
+	gtk_grid_attach (GTK_GRID (container), widget, 0, 3, 2, 1);
+	gtk_widget_show (widget);
+
+	g_object_bind_property (
+		openpgp_ext, "sign-by-default",
+		widget, "active",
+		G_BINDING_SYNC_CREATE |
+		G_BINDING_BIDIRECTIONAL);
+
+	text = _("Always encrypt to _myself when sending encrypted messages");
+	widget = gtk_check_button_new_with_mnemonic (text);
+	gtk_widget_set_margin_left (widget, 12);
+	gtk_grid_attach (GTK_GRID (container), widget, 0, 4, 2, 1);
+	gtk_widget_show (widget);
+
+	g_object_bind_property (
+		openpgp_ext, "encrypt-to-self",
+		widget, "active",
+		G_BINDING_SYNC_CREATE |
+		G_BINDING_BIDIRECTIONAL);
+
+	text = _("Always _trust keys in my keyring when encrypting");
+	widget = gtk_check_button_new_with_mnemonic (text);
+	gtk_widget_set_margin_left (widget, 12);
+	gtk_grid_attach (GTK_GRID (container), widget, 0, 5, 2, 1);
+	gtk_widget_show (widget);
+
+	g_object_bind_property (
+		openpgp_ext, "always-trust",
+		widget, "active",
+		G_BINDING_SYNC_CREATE |
+		G_BINDING_BIDIRECTIONAL);
+
+#if defined (HAVE_NSS)
+
+	/*** Security MIME (S/MIME) ***/
+
+	widget = gtk_grid_new ();
+	gtk_grid_set_row_spacing (GTK_GRID (widget), 6);
+	gtk_grid_set_column_spacing (GTK_GRID (widget), 6);
+	gtk_box_pack_start (GTK_BOX (page), widget, FALSE, FALSE, 0);
+	gtk_widget_show (widget);
+
+	container = widget;
+
+	text = _("Secure MIME (S/MIME)");
+	markup = g_markup_printf_escaped ("<b>%s</b>", text);
+	widget = gtk_label_new (markup);
+	gtk_label_set_use_markup (GTK_LABEL (widget), TRUE);
+	gtk_misc_set_alignment (GTK_MISC (widget), 0.0, 0.5);
+	gtk_grid_attach (GTK_GRID (container), widget, 0, 0, 4, 1);
+	gtk_widget_show (widget);
+
+	text = _("Sig_ning certificate:");
+	widget = gtk_label_new_with_mnemonic (text);
+	gtk_widget_set_margin_left (widget, 12);
+	gtk_size_group_add_widget (size_group, widget);
+	gtk_misc_set_alignment (GTK_MISC (widget), 1.0, 0.5);
+	gtk_grid_attach (GTK_GRID (container), widget, 0, 1, 1, 1);
+	gtk_widget_show (widget);
+
+	label = GTK_LABEL (widget);
+
+	widget = gtk_entry_new ();
+	gtk_widget_set_hexpand (widget, TRUE);
+	gtk_label_set_mnemonic_widget (label, widget);
+	gtk_grid_attach (GTK_GRID (container), widget, 1, 1, 1, 1);
+	gtk_widget_show (widget);
+
+	g_object_bind_property (
+		smime_ext, "signing-certificate",
+		widget, "text",
+		G_BINDING_BIDIRECTIONAL |
+		G_BINDING_SYNC_CREATE);
+
+	entry = GTK_ENTRY (widget);
+
+	widget = gtk_button_new_with_label (_("Select"));
+	gtk_grid_attach (GTK_GRID (container), widget, 2, 1, 1, 1);
+	gtk_widget_show (widget);
+
+	g_signal_connect (
+		widget, "clicked",
+		G_CALLBACK (mail_config_security_page_select_sign_cert),
+		entry);
+
+	widget = gtk_button_new_from_stock (GTK_STOCK_CLEAR);
+	gtk_grid_attach (GTK_GRID (container), widget, 3, 1, 1, 1);
+	gtk_widget_show (widget);
+
+	g_signal_connect (
+		widget, "clicked",
+		G_CALLBACK (mail_config_security_page_clear_cert),
+		entry);
+
+	text = _("Signing _algorithm:");
+	widget = gtk_label_new_with_mnemonic (text);
+	gtk_widget_set_margin_left (widget, 12);
+	gtk_size_group_add_widget (size_group, widget);
+	gtk_misc_set_alignment (GTK_MISC (widget), 1.0, 0.5);
+	gtk_grid_attach (GTK_GRID (container), widget, 0, 2, 1, 1);
+	gtk_widget_show (widget);
+
+	label = GTK_LABEL (widget);
+
+	widget = gtk_combo_box_text_new ();
+	gtk_combo_box_text_append (
+		GTK_COMBO_BOX_TEXT (widget),
+		"", _("Default"));
+	gtk_combo_box_text_append (
+		GTK_COMBO_BOX_TEXT (widget),
+		"sha1", _("SHA1"));
+	gtk_combo_box_text_append (
+		GTK_COMBO_BOX_TEXT (widget),
+		"sha256", _("SHA256"));
+	gtk_combo_box_text_append (
+		GTK_COMBO_BOX_TEXT (widget),
+		"sha384", _("SHA384"));
+	gtk_combo_box_text_append (
+		GTK_COMBO_BOX_TEXT (widget),
+		"sha512", _("SHA512"));
+	gtk_widget_set_halign (widget, GTK_ALIGN_START);
+	gtk_label_set_mnemonic_widget (label, widget);
+	gtk_grid_attach (GTK_GRID (container), widget, 1, 2, 1, 1);
+	gtk_widget_show (widget);
+
+	g_object_bind_property (
+		smime_ext, "signing-algorithm",
+		widget, "active-id",
+		G_BINDING_SYNC_CREATE |
+		G_BINDING_BIDIRECTIONAL);
+
+	/* Make sure the combo box has an active item. */
+	if (gtk_combo_box_get_active_id (GTK_COMBO_BOX (widget)) == NULL)
+		gtk_combo_box_set_active (GTK_COMBO_BOX (widget), 0);
+
+	text = _("Always sign outgoing messages when using this account");
+	widget = gtk_check_button_new_with_mnemonic (text);
+	gtk_widget_set_margin_left (widget, 12);
+	gtk_grid_attach (GTK_GRID (container), widget, 0, 3, 4, 1);
+	gtk_widget_show (widget);
+
+	g_object_bind_property (
+		smime_ext, "sign-by-default",
+		widget, "active",
+		G_BINDING_SYNC_CREATE |
+		G_BINDING_BIDIRECTIONAL);
+
+	g_object_bind_property_full (
+		smime_ext, "signing-certificate",
+		widget, "sensitive",
+		G_BINDING_SYNC_CREATE,
+		mail_config_security_page_string_has_text,
+		NULL,
+		NULL, (GDestroyNotify) NULL);
+
+	/* Add extra padding between signing stuff and encryption stuff. */
+	gtk_widget_set_margin_bottom (widget, 6);
+
+	text = _("Encryption certificate:");
+	widget = gtk_label_new_with_mnemonic (text);
+	gtk_widget_set_margin_left (widget, 12);
+	gtk_size_group_add_widget (size_group, widget);
+	gtk_misc_set_alignment (GTK_MISC (widget), 1.0, 0.5);
+	gtk_grid_attach (GTK_GRID (container), widget, 0, 4, 1, 1);
+	gtk_widget_show (widget);
+
+	label = GTK_LABEL (widget);
+
+	widget = gtk_entry_new ();
+	gtk_widget_set_hexpand (widget, TRUE);
+	gtk_label_set_mnemonic_widget (label, widget);
+	gtk_grid_attach (GTK_GRID (container), widget, 1, 4, 1, 1);
+	gtk_widget_show (widget);
+
+	g_object_bind_property (
+		smime_ext, "encryption-certificate",
+		widget, "text",
+		G_BINDING_BIDIRECTIONAL |
+		G_BINDING_SYNC_CREATE);
+
+	entry = GTK_ENTRY (widget);
+
+	widget = gtk_button_new_with_label (_("Select"));
+	gtk_grid_attach (GTK_GRID (container), widget, 2, 4, 1, 1);
+	gtk_widget_show (widget);
+
+	g_signal_connect (
+		widget, "clicked",
+		G_CALLBACK (mail_config_security_page_select_encrypt_cert),
+		entry);
+
+	widget = gtk_button_new_from_stock (GTK_STOCK_CLEAR);
+	gtk_grid_attach (GTK_GRID (container), widget, 3, 4, 1, 1);
+	gtk_widget_show (widget);
+
+	g_signal_connect (
+		widget, "clicked",
+		G_CALLBACK (mail_config_security_page_clear_cert),
+		entry);
+
+	text = _("Always encrypt outgoing messages when using this account");
+	widget = gtk_check_button_new_with_mnemonic (text);
+	gtk_widget_set_margin_left (widget, 12);
+	gtk_grid_attach (GTK_GRID (container), widget, 0, 5, 4, 1);
+	gtk_widget_show (widget);
+
+	g_object_bind_property (
+		smime_ext, "encrypt-by-default",
+		widget, "active",
+		G_BINDING_SYNC_CREATE |
+		G_BINDING_BIDIRECTIONAL);
+
+	g_object_bind_property_full (
+		smime_ext, "encryption-certificate",
+		widget, "sensitive",
+		G_BINDING_SYNC_CREATE,
+		mail_config_security_page_string_has_text,
+		NULL,
+		NULL, (GDestroyNotify) NULL);
+
+	text = _("Always encrypt to myself when sending encrypted messages");
+	widget = gtk_check_button_new_with_mnemonic (text);
+	gtk_widget_set_margin_left (widget, 12);
+	gtk_grid_attach (GTK_GRID (container), widget, 0, 6, 4, 1);
+	gtk_widget_show (widget);
+
+	g_object_bind_property (
+		smime_ext, "encrypt-to-self",
+		widget, "active",
+		G_BINDING_SYNC_CREATE |
+		G_BINDING_BIDIRECTIONAL);
+
+	g_object_bind_property_full (
+		smime_ext, "encryption-certificate",
+		widget, "sensitive",
+		G_BINDING_SYNC_CREATE,
+		mail_config_security_page_string_has_text,
+		NULL,
+		NULL, (GDestroyNotify) NULL);
+
+#endif /* HAVE_NSS */
+
+	g_object_unref (size_group);
+}
+
+static void
+e_mail_config_security_page_class_init (EMailConfigSecurityPageClass *class)
+{
+	GObjectClass *object_class;
+
+	g_type_class_add_private (
+		class, sizeof (EMailConfigSecurityPagePrivate));
+
+	object_class = G_OBJECT_CLASS (class);
+	object_class->set_property = mail_config_security_page_set_property;
+	object_class->get_property = mail_config_security_page_get_property;
+	object_class->dispose = mail_config_security_page_dispose;
+	object_class->constructed = mail_config_security_page_constructed;
+
+	g_object_class_install_property (
+		object_class,
+		PROP_IDENTITY_SOURCE,
+		g_param_spec_object (
+			"identity-source",
+			"Identity Source",
+			"Mail identity source being edited",
+			E_TYPE_SOURCE,
+			G_PARAM_READWRITE |
+			G_PARAM_CONSTRUCT_ONLY |
+			G_PARAM_STATIC_STRINGS));
+}
+
+static void
+e_mail_config_security_page_interface_init (EMailConfigPageInterface *interface)
+{
+	interface->title = _("Security");
+	interface->sort_order = E_MAIL_CONFIG_SECURITY_PAGE_SORT_ORDER;
+}
+
+static void
+e_mail_config_security_page_init (EMailConfigSecurityPage *page)
+{
+	page->priv = E_MAIL_CONFIG_SECURITY_PAGE_GET_PRIVATE (page);
+}
+
+EMailConfigPage *
+e_mail_config_security_page_new (ESource *identity_source)
+{
+	g_return_val_if_fail (E_IS_SOURCE (identity_source), NULL);
+
+	return g_object_new (
+		E_TYPE_MAIL_CONFIG_SECURITY_PAGE,
+		"identity-source", identity_source, NULL);
+}
+
+ESource *
+e_mail_config_security_page_get_identity_source (EMailConfigSecurityPage *page)
+{
+	g_return_val_if_fail (E_IS_MAIL_CONFIG_SECURITY_PAGE (page), NULL);
+
+	return page->priv->identity_source;
+}
+
diff --git a/mail/e-mail-config-security-page.h b/mail/e-mail-config-security-page.h
new file mode 100644
index 0000000..79174ea
--- /dev/null
+++ b/mail/e-mail-config-security-page.h
@@ -0,0 +1,73 @@
+/*
+ * e-mail-config-security-page.h
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) version 3.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with the program; if not, see <http://www.gnu.org/licenses/>
+ *
+ */
+
+#ifndef E_MAIL_CONFIG_SECURITY_PAGE_H
+#define E_MAIL_CONFIG_SECURITY_PAGE_H
+
+#include <gtk/gtk.h>
+#include <libedataserver/e-source.h>
+
+#include <mail/e-mail-config-page.h>
+
+/* Standard GObject macros */
+#define E_TYPE_MAIL_CONFIG_SECURITY_PAGE \
+	(e_mail_config_security_page_get_type ())
+#define E_MAIL_CONFIG_SECURITY_PAGE(obj) \
+	(G_TYPE_CHECK_INSTANCE_CAST \
+	((obj), E_TYPE_MAIL_CONFIG_SECURITY_PAGE, EMailConfigSecurityPage))
+#define E_MAIL_CONFIG_SECURITY_PAGE_CLASS(cls) \
+	(G_TYPE_CHECK_CLASS_CAST \
+	((cls), E_TYPE_MAIL_CONFIG_SECURITY_PAGE, EMailConfigSecurityPageClass))
+#define E_IS_MAIL_CONFIG_SECURITY_PAGE(obj) \
+	(G_TYPE_CHECK_INSTANCE_TYPE \
+	((obj), E_TYPE_MAIL_CONFIG_SECURITY_PAGE))
+#define E_IS_MAIL_CONFIG_SECURITY_PAGE_CLASS(cls) \
+	(G_TYPE_CHECK_CLASS_TYPE \
+	((cls), E_TYPE_MAIL_CONFIG_SECURITY_PAGE))
+#define E_MAIL_CONFIG_SECURITY_PAGE_GET_CLASS(obj) \
+	(G_TYPE_INSTANCE_GET_CLASS \
+	((obj), E_TYPE_MAIL_CONFIG_SECURITY_PAGE, EMailConfigSecurityPageClass))
+
+#define E_MAIL_CONFIG_SECURITY_PAGE_SORT_ORDER (600)
+
+G_BEGIN_DECLS
+
+typedef struct _EMailConfigSecurityPage EMailConfigSecurityPage;
+typedef struct _EMailConfigSecurityPageClass EMailConfigSecurityPageClass;
+typedef struct _EMailConfigSecurityPagePrivate EMailConfigSecurityPagePrivate;
+
+struct _EMailConfigSecurityPage {
+	GtkBox parent;
+	EMailConfigSecurityPagePrivate *priv;
+};
+
+struct _EMailConfigSecurityPageClass {
+	GtkBoxClass parent_class;
+};
+
+GType		e_mail_config_security_page_get_type
+						(void) G_GNUC_CONST;
+EMailConfigPage *
+		e_mail_config_security_page_new	(ESource *identity_source);
+ESource *	e_mail_config_security_page_get_identity_source
+						(EMailConfigSecurityPage *page);
+
+G_END_DECLS
+
+#endif /* E_MAIL_CONFIG_SECURITY_PAGE_H */
+
diff --git a/mail/e-mail-config-sending-page.c b/mail/e-mail-config-sending-page.c
new file mode 100644
index 0000000..5efb1b3
--- /dev/null
+++ b/mail/e-mail-config-sending-page.c
@@ -0,0 +1,69 @@
+/*
+ * e-mail-config-sending-page.c
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) version 3.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with the program; if not, see <http://www.gnu.org/licenses/>
+ *
+ */
+
+#include "e-mail-config-sending-page.h"
+
+#include <config.h>
+#include <glib/gi18n-lib.h>
+
+#include <libedataserver/e-source-mail-transport.h>
+
+/* Forward Declarations */
+static void	e_mail_config_sending_page_interface_init
+					(EMailConfigPageInterface *interface);
+
+G_DEFINE_TYPE_WITH_CODE (
+	EMailConfigSendingPage,
+	e_mail_config_sending_page,
+	E_TYPE_MAIL_CONFIG_SERVICE_PAGE,
+	G_IMPLEMENT_INTERFACE (
+		E_TYPE_MAIL_CONFIG_PAGE,
+		e_mail_config_sending_page_interface_init))
+
+static void
+e_mail_config_sending_page_class_init (EMailConfigSendingPageClass *class)
+{
+	EMailConfigServicePageClass *service_page_class;
+
+	service_page_class = E_MAIL_CONFIG_SERVICE_PAGE_CLASS (class);
+	service_page_class->extension_name = E_SOURCE_EXTENSION_MAIL_TRANSPORT;
+	service_page_class->provider_type = CAMEL_PROVIDER_TRANSPORT;
+}
+
+static void
+e_mail_config_sending_page_interface_init (EMailConfigPageInterface *interface)
+{
+	interface->title = _("Sending Email");
+	interface->sort_order = E_MAIL_CONFIG_SENDING_PAGE_SORT_ORDER;
+}
+
+static void
+e_mail_config_sending_page_init (EMailConfigSendingPage *page)
+{
+}
+
+EMailConfigPage *
+e_mail_config_sending_page_new (ESourceRegistry *registry)
+{
+	g_return_val_if_fail (E_IS_SOURCE_REGISTRY (registry), NULL);
+
+	return g_object_new (
+		E_TYPE_MAIL_CONFIG_SENDING_PAGE,
+		"registry", registry, NULL);
+}
+
diff --git a/mail/e-mail-config-sending-page.h b/mail/e-mail-config-sending-page.h
new file mode 100644
index 0000000..4727602
--- /dev/null
+++ b/mail/e-mail-config-sending-page.h
@@ -0,0 +1,68 @@
+/*
+ * e-mail-config-sending-page.h
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) version 3.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with the program; if not, see <http://www.gnu.org/licenses/>
+ *
+ */
+
+#ifndef E_MAIL_CONFIG_SENDING_PAGE_H
+#define E_MAIL_CONFIG_SENDING_PAGE_H
+
+#include <mail/e-mail-config-page.h>
+#include <mail/e-mail-config-service-page.h>
+
+/* Standard GObject macros */
+#define E_TYPE_MAIL_CONFIG_SENDING_PAGE \
+	(e_mail_config_sending_page_get_type ())
+#define E_MAIL_CONFIG_SENDING_PAGE(obj) \
+	(G_TYPE_CHECK_INSTANCE_CAST \
+	((obj), E_TYPE_MAIL_CONFIG_SENDING_PAGE, EMailConfigSendingPage))
+#define E_MAIL_CONFIG_SENDING_PAGE_CLASS(cls) \
+	(G_TYPE_CHECK_CLASS_CAST \
+	((cls), E_TYPE_MAIL_CONFIG_SENDING_PAGE, EMailConfigSendingPageClass))
+#define E_IS_MAIL_CONFIG_SENDING_PAGE(obj) \
+	(G_TYPE_CHECK_INSTANCE_TYPE \
+	((obj), E_TYPE_MAIL_CONFIG_SENDING_PAGE))
+#define E_IS_MAIL_CONFIG_SENDING_PAGE_CLASS(cls) \
+	(G_TYPE_CHECK_CLASS_TYPE \
+	((cls), E_TYPE_MAIL_CONFIG_SENDING_PAGE))
+#define E_MAIL_CONFIG_SENDING_PAGE_GET_CLASS(obj) \
+	(G_TYPE_INSTANCE_GET_CLASS \
+	((obj), E_TYPE_MAIL_CONFIG_SENDING_PAGE, EMailConfigSendingPageClass))
+
+#define E_MAIL_CONFIG_SENDING_PAGE_SORT_ORDER (400)
+
+G_BEGIN_DECLS
+
+typedef struct _EMailConfigSendingPage EMailConfigSendingPage;
+typedef struct _EMailConfigSendingPageClass EMailConfigSendingPageClass;
+typedef struct _EMailConfigSendingPagePrivate EMailConfigSendingPagePrivate;
+
+struct _EMailConfigSendingPage {
+	EMailConfigServicePage parent;
+};
+
+struct _EMailConfigSendingPageClass {
+	EMailConfigServicePageClass parent_class;
+};
+
+GType		e_mail_config_sending_page_get_type
+						(void) G_GNUC_CONST;
+EMailConfigPage *
+		e_mail_config_sending_page_new	(ESourceRegistry *registry);
+
+G_END_DECLS
+
+#endif /* E_MAIL_CONFIG_SENDING_PAGE_H */
+
diff --git a/mail/e-mail-config-service-backend.c b/mail/e-mail-config-service-backend.c
new file mode 100644
index 0000000..2f75a17
--- /dev/null
+++ b/mail/e-mail-config-service-backend.c
@@ -0,0 +1,139 @@
+/*
+ * e-mail-config-service-backend.c
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) version 3.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with the program; if not, see <http://www.gnu.org/licenses/>
+ *
+ */
+
+#include "e-mail-config-service-backend.h"
+
+#include <mail/e-mail-config-service-page.h>
+
+G_DEFINE_TYPE (
+	EMailConfigServiceBackend,
+	e_mail_config_service_backend,
+	E_TYPE_EXTENSION)
+
+static void
+mail_config_service_backend_insert_widgets (EMailConfigServiceBackend *backend,
+                                            ESource *scratch_source,
+                                            GtkBox *parent)
+{
+	/* does nothing */
+}
+
+static gboolean
+mail_config_service_backend_check_complete (EMailConfigServiceBackend *backend,
+                                            ESource *scratch_source)
+{
+	return TRUE;
+}
+
+static void
+mail_config_service_backend_commit_changes (EMailConfigServiceBackend *backend,
+                                            ESource *scratch_source)
+{
+	/* does nothing */
+}
+
+static void
+e_mail_config_service_backend_class_init (EMailConfigServiceBackendClass *class)
+{
+	EExtensionClass *extension_class;
+
+	extension_class = E_EXTENSION_CLASS (class);
+	extension_class->extensible_type = E_TYPE_MAIL_CONFIG_SERVICE_PAGE;
+
+	class->insert_widgets = mail_config_service_backend_insert_widgets;
+	class->check_complete = mail_config_service_backend_check_complete;
+	class->commit_changes = mail_config_service_backend_commit_changes;
+}
+
+static void
+e_mail_config_service_backend_init (EMailConfigServiceBackend *backend)
+{
+}
+
+EMailConfigServicePage *
+e_mail_config_service_backend_get_page (EMailConfigServiceBackend *backend)
+{
+	EExtensible *extensible;
+
+	g_return_val_if_fail (E_IS_MAIL_CONFIG_SERVICE_BACKEND (backend), NULL);
+
+	extensible = e_extension_get_extensible (E_EXTENSION (backend));
+
+	return E_MAIL_CONFIG_SERVICE_PAGE (extensible);
+}
+
+CamelProvider *
+e_mail_config_service_backend_get_provider (EMailConfigServiceBackend *backend)
+{
+	EMailConfigServiceBackendClass *class;
+
+	g_return_val_if_fail (E_IS_MAIL_CONFIG_SERVICE_BACKEND (backend), NULL);
+
+	class = E_MAIL_CONFIG_SERVICE_BACKEND_GET_CLASS (backend);
+	g_return_val_if_fail (class->backend_name != NULL, NULL);
+
+	return camel_provider_get (class->backend_name, NULL);
+}
+
+void
+e_mail_config_service_backend_insert_widgets (EMailConfigServiceBackend *backend,
+                                              ESource *scratch_source,
+                                              GtkBox *parent)
+{
+	EMailConfigServiceBackendClass *class;
+
+	g_return_if_fail (E_IS_MAIL_CONFIG_SERVICE_BACKEND (backend));
+	g_return_if_fail (E_IS_SOURCE (scratch_source));
+	g_return_if_fail (GTK_IS_BOX (parent));
+
+	class = E_MAIL_CONFIG_SERVICE_BACKEND_GET_CLASS (backend);
+	g_return_if_fail (class->insert_widgets != NULL);
+
+	return class->insert_widgets (backend, scratch_source, parent);
+}
+
+gboolean
+e_mail_config_service_backend_check_complete (EMailConfigServiceBackend *backend,
+                                              ESource *scratch_source)
+{
+	EMailConfigServiceBackendClass *class;
+
+	g_return_val_if_fail (E_IS_MAIL_CONFIG_SERVICE_BACKEND (backend), FALSE);
+	g_return_val_if_fail (E_IS_SOURCE (scratch_source), FALSE);
+
+	class = E_MAIL_CONFIG_SERVICE_BACKEND_GET_CLASS (backend);
+	g_return_val_if_fail (class->check_complete != NULL, FALSE);
+
+	return class->check_complete (backend, scratch_source);
+}
+
+void
+e_mail_config_service_backend_commit_changes (EMailConfigServiceBackend *backend,
+                                              ESource *scratch_source)
+{
+	EMailConfigServiceBackendClass *class;
+
+	g_return_if_fail (E_IS_MAIL_CONFIG_SERVICE_BACKEND (backend));
+	g_return_if_fail (E_IS_SOURCE (scratch_source));
+
+	class = E_MAIL_CONFIG_SERVICE_BACKEND_GET_CLASS (backend);
+	g_return_if_fail (class->commit_changes != NULL);
+
+	class->commit_changes (backend, scratch_source);
+}
+
diff --git a/mail/e-mail-config-service-backend.h b/mail/e-mail-config-service-backend.h
new file mode 100644
index 0000000..4f69cd1
--- /dev/null
+++ b/mail/e-mail-config-service-backend.h
@@ -0,0 +1,97 @@
+/*
+ * e-mail-config-service-backend.h
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) version 3.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with the program; if not, see <http://www.gnu.org/licenses/>
+ *
+ */
+
+#ifndef E_MAIL_CONFIG_SERVICE_BACKEND_H
+#define E_MAIL_CONFIG_SERVICE_BACKEND_H
+
+#include <gtk/gtk.h>
+#include <libebackend/e-extension.h>
+#include <libedataserver/e-source.h>
+
+#include <mail/e-mail-config-service-page.h>
+
+/* Standard GObject macros */
+#define E_TYPE_MAIL_CONFIG_SERVICE_BACKEND \
+	(e_mail_config_service_backend_get_type ())
+#define E_MAIL_CONFIG_SERVICE_BACKEND(obj) \
+	(G_TYPE_CHECK_INSTANCE_CAST \
+	((obj), E_TYPE_MAIL_CONFIG_SERVICE_BACKEND, EMailConfigServiceBackend))
+#define E_MAIL_CONFIG_SERVICE_BACKEND_CLASS(cls) \
+	(G_TYPE_CHECK_CLASS_CAST \
+	((cls), E_TYPE_MAIL_CONFIG_SERVICE_BACKEND, EMailConfigServiceBackendClass))
+#define E_IS_MAIL_CONFIG_SERVICE_BACKEND(obj) \
+	(G_TYPE_CHECK_INSTANCE_TYPE \
+	((obj), E_TYPE_MAIL_CONFIG_SERVICE_BACKEND))
+#define E_IS_MAIL_CONFIG_SERVICE_BACKEND_CLASS(cls) \
+	(G_TYPE_CHECK_CLASS_TYPE \
+	((cls), E_TYPE_MAIL_CONFIG_SERVICE_BACKEND))
+#define E_MAIL_CONFIG_SERVICE_BACKEND_GET_CLASS(obj) \
+	(G_TYPE_INSTANCE_GET_CLASS \
+	((obj), E_TYPE_MAIL_CONFIG_SERVICE_BACKEND, EMailConfigServiceBackendClass))
+
+G_BEGIN_DECLS
+
+typedef struct _EMailConfigServiceBackend EMailConfigServiceBackend;
+typedef struct _EMailConfigServiceBackendClass EMailConfigServiceBackendClass;
+typedef struct _EMailConfigServiceBackendPrivate EMailConfigServiceBackendPrivate;
+
+struct _EMailConfigServiceBackend {
+	EExtension parent;
+	EMailConfigServiceBackendPrivate *priv;
+};
+
+struct _EMailConfigServiceBackendClass {
+	EExtensionClass parent_class;
+
+	const gchar *backend_name;
+
+	/* Signals */
+	void		(*insert_widgets)
+					(EMailConfigServiceBackend *backend,
+					 ESource *scratch_source,
+					 GtkBox *parent);
+	gboolean	(*check_complete)
+					(EMailConfigServiceBackend *backend,
+					 ESource *scratch_source);
+	void		(*commit_changes)
+					(EMailConfigServiceBackend *backend,
+					 ESource *scratch_source);
+};
+
+GType		e_mail_config_service_backend_get_type
+					(void) G_GNUC_CONST;
+EMailConfigServicePage *
+		e_mail_config_service_backend_get_page
+					(EMailConfigServiceBackend *backend);
+CamelProvider *	e_mail_config_service_backend_get_provider
+					(EMailConfigServiceBackend *backend);
+void		e_mail_config_service_backend_insert_widgets
+					(EMailConfigServiceBackend *backend,
+					 ESource *scratch_source,
+					 GtkBox *parent);
+gboolean	e_mail_config_service_backend_check_complete
+					(EMailConfigServiceBackend *backend,
+					 ESource *scratch_source);
+void		e_mail_config_service_backend_commit_changes
+					(EMailConfigServiceBackend *backend,
+					 ESource *scratch_source);
+
+G_END_DECLS
+
+#endif /* E_MAIL_CONFIG_SERVICE_BACKEND_H */
+
diff --git a/mail/e-mail-config-service-page.c b/mail/e-mail-config-service-page.c
new file mode 100644
index 0000000..4dabceb
--- /dev/null
+++ b/mail/e-mail-config-service-page.c
@@ -0,0 +1,775 @@
+/*
+ * e-mail-config-service-page.c
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) version 3.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with the program; if not, see <http://www.gnu.org/licenses/>
+ *
+ */
+
+#include "e-mail-config-service-page.h"
+
+#include <config.h>
+#include <glib/gi18n-lib.h>
+
+#include <camel/camel.h>
+#include <libebackend/e-extensible.h>
+#include <libedataserver/e-source-camel.h>
+#include <libedataserver/e-source-backend.h>
+
+#include <libevolution-utils/e-alert-sink.h>
+#include <libevolution-utils/e-alert-dialog.h>
+#include <misc/e-activity-bar.h>
+#include <misc/e-alert-bar.h>
+#include <misc/e-source-notebook.h>
+
+#include <mail/e-mail-config-page.h>
+#include <mail/e-mail-config-service-backend.h>
+
+#define E_MAIL_CONFIG_SERVICE_PAGE_GET_PRIVATE(obj) \
+	(G_TYPE_INSTANCE_GET_PRIVATE \
+	((obj), E_TYPE_MAIL_CONFIG_SERVICE_PAGE, EMailConfigServicePagePrivate))
+
+typedef struct _Candidate Candidate;
+
+struct _EMailConfigServicePagePrivate {
+	ESourceRegistry *registry;
+	ESource *active_source;
+
+	GHashTable *backends;
+	GPtrArray *candidates;
+
+	GtkWidget *type_combo;
+	GtkWidget *type_label;
+	GtkWidget *desc_label;
+	GtkWidget *notebook;
+	GtkWidget *activity_bar;
+	GtkWidget *alert_bar;
+};
+
+struct _Candidate {
+	GtkWidget *widget;
+	ESource *scratch_source;
+	EMailConfigServiceBackend *backend;
+
+	CamelSettings *settings;
+	gulong settings_notify_handler_id;
+};
+
+enum {
+	PROP_0,
+	PROP_ACTIVE_SOURCE,
+	PROP_REGISTRY
+};
+
+/* Forward Declarations */
+static void	e_mail_config_service_page_alert_sink_init
+					(EAlertSinkInterface *interface);
+static void	e_mail_config_service_page_interface_init
+					(EMailConfigPageInterface *interface);
+
+G_DEFINE_ABSTRACT_TYPE_WITH_CODE (
+	EMailConfigServicePage,
+	e_mail_config_service_page,
+	GTK_TYPE_BOX,
+	G_IMPLEMENT_INTERFACE (
+		E_TYPE_EXTENSIBLE, NULL)
+	G_IMPLEMENT_INTERFACE (
+		E_TYPE_ALERT_SINK,
+		e_mail_config_service_page_alert_sink_init)
+	G_IMPLEMENT_INTERFACE (
+		E_TYPE_MAIL_CONFIG_PAGE,
+		e_mail_config_service_page_interface_init))
+
+static void
+mail_config_service_page_free_candidate (Candidate *candidate)
+{
+	g_object_unref (candidate->widget);
+	g_object_unref (candidate->scratch_source);
+	g_object_unref (candidate->backend);
+
+	g_signal_handler_disconnect (
+		candidate->settings,
+		candidate->settings_notify_handler_id);
+	g_object_unref (candidate->settings);
+
+	g_slice_free (Candidate, candidate);
+}
+
+static void
+mail_config_service_page_init_backends (EMailConfigServicePage *page)
+{
+	GList *list, *iter;
+
+	page->priv->backends = g_hash_table_new_full (
+		(GHashFunc) g_str_hash,
+		(GEqualFunc) g_str_equal,
+		(GDestroyNotify) g_free,
+		(GDestroyNotify) g_object_unref);
+
+	e_extensible_load_extensions (E_EXTENSIBLE (page));
+
+	list = e_extensible_list_extensions (
+		E_EXTENSIBLE (page), E_TYPE_MAIL_CONFIG_SERVICE_BACKEND);
+
+	for (iter = list; iter != NULL; iter = g_list_next (iter)) {
+		EMailConfigServiceBackend *backend;
+		EMailConfigServiceBackendClass *class;
+
+		backend = E_MAIL_CONFIG_SERVICE_BACKEND (iter->data);
+		class = E_MAIL_CONFIG_SERVICE_BACKEND_GET_CLASS (backend);
+
+		if (class->backend_name != NULL)
+			g_hash_table_insert (
+				page->priv->backends,
+				g_strdup (class->backend_name),
+				g_object_ref (backend));
+	}
+
+	g_list_free (list);
+}
+
+static void
+mail_config_service_page_settings_notify_cb (CamelSettings *settings,
+                                             GParamSpec *pspec,
+                                             EMailConfigPage *page)
+{
+	e_mail_config_page_changed (page);
+}
+
+static gboolean
+mail_config_service_page_backend_name_to_description (GBinding *binding,
+                                                      const GValue *source_value,
+                                                      GValue *target_value,
+                                                      gpointer user_data)
+{
+	CamelProvider *provider;
+	const gchar *description;
+	const gchar *backend_name;
+
+	backend_name = g_value_get_string (source_value);
+
+	/* XXX Silly special case. */
+	if (backend_name == NULL)
+		backend_name = "none";
+
+	provider = camel_provider_get (backend_name, NULL);
+
+	if (provider != NULL && provider->description != NULL)
+		description = g_dgettext (
+			provider->translation_domain,
+			provider->description);
+	else
+		description = "";
+
+	g_value_set_string (target_value, description);
+
+	return TRUE;
+}
+
+static Candidate *
+mail_config_service_page_get_active_candidate (EMailConfigServicePage *page)
+{
+	GtkComboBox *combo_box;
+	gint active;
+
+	combo_box = GTK_COMBO_BOX (page->priv->type_combo);
+	active = gtk_combo_box_get_active (combo_box);
+	g_return_val_if_fail (active >= 0, NULL);
+
+	return g_ptr_array_index (page->priv->candidates, active);
+}
+
+static void
+mail_config_service_page_set_registry (EMailConfigServicePage *page,
+                                       ESourceRegistry *registry)
+{
+	g_return_if_fail (E_IS_SOURCE_REGISTRY (registry));
+	g_return_if_fail (page->priv->registry == NULL);
+
+	page->priv->registry = g_object_ref (registry);
+}
+
+static void
+mail_config_service_page_set_property (GObject *object,
+                                       guint property_id,
+                                       const GValue *value,
+                                       GParamSpec *pspec)
+{
+	switch (property_id) {
+		case PROP_ACTIVE_SOURCE:
+			e_mail_config_service_page_set_active_source (
+				E_MAIL_CONFIG_SERVICE_PAGE (object),
+				g_value_get_object (value));
+			return;
+
+		case PROP_REGISTRY:
+			mail_config_service_page_set_registry (
+				E_MAIL_CONFIG_SERVICE_PAGE (object),
+				g_value_get_object (value));
+			return;
+	}
+
+	G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+}
+
+static void
+mail_config_service_page_get_property (GObject *object,
+                                       guint property_id,
+                                       GValue *value,
+                                       GParamSpec *pspec)
+{
+	switch (property_id) {
+		case PROP_ACTIVE_SOURCE:
+			g_value_set_object (
+				value,
+				e_mail_config_service_page_get_active_source (
+				E_MAIL_CONFIG_SERVICE_PAGE (object)));
+			return;
+
+		case PROP_REGISTRY:
+			g_value_set_object (
+				value,
+				e_mail_config_service_page_get_registry (
+				E_MAIL_CONFIG_SERVICE_PAGE (object)));
+			return;
+	}
+
+	G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+}
+
+static void
+mail_config_service_page_dispose (GObject *object)
+{
+	EMailConfigServicePagePrivate *priv;
+
+	priv = E_MAIL_CONFIG_SERVICE_PAGE_GET_PRIVATE (object);
+
+	if (priv->registry != NULL) {
+		g_object_unref (priv->registry);
+		priv->registry = NULL;
+	}
+
+	if (priv->active_source != NULL) {
+		g_object_unref (priv->active_source);
+		priv->active_source = NULL;
+	}
+
+	g_hash_table_remove_all (priv->backends);
+	g_ptr_array_set_size (priv->candidates, 0);
+
+	/* Chain up to parent's dispose() method. */
+	G_OBJECT_CLASS (e_mail_config_service_page_parent_class)->dispose (object);
+}
+
+static void
+mail_config_service_page_finalize (GObject *object)
+{
+	EMailConfigServicePagePrivate *priv;
+
+	priv = E_MAIL_CONFIG_SERVICE_PAGE_GET_PRIVATE (object);
+
+	g_hash_table_destroy (priv->backends);
+	g_ptr_array_free (priv->candidates, TRUE);
+
+	/* Chain up to parent's finalize() method. */
+	G_OBJECT_CLASS (e_mail_config_service_page_parent_class)->finalize (object);
+}
+
+static void
+mail_config_service_page_constructed (GObject *object)
+{
+	EMailConfigServicePage *page;
+
+	page = E_MAIL_CONFIG_SERVICE_PAGE (object);
+
+	mail_config_service_page_init_backends (page);
+}
+
+static gboolean
+mail_config_service_page_check_complete (EMailConfigPage *page)
+{
+	EMailConfigServicePagePrivate *priv;
+	Candidate *candidate;
+	GtkComboBox *type_combo;
+
+	priv = E_MAIL_CONFIG_SERVICE_PAGE_GET_PRIVATE (page);
+
+	/* Make sure the combo box has an active item. */
+	type_combo = GTK_COMBO_BOX (priv->type_combo);
+	if (gtk_combo_box_get_active_id (type_combo) == NULL)
+		return FALSE;
+
+	candidate = mail_config_service_page_get_active_candidate (
+		E_MAIL_CONFIG_SERVICE_PAGE (page));
+	g_return_val_if_fail (candidate != NULL, FALSE);
+
+	return e_mail_config_service_backend_check_complete (
+		candidate->backend, candidate->scratch_source);
+}
+
+static void
+mail_config_service_page_commit_changes (EMailConfigPage *page,
+                                         GQueue *source_queue)
+{
+	Candidate *candidate;
+
+	candidate = mail_config_service_page_get_active_candidate (
+		E_MAIL_CONFIG_SERVICE_PAGE (page));
+	g_return_if_fail (candidate != NULL);
+
+	e_mail_config_service_backend_commit_changes (
+		candidate->backend, candidate->scratch_source);
+}
+
+static void
+mail_config_service_page_submit_alert (EAlertSink *alert_sink,
+                                       EAlert *alert)
+{
+	EMailConfigServicePagePrivate *priv;
+	EAlertBar *alert_bar;
+	GtkWidget *dialog;
+	GtkWindow *parent;
+
+	priv = E_MAIL_CONFIG_SERVICE_PAGE_GET_PRIVATE (alert_sink);
+
+	switch (e_alert_get_message_type (alert)) {
+		case GTK_MESSAGE_INFO:
+		case GTK_MESSAGE_WARNING:
+		case GTK_MESSAGE_ERROR:
+			alert_bar = E_ALERT_BAR (priv->alert_bar);
+			e_alert_bar_add_alert (alert_bar, alert);
+			break;
+
+		default:
+			parent = GTK_WINDOW (alert_sink);
+			dialog = e_alert_dialog_new (parent, alert);
+			gtk_dialog_run (GTK_DIALOG (dialog));
+			gtk_widget_destroy (dialog);
+			break;
+	}
+}
+
+static void
+e_mail_config_service_page_class_init (EMailConfigServicePageClass *class)
+{
+	GObjectClass *object_class;
+
+	g_type_class_add_private (class, sizeof (EMailConfigServicePagePrivate));
+
+	object_class = G_OBJECT_CLASS (class);
+	object_class->set_property = mail_config_service_page_set_property;
+	object_class->get_property = mail_config_service_page_get_property;
+	object_class->dispose = mail_config_service_page_dispose;
+	object_class->finalize = mail_config_service_page_finalize;
+	object_class->constructed = mail_config_service_page_constructed;
+
+	g_object_class_install_property (
+		object_class,
+		PROP_ACTIVE_SOURCE,
+		g_param_spec_object (
+			"active-source",
+			"Active Source",
+			"The active data source",
+			E_TYPE_SOURCE,
+			G_PARAM_READWRITE |
+			G_PARAM_STATIC_STRINGS));
+
+	g_object_class_install_property (
+		object_class,
+		PROP_REGISTRY,
+		g_param_spec_object (
+			"registry",
+			"Registry",
+			"Data source registry",
+			E_TYPE_SOURCE_REGISTRY,
+			G_PARAM_READWRITE |
+			G_PARAM_CONSTRUCT_ONLY |
+			G_PARAM_STATIC_STRINGS));
+}
+
+static void
+e_mail_config_service_page_alert_sink_init (EAlertSinkInterface *interface)
+{
+	interface->submit_alert = mail_config_service_page_submit_alert;
+}
+
+static void
+e_mail_config_service_page_interface_init (EMailConfigPageInterface *interface)
+{
+	interface->check_complete = mail_config_service_page_check_complete;
+	interface->commit_changes = mail_config_service_page_commit_changes;
+}
+
+static void
+e_mail_config_service_page_init (EMailConfigServicePage *page)
+{
+	GPtrArray *candidates;
+	PangoAttribute *attr;
+	PangoAttrList *attr_list;
+	GtkLabel *label;
+	GtkWidget *frame;
+	GtkWidget *widget;
+	GtkWidget *container;
+
+	/* The candidates array holds scratch ESources, one for each
+	 * item in the "type" combo box.  Scratch ESources are never
+	 * added to the registry, so backend extensions can make any
+	 * changes they want to them.  Whichever scratch ESource is
+	 * "active" (selected in the "type" combo box) when the user
+	 * clicks OK wins and is written to disk.  The others are
+	 * discarded. */
+	candidates = g_ptr_array_new_with_free_func (
+		(GDestroyNotify) mail_config_service_page_free_candidate);
+
+	gtk_box_set_spacing (GTK_BOX (page), 12);
+
+	gtk_orientable_set_orientation (
+		GTK_ORIENTABLE (page), GTK_ORIENTATION_VERTICAL);
+
+	page->priv = E_MAIL_CONFIG_SERVICE_PAGE_GET_PRIVATE (page);
+	page->priv->candidates = candidates;
+
+	/* Either the combo box or the label is shown, never both.
+	 * But we create both widgets and keep them both up-to-date
+	 * regardless just because it makes the logic simpler. */
+
+	container = GTK_WIDGET (page);
+
+	widget = gtk_grid_new ();
+	gtk_grid_set_row_spacing (GTK_GRID (widget), 12);
+	gtk_box_pack_start (GTK_BOX (container), widget, FALSE, FALSE, 0);
+	gtk_widget_show (widget);
+
+	container = widget;
+
+	attr_list = pango_attr_list_new ();
+
+	attr = pango_attr_weight_new (PANGO_WEIGHT_BOLD);
+	pango_attr_list_insert (attr_list, attr);
+
+	widget = gtk_label_new_with_mnemonic (_("Server _Type:"));
+	gtk_widget_set_margin_right (widget, 12);
+	gtk_misc_set_alignment (GTK_MISC (widget), 1.0, 0.5);
+	gtk_grid_attach (GTK_GRID (container), widget, 0, 0, 1, 1);
+	gtk_widget_show (widget);
+
+	label = GTK_LABEL (widget);
+
+	widget = gtk_combo_box_text_new ();
+	gtk_widget_set_hexpand (widget, TRUE);
+	gtk_label_set_mnemonic_widget (label, widget);
+	gtk_grid_attach (GTK_GRID (container), widget, 1, 0, 1, 1);
+	page->priv->type_combo = widget;  /* not referenced */
+	gtk_widget_show (widget);
+
+	widget = gtk_label_new (NULL);
+	gtk_widget_set_hexpand (widget, TRUE);
+	gtk_misc_set_alignment (GTK_MISC (widget), 0.0, 0.5);
+	gtk_label_set_attributes (GTK_LABEL (widget), attr_list);
+	gtk_grid_attach (GTK_GRID (container), widget, 2, 0, 1, 1);
+	page->priv->type_label = widget;  /* not referenced */
+	gtk_widget_show (widget);
+
+	widget = gtk_label_new (_("Description:"));
+	gtk_widget_set_margin_right (widget, 12);
+	gtk_misc_set_alignment (GTK_MISC (widget), 1.0, 0.0);
+	gtk_grid_attach (GTK_GRID (container), widget, 0, 1, 1, 1);
+	gtk_widget_show (widget);
+
+	widget = gtk_label_new (NULL);
+	gtk_label_set_line_wrap (GTK_LABEL (widget), TRUE);
+	gtk_misc_set_alignment (GTK_MISC (widget), 0.0, 0.5);
+	gtk_grid_attach (GTK_GRID (container), widget, 1, 1, 2, 1);
+	page->priv->desc_label = widget;  /* not referenced */
+	gtk_widget_show (widget);
+
+	pango_attr_list_unref (attr_list);
+
+	container = GTK_WIDGET (page);
+
+	widget = gtk_separator_new (GTK_ORIENTATION_HORIZONTAL);
+	gtk_box_pack_start (GTK_BOX (container), widget, FALSE, FALSE, 0);
+	gtk_widget_show (widget);
+
+	widget = e_source_notebook_new ();
+	gtk_box_pack_start (GTK_BOX (container), widget, TRUE, TRUE, 0);
+	page->priv->notebook = widget;  /* not referenced */
+	gtk_widget_show (widget);
+
+	widget = gtk_frame_new (NULL);
+	gtk_frame_set_shadow_type (GTK_FRAME (widget), GTK_SHADOW_IN);
+	gtk_box_pack_start (GTK_BOX (container), widget, FALSE, FALSE, 0);
+	/* Visibility is bound to the EActivityBar. */
+
+	frame = widget;
+
+	widget = e_activity_bar_new ();
+	gtk_container_add (GTK_CONTAINER (frame), widget);
+	page->priv->activity_bar = widget;  /* not referenced */
+	/* EActivityBar controls its own visibility. */
+
+	g_object_bind_property (
+		widget, "visible",
+		frame, "visible",
+		G_BINDING_SYNC_CREATE);
+
+	widget = gtk_frame_new (NULL);
+	gtk_frame_set_shadow_type (GTK_FRAME (widget), GTK_SHADOW_IN);
+	gtk_box_pack_start (GTK_BOX (container), widget, FALSE, FALSE, 0);
+	/* Visibility is bound to the EAlertBar. */
+
+	frame = widget;
+
+	widget = e_alert_bar_new ();
+	gtk_container_add (GTK_CONTAINER (frame), widget);
+	page->priv->alert_bar = widget;  /* not referenced */
+	/* EAlertBar controls its own visibility. */
+
+	g_object_bind_property (
+		widget, "visible",
+		frame, "visible",
+		G_BINDING_SYNC_CREATE);
+
+	/* Keep the combo box's active row number synchronized with the
+	 * notebook's current page number.  Avoid G_BINDING_SYNC_CREATE
+	 * since we haven't added any combo box rows. */
+	g_object_bind_property (
+		page->priv->type_combo, "active",
+		page->priv->notebook, "page",
+		G_BINDING_BIDIRECTIONAL);
+
+	/* Keep the active notebook data source synchronized with our
+	 * own "active-source" property.  Avoid G_BINDING_SYNC_CREATE
+	 * since we haven't added any notebook pages. */
+	g_object_bind_property (
+		page, "active-source",
+		page->priv->notebook, "active-source",
+		G_BINDING_BIDIRECTIONAL);
+
+	/* This keeps the description field up-to-date. */
+	g_object_bind_property_full (
+		page->priv->type_combo, "active-id",
+		page->priv->desc_label, "label",
+		G_BINDING_DEFAULT,
+		mail_config_service_page_backend_name_to_description,
+		NULL,
+		NULL, (GDestroyNotify) NULL);
+
+	/* For the "Server Type", either the combo
+	 * box or the label is visible, never both. */
+	g_object_bind_property (
+		page->priv->type_combo, "visible",
+		page->priv->type_label, "visible",
+		G_BINDING_SYNC_CREATE |
+		G_BINDING_BIDIRECTIONAL |
+		G_BINDING_INVERT_BOOLEAN);
+
+	g_signal_connect_swapped (
+		page->priv->type_combo, "changed",
+		G_CALLBACK (e_mail_config_page_changed), page);
+}
+
+ESource *
+e_mail_config_service_page_get_active_source (EMailConfigServicePage *page)
+{
+	g_return_val_if_fail (E_IS_MAIL_CONFIG_SERVICE_PAGE (page), NULL);
+
+	return page->priv->active_source;
+}
+
+void
+e_mail_config_service_page_set_active_source (EMailConfigServicePage *page,
+                                              ESource *scratch_source)
+{
+	g_return_if_fail (E_IS_MAIL_CONFIG_SERVICE_PAGE (page));
+
+	if (scratch_source != NULL) {
+		g_return_if_fail (E_IS_SOURCE (scratch_source));
+		g_object_ref (scratch_source);
+	}
+
+	if (page->priv->active_source != NULL)
+		g_object_unref (page->priv->active_source);
+
+	page->priv->active_source = scratch_source;
+
+	g_object_notify (G_OBJECT (page), "active-source");
+}
+
+ESourceRegistry *
+e_mail_config_service_page_get_registry (EMailConfigServicePage *page)
+{
+	g_return_val_if_fail (E_IS_MAIL_CONFIG_SERVICE_PAGE (page), NULL);
+
+	return page->priv->registry;
+}
+
+CamelProvider *
+e_mail_config_service_page_get_provider (EMailConfigServicePage *page,
+                                         ESource *scratch_source)
+{
+	ESourceBackend *backend_ext;
+	EMailConfigServicePageClass *class;
+	const gchar *backend_name;
+	const gchar *extension_name;
+
+	g_return_val_if_fail (E_IS_MAIL_CONFIG_SERVICE_PAGE (page), NULL);
+	g_return_val_if_fail (E_IS_SOURCE (scratch_source), NULL);
+
+	class = E_MAIL_CONFIG_SERVICE_PAGE_GET_CLASS (page);
+	extension_name = class->extension_name;
+	backend_ext = e_source_get_extension (scratch_source, extension_name);
+	backend_name = e_source_backend_get_backend_name (backend_ext);
+
+	return camel_provider_get (backend_name, NULL);
+}
+
+CamelSettings *
+e_mail_config_service_page_get_settings (EMailConfigServicePage *page,
+                                         ESource *scratch_source)
+{
+	ESourceCamel *camel_ext;
+	ESourceBackend *backend_ext;
+	EMailConfigServicePageClass *class;
+	const gchar *backend_name;
+	const gchar *extension_name;
+
+	g_return_val_if_fail (E_IS_MAIL_CONFIG_SERVICE_PAGE (page), NULL);
+	g_return_val_if_fail (E_IS_SOURCE (scratch_source), NULL);
+
+	class = E_MAIL_CONFIG_SERVICE_PAGE_GET_CLASS (page);
+	extension_name = class->extension_name;
+	backend_ext = e_source_get_extension (scratch_source, extension_name);
+	backend_name = e_source_backend_get_backend_name (backend_ext);
+
+	extension_name = e_source_camel_get_extension_name (backend_name);
+	camel_ext = e_source_get_extension (scratch_source, extension_name);
+
+	return e_source_camel_get_settings (camel_ext);
+}
+
+void
+e_mail_config_service_page_add_scratch_source (EMailConfigServicePage *page,
+                                               ESource *scratch_source)
+{
+	GtkWidget *widget;
+	GtkLabel *type_label;
+	GtkComboBoxText *type_combo;
+	CamelSettings *settings;
+	Candidate *candidate;
+	CamelProvider *provider;
+	ESourceBackend *extension;
+	ESourceNotebook *notebook;
+	EMailConfigServiceBackend *backend;
+	EMailConfigServicePageClass *class;
+	const gchar *extension_name;
+	const gchar *backend_name;
+	const gchar *display_name;
+	gulong handler_id;
+	gint page_num;
+
+	g_return_if_fail (E_IS_MAIL_CONFIG_SERVICE_PAGE (page));
+	g_return_if_fail (E_IS_SOURCE (scratch_source));
+
+	/* Get the backend name for this scratch source. */
+	class = E_MAIL_CONFIG_SERVICE_PAGE_GET_CLASS (page);
+	extension_name = class->extension_name;
+	extension = e_source_get_extension (scratch_source, extension_name);
+	backend_name = e_source_backend_get_backend_name (extension);
+	g_return_if_fail (backend_name != NULL);
+
+	/* Make sure we have a corresponding CamelProvider. */
+	provider = camel_provider_get (backend_name, NULL);
+	g_return_if_fail (provider != NULL);
+
+	/* Make sure we have a corresponding CamelSettings. */
+	settings = e_mail_config_service_page_get_settings (page, scratch_source);
+	g_return_if_fail (CAMEL_IS_SETTINGS (settings));
+
+	/* Make sure we have a corresponding EMailConfigServicePageBackend. */
+	backend = g_hash_table_lookup (page->priv->backends, backend_name);
+	g_return_if_fail (E_IS_MAIL_CONFIG_SERVICE_BACKEND (backend));
+
+	widget = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6);
+	e_mail_config_service_backend_insert_widgets (
+		backend, scratch_source, GTK_BOX (widget));
+	gtk_widget_show (widget);
+
+	candidate = g_slice_new0 (Candidate);
+	candidate->widget = g_object_ref_sink (widget);
+	candidate->backend = g_object_ref (backend);
+	candidate->settings = g_object_ref (settings);
+	candidate->scratch_source = g_object_ref (scratch_source);
+
+	/* Emit "changed" signals for subsequent CamelSettings changes. */
+	handler_id = g_signal_connect (
+		candidate->settings, "notify",
+		G_CALLBACK (mail_config_service_page_settings_notify_cb), page);
+	candidate->settings_notify_handler_id = handler_id;
+
+	g_ptr_array_add (page->priv->candidates, candidate);
+
+	display_name = g_dgettext (
+		provider->translation_domain,
+		provider->name);
+
+	notebook = E_SOURCE_NOTEBOOK (page->priv->notebook);
+	page_num = e_source_notebook_add_page (notebook, scratch_source, widget);
+
+	type_combo = GTK_COMBO_BOX_TEXT (page->priv->type_combo);
+	gtk_combo_box_text_append (type_combo, backend_name, display_name);
+
+	/* The type label is only visible if we have one scratch source,
+	 * so just always set the label text to the most recently added
+	 * scratch source. */
+	type_label = GTK_LABEL (page->priv->type_label);
+	gtk_label_set_text (type_label, display_name);
+
+	/* If no combo box row is active yet, choose the new row. */
+	if (gtk_combo_box_get_active_id (GTK_COMBO_BOX (type_combo)) == NULL)
+		gtk_combo_box_set_active_id (
+			GTK_COMBO_BOX (type_combo), backend_name);
+
+	/* If the page number of the newly-added notebook page is zero,
+	 * show the "type" label.  Otherwise show the "type" combo box.
+	 * There's an inverted "visible" binding between the combo box
+	 * and label, so we only need to change one of the widgets. */
+	gtk_widget_set_visible (page->priv->type_combo, page_num > 0);
+}
+
+EActivity *
+e_mail_config_service_page_new_activity (EMailConfigServicePage *page)
+{
+	EActivity *activity;
+	EActivityBar *activity_bar;
+	GCancellable *cancellable;
+
+	g_return_val_if_fail (E_IS_MAIL_CONFIG_SERVICE_PAGE (page), NULL);
+
+	/* Clear any previous alerts. */
+	e_alert_bar_clear (E_ALERT_BAR (page->priv->alert_bar));
+
+	activity = e_activity_new ();
+
+	e_activity_set_alert_sink (activity, E_ALERT_SINK (page));
+
+	cancellable = camel_operation_new ();
+	e_activity_set_cancellable (activity, cancellable);
+	g_object_unref (cancellable);
+
+	activity_bar = E_ACTIVITY_BAR (page->priv->activity_bar);
+	e_activity_bar_set_activity (activity_bar, activity);
+
+	return activity;
+}
+
diff --git a/mail/e-mail-config-service-page.h b/mail/e-mail-config-service-page.h
new file mode 100644
index 0000000..bafa3c1
--- /dev/null
+++ b/mail/e-mail-config-service-page.h
@@ -0,0 +1,95 @@
+/*
+ * e-mail-config-service-page.h
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) version 3.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with the program; if not, see <http://www.gnu.org/licenses/>
+ *
+ */
+
+/* XXX This is very similar to ESourceConfig for address books and
+ *     calendars, but not similar enough to easily unify the APIs.
+ *     Probably with more thought and effort it could be done. */
+
+#ifndef E_MAIL_CONFIG_SERVICE_PAGE_H
+#define E_MAIL_CONFIG_SERVICE_PAGE_H
+
+#include <gtk/gtk.h>
+#include <camel/camel.h>
+#include <libedataserver/e-source-extension.h>
+#include <libedataserver/e-source-registry.h>
+
+#include <e-util/e-activity.h>
+
+/* Standard GObject macros */
+#define E_TYPE_MAIL_CONFIG_SERVICE_PAGE \
+	(e_mail_config_service_page_get_type ())
+#define E_MAIL_CONFIG_SERVICE_PAGE(obj) \
+	(G_TYPE_CHECK_INSTANCE_CAST \
+	((obj), E_TYPE_MAIL_CONFIG_SERVICE_PAGE, EMailConfigServicePage))
+#define E_MAIL_CONFIG_SERVICE_PAGE_CLASS(cls) \
+	(G_TYPE_CHECK_CLASS_CAST \
+	((cls), E_TYPE_MAIL_CONFIG_SERVICE_PAGE, EMailConfigServicePageClass))
+#define E_IS_MAIL_CONFIG_SERVICE_PAGE(obj) \
+	(G_TYPE_CHECK_INSTANCE_TYPE \
+	((obj), E_TYPE_MAIL_CONFIG_SERVICE_PAGE))
+#define E_IS_MAIL_CONFIG_SERVICE_PAGE_CLASS(cls) \
+	(G_TYPE_CHECK_CLASS_TYPE \
+	((cls), E_TYPE_MAIL_CONFIG_SERVICE_PAGE))
+#define E_MAIL_CONFIG_SERVICE_PAGE_GET_CLASS(obj) \
+	(G_TYPE_INSTANCE_GET_CLASS \
+	((obj), E_TYPE_MAIL_CONFIG_SERVICE_PAGE, EMailConfigServicePageClass))
+
+G_BEGIN_DECLS
+
+typedef struct _EMailConfigServicePage EMailConfigServicePage;
+typedef struct _EMailConfigServicePageClass EMailConfigServicePageClass;
+typedef struct _EMailConfigServicePagePrivate EMailConfigServicePagePrivate;
+
+struct _EMailConfigServicePage {
+	GtkBox parent;
+	EMailConfigServicePagePrivate *priv;
+};
+
+struct _EMailConfigServicePageClass {
+	GtkBoxClass parent_class;
+
+	const gchar *extension_name;
+	CamelProviderType provider_type;
+};
+
+GType		e_mail_config_service_page_get_type
+						(void) G_GNUC_CONST;
+ESource *	e_mail_config_service_page_get_active_source
+						(EMailConfigServicePage *page);
+void		e_mail_config_service_page_set_active_source
+						(EMailConfigServicePage *page,
+						 ESource *scratch_source);
+ESourceRegistry *
+		e_mail_config_service_page_get_registry
+						(EMailConfigServicePage *page);
+CamelProvider *	e_mail_config_service_page_get_provider
+						(EMailConfigServicePage *page,
+						 ESource *scratch_source);
+CamelSettings *	e_mail_config_service_page_get_settings
+						(EMailConfigServicePage *page,
+						 ESource *scratch_source);
+void		e_mail_config_service_page_add_scratch_source
+						(EMailConfigServicePage *page,
+						 ESource *scratch_source);
+EActivity *	e_mail_config_service_page_new_activity
+						(EMailConfigServicePage *page);
+
+G_END_DECLS
+
+#endif /* E_MAIL_CONFIG_SERVICE_PAGE_H */
+
diff --git a/mail/e-mail-config-sidebar.c b/mail/e-mail-config-sidebar.c
new file mode 100644
index 0000000..2d28ae8
--- /dev/null
+++ b/mail/e-mail-config-sidebar.c
@@ -0,0 +1,415 @@
+/*
+ * e-mail-config-sidebar.c
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) version 3.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with the program; if not, see <http://www.gnu.org/licenses/>
+ *
+ */
+
+#include "e-mail-config-sidebar.h"
+
+#define E_MAIL_CONFIG_SIDEBAR_GET_PRIVATE(obj) \
+	(G_TYPE_INSTANCE_GET_PRIVATE \
+	((obj), E_TYPE_MAIL_CONFIG_SIDEBAR, EMailConfigSidebarPrivate))
+
+struct _EMailConfigSidebarPrivate {
+	EMailConfigNotebook *notebook;
+	gint active;
+
+	GHashTable *buttons_to_pages;
+	GHashTable *pages_to_buttons;
+
+	gulong page_added_handler_id;
+	gulong page_removed_handler_id;
+	gulong page_reordered_handler_id;
+};
+
+enum {
+	PROP_0,
+	PROP_ACTIVE,
+	PROP_NOTEBOOK
+};
+
+G_DEFINE_TYPE (
+	EMailConfigSidebar,
+	e_mail_config_sidebar,
+	GTK_TYPE_BUTTON_BOX)
+
+static void
+mail_config_sidebar_button_toggled (GtkToggleButton *button,
+                                    EMailConfigSidebar *sidebar)
+{
+	if (gtk_toggle_button_get_active (button)) {
+		GHashTable *hash_table;
+		GtkNotebook *notebook;
+		GtkWidget *page;
+		gint page_num;
+
+		hash_table = sidebar->priv->buttons_to_pages;
+		page = g_hash_table_lookup (hash_table, button);
+		g_return_if_fail (GTK_IS_WIDGET (page));
+
+		notebook = GTK_NOTEBOOK (sidebar->priv->notebook);
+		page_num = gtk_notebook_page_num (notebook, page);
+		e_mail_config_sidebar_set_active (sidebar, page_num);
+	}
+}
+
+static void
+mail_config_sidebar_notebook_page_added (GtkNotebook *notebook,
+                                         GtkWidget *page,
+                                         guint page_num,
+                                         EMailConfigSidebar *sidebar)
+{
+	GtkRadioButton *group_member;
+	GtkWidget *button;
+	GList *keys;
+	gchar *tab_label = NULL;
+
+	/* Grab another radio button if we have any. */
+	keys = g_hash_table_get_keys (sidebar->priv->buttons_to_pages);
+	group_member = (keys != NULL) ? GTK_RADIO_BUTTON (keys->data) : NULL;
+	g_list_free (keys);
+
+	gtk_container_child_get (
+		GTK_CONTAINER (notebook), page,
+		"tab-label", &tab_label, NULL);
+
+	button = gtk_radio_button_new_with_label_from_widget (
+		group_member, tab_label);
+	g_object_set (button, "draw-indicator", FALSE, NULL);
+	gtk_button_set_relief (GTK_BUTTON (button), GTK_RELIEF_NONE);
+	gtk_box_pack_start (GTK_BOX (sidebar), button, FALSE, FALSE, 0);
+	gtk_box_reorder_child (GTK_BOX (sidebar), button, page_num);
+	gtk_widget_show (button);
+
+	g_signal_connect (
+		button, "toggled",
+		G_CALLBACK (mail_config_sidebar_button_toggled), sidebar);
+
+	g_hash_table_insert (
+		sidebar->priv->pages_to_buttons,
+		g_object_ref (page), g_object_ref (button));
+
+	g_hash_table_insert (
+		sidebar->priv->buttons_to_pages,
+		g_object_ref (button), g_object_ref (page));
+}
+
+static void
+mail_config_sidebar_notebook_page_removed (GtkNotebook *notebook,
+                                           GtkWidget *page,
+                                           guint page_num,
+                                           EMailConfigSidebar *sidebar)
+{
+	GHashTable *hash_table;
+	GtkWidget *button;
+
+	hash_table = sidebar->priv->pages_to_buttons;
+	button = g_hash_table_lookup (hash_table, page);
+	g_return_if_fail (GTK_IS_WIDGET (button));
+
+	gtk_container_remove (GTK_CONTAINER (sidebar), button);
+
+	g_hash_table_remove (sidebar->priv->pages_to_buttons, page);
+	g_hash_table_remove (sidebar->priv->buttons_to_pages, button);
+}
+
+static void
+mail_config_sidebar_notebook_page_reordered (GtkNotebook *notebook,
+                                             GtkWidget *page,
+                                             guint page_num,
+                                             EMailConfigSidebar *sidebar)
+{
+	GHashTable *hash_table;
+	GtkWidget *button;
+
+	hash_table = sidebar->priv->pages_to_buttons;
+	button = g_hash_table_lookup (hash_table, page);
+	g_return_if_fail (GTK_IS_WIDGET (button));
+
+	gtk_box_reorder_child (GTK_BOX (sidebar), button, page_num);
+}
+
+static void
+mail_config_sidebar_set_notebook (EMailConfigSidebar *sidebar,
+                                  EMailConfigNotebook *notebook)
+{
+	g_return_if_fail (E_IS_MAIL_CONFIG_NOTEBOOK (notebook));
+	g_return_if_fail (sidebar->priv->notebook == NULL);
+
+	sidebar->priv->notebook = g_object_ref (notebook);
+}
+
+static void
+mail_config_sidebar_set_property (GObject *object,
+                                  guint property_id,
+                                  const GValue *value,
+                                  GParamSpec *pspec)
+{
+	switch (property_id) {
+		case PROP_ACTIVE:
+			e_mail_config_sidebar_set_active (
+				E_MAIL_CONFIG_SIDEBAR (object),
+				g_value_get_int (value));
+			return;
+
+		case PROP_NOTEBOOK:
+			mail_config_sidebar_set_notebook (
+				E_MAIL_CONFIG_SIDEBAR (object),
+				g_value_get_object (value));
+			return;
+	}
+
+	G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+}
+
+static void
+mail_config_sidebar_get_property (GObject *object,
+                                  guint property_id,
+                                  GValue *value,
+                                  GParamSpec *pspec)
+{
+	switch (property_id) {
+		case PROP_ACTIVE:
+			g_value_set_int (
+				value,
+				e_mail_config_sidebar_get_active (
+				E_MAIL_CONFIG_SIDEBAR (object)));
+			return;
+
+		case PROP_NOTEBOOK:
+			g_value_set_object (
+				value,
+				e_mail_config_sidebar_get_notebook (
+				E_MAIL_CONFIG_SIDEBAR (object)));
+			return;
+	}
+
+	G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+}
+
+static void
+mail_config_sidebar_dispose (GObject *object)
+{
+	EMailConfigSidebarPrivate *priv;
+
+	priv = E_MAIL_CONFIG_SIDEBAR_GET_PRIVATE (object);
+
+	if (priv->notebook != NULL) {
+		g_signal_handler_disconnect (
+			priv->notebook, priv->page_added_handler_id);
+		g_signal_handler_disconnect (
+			priv->notebook, priv->page_removed_handler_id);
+		g_signal_handler_disconnect (
+			priv->notebook, priv->page_reordered_handler_id);
+		g_object_unref (priv->notebook);
+		priv->notebook = NULL;
+	}
+
+	g_hash_table_remove_all (priv->buttons_to_pages);
+	g_hash_table_remove_all (priv->pages_to_buttons);
+
+	/* Chain up to parent's dispose() method. */
+	G_OBJECT_CLASS (e_mail_config_sidebar_parent_class)->dispose (object);
+}
+
+static void
+mail_config_sidebar_finalize (GObject *object)
+{
+	EMailConfigSidebarPrivate *priv;
+
+	priv = E_MAIL_CONFIG_SIDEBAR_GET_PRIVATE (object);
+
+	g_hash_table_destroy (priv->buttons_to_pages);
+	g_hash_table_destroy (priv->pages_to_buttons);
+
+	/* Chain up to parent's finalize() method. */
+	G_OBJECT_CLASS (e_mail_config_sidebar_parent_class)->finalize (object);
+}
+
+static void
+mail_config_sidebar_constructed (GObject *object)
+{
+	EMailConfigSidebar *sidebar;
+	GtkNotebook *notebook;
+	gulong handler_id;
+	gint n_pages, ii;
+
+	sidebar = E_MAIL_CONFIG_SIDEBAR (object);
+
+	/* Chain up to parent's constructed() method. */
+	G_OBJECT_CLASS (e_mail_config_sidebar_parent_class)->
+		constructed (object);
+
+	gtk_orientable_set_orientation (
+		GTK_ORIENTABLE (sidebar), GTK_ORIENTATION_VERTICAL);
+
+	gtk_button_box_set_layout (
+		GTK_BUTTON_BOX (sidebar), GTK_BUTTONBOX_START);
+
+	gtk_box_set_spacing (GTK_BOX (sidebar), 6);
+
+	/* Add buttons for existing notebook pages before
+	 * binding to properties or connecting to signals. */
+
+	notebook = GTK_NOTEBOOK (sidebar->priv->notebook);
+	n_pages = gtk_notebook_get_n_pages (notebook);
+
+	for (ii = 0; ii < n_pages; ii++) {
+		GtkWidget *page;
+
+		page = gtk_notebook_get_nth_page (notebook, ii);
+		mail_config_sidebar_notebook_page_added (
+			notebook, page, (guint) ii, sidebar);
+	}
+
+	g_object_bind_property (
+		sidebar, "active",
+		notebook, "page",
+		G_BINDING_BIDIRECTIONAL |
+		G_BINDING_SYNC_CREATE);
+
+	handler_id = g_signal_connect (
+		notebook, "page-added",
+		G_CALLBACK (mail_config_sidebar_notebook_page_added),
+		sidebar);
+	sidebar->priv->page_added_handler_id = handler_id;
+
+	handler_id = g_signal_connect (
+		notebook, "page-removed",
+		G_CALLBACK (mail_config_sidebar_notebook_page_removed),
+		sidebar);
+	sidebar->priv->page_removed_handler_id = handler_id;
+
+	handler_id = g_signal_connect (
+		notebook, "page-reordered",
+		G_CALLBACK (mail_config_sidebar_notebook_page_reordered),
+		sidebar);
+	sidebar->priv->page_reordered_handler_id = handler_id;
+}
+
+static void
+e_mail_config_sidebar_class_init (EMailConfigSidebarClass *class)
+{
+	GObjectClass *object_class;
+
+	g_type_class_add_private (class, sizeof (EMailConfigSidebarPrivate));
+
+	object_class = G_OBJECT_CLASS (class);
+	object_class->set_property = mail_config_sidebar_set_property;
+	object_class->get_property = mail_config_sidebar_get_property;
+	object_class->dispose = mail_config_sidebar_dispose;
+	object_class->finalize = mail_config_sidebar_finalize;
+	object_class->constructed = mail_config_sidebar_constructed;
+
+	/* Use the same constraints as GtkNotebook:page. */
+	g_object_class_install_property (
+		object_class,
+		PROP_ACTIVE,
+		g_param_spec_int (
+			"active",
+			"Active",
+			"Index of the currently active button",
+			-1, G_MAXINT, -1,
+			G_PARAM_READWRITE |
+			G_PARAM_STATIC_STRINGS));
+
+	g_object_class_install_property (
+		object_class,
+		PROP_NOTEBOOK,
+		g_param_spec_object (
+			"notebook",
+			"Notebook",
+			"Mail configuration notebook",
+			E_TYPE_MAIL_CONFIG_NOTEBOOK,
+			G_PARAM_READWRITE |
+			G_PARAM_CONSTRUCT_ONLY |
+			G_PARAM_STATIC_STRINGS));
+}
+
+static void
+e_mail_config_sidebar_init (EMailConfigSidebar *sidebar)
+{
+	GHashTable *buttons_to_pages;
+	GHashTable *pages_to_buttons;
+
+	buttons_to_pages = g_hash_table_new_full (
+		(GHashFunc) g_direct_hash,
+		(GEqualFunc) g_direct_equal,
+		(GDestroyNotify) g_object_unref,
+		(GDestroyNotify) g_object_unref);
+
+	pages_to_buttons = g_hash_table_new_full (
+		(GHashFunc) g_direct_hash,
+		(GEqualFunc) g_direct_equal,
+		(GDestroyNotify) g_object_unref,
+		(GDestroyNotify) g_object_unref);
+
+	sidebar->priv = E_MAIL_CONFIG_SIDEBAR_GET_PRIVATE (sidebar);
+	sidebar->priv->buttons_to_pages = buttons_to_pages;
+	sidebar->priv->pages_to_buttons = pages_to_buttons;
+}
+
+GtkWidget *
+e_mail_config_sidebar_new (EMailConfigNotebook *notebook)
+{
+	g_return_val_if_fail (E_IS_MAIL_CONFIG_NOTEBOOK (notebook), NULL);
+
+	return g_object_new (
+		E_TYPE_MAIL_CONFIG_SIDEBAR,
+		"notebook", notebook, NULL);
+}
+
+gint
+e_mail_config_sidebar_get_active (EMailConfigSidebar *sidebar)
+{
+	g_return_val_if_fail (E_IS_MAIL_CONFIG_SIDEBAR (sidebar), -1);
+
+	return sidebar->priv->active;
+}
+
+void
+e_mail_config_sidebar_set_active (EMailConfigSidebar *sidebar,
+                                  gint active)
+{
+	GtkNotebook *notebook;
+	GtkWidget *page;
+
+	g_return_if_fail (E_IS_MAIL_CONFIG_SIDEBAR (sidebar));
+
+	notebook = GTK_NOTEBOOK (sidebar->priv->notebook);
+	page = gtk_notebook_get_nth_page (notebook, active);
+
+	sidebar->priv->active = (page != NULL) ? active : -1;
+
+	g_object_notify (G_OBJECT (sidebar), "active");
+
+	if (page != NULL) {
+		GHashTable *hash_table;
+		GtkToggleButton *button;
+
+		hash_table = sidebar->priv->pages_to_buttons;
+		button = g_hash_table_lookup (hash_table, page);
+		gtk_toggle_button_set_active (button, TRUE);
+	}
+}
+
+EMailConfigNotebook *
+e_mail_config_sidebar_get_notebook (EMailConfigSidebar *sidebar)
+{
+	g_return_val_if_fail (E_IS_MAIL_CONFIG_SIDEBAR (sidebar), NULL);
+
+	return sidebar->priv->notebook;
+}
+
diff --git a/mail/e-mail-config-sidebar.h b/mail/e-mail-config-sidebar.h
new file mode 100644
index 0000000..50f272e
--- /dev/null
+++ b/mail/e-mail-config-sidebar.h
@@ -0,0 +1,72 @@
+/*
+ * e-mail-config-sidebar.h
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) version 3.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with the program; if not, see <http://www.gnu.org/licenses/>
+ *
+ */
+
+#ifndef E_MAIL_CONFIG_SIDEBAR_H
+#define E_MAIL_CONFIG_SIDEBAR_H
+
+#include <mail/e-mail-config-notebook.h>
+
+/* Standard GObject macros */
+#define E_TYPE_MAIL_CONFIG_SIDEBAR \
+	(e_mail_config_sidebar_get_type ())
+#define E_MAIL_CONFIG_SIDEBAR(obj) \
+	(G_TYPE_CHECK_INSTANCE_CAST \
+	((obj), E_TYPE_MAIL_CONFIG_SIDEBAR, EMailConfigSidebar))
+#define E_MAIL_CONFIG_SIDEBAR_CLASS(cls) \
+	(G_TYPE_CHECK_CLASS_CAST \
+	((cls), E_TYPE_MAIL_CONFIG_SIDEBAR, EMailConfigSidebarClass))
+#define E_IS_MAIL_CONFIG_SIDEBAR(obj) \
+	(G_TYPE_CHECK_INSTANCE_TYPE \
+	((obj), E_TYPE_MAIL_CONFIG_SIDEBAR))
+#define E_IS_MAIL_CONFIG_SIDEBAR_CLASS(cls) \
+	(G_TYPE_CHECK_CLASS_TYPE \
+	((cls), E_TYPE_MAIL_CONFIG_SIDEBAR))
+#define E_MAIL_CONFIG_SIDEBAR_GET_CLASS(obj) \
+	(G_TYPE_INSTANCE_GET_CLASS \
+	((obj), E_TYPE_MAIL_CONFIG_SIDEBAR, EMailConfigSidebarClass))
+
+G_BEGIN_DECLS
+
+typedef struct _EMailConfigSidebar EMailConfigSidebar;
+typedef struct _EMailConfigSidebarClass EMailConfigSidebarClass;
+typedef struct _EMailConfigSidebarPrivate EMailConfigSidebarPrivate;
+
+struct _EMailConfigSidebar {
+	GtkButtonBox parent;
+	EMailConfigSidebarPrivate *priv;
+};
+
+struct _EMailConfigSidebarClass {
+	GtkButtonBoxClass parent_class;
+};
+
+GType		e_mail_config_sidebar_get_type	(void) G_GNUC_CONST;
+GtkWidget *	e_mail_config_sidebar_new	(EMailConfigNotebook *notebook);
+gint		e_mail_config_sidebar_get_active
+						(EMailConfigSidebar *sidebar);
+void		e_mail_config_sidebar_set_active
+						(EMailConfigSidebar *sidebar,
+						 gint active);
+EMailConfigNotebook *
+		e_mail_config_sidebar_get_notebook
+						(EMailConfigSidebar *sidebar);
+
+G_END_DECLS
+
+#endif /* E_MAIL_CONFIG_SIDEBAR_H */
+
diff --git a/mail/e-mail-config-summary-page.c b/mail/e-mail-config-summary-page.c
new file mode 100644
index 0000000..0d8b546
--- /dev/null
+++ b/mail/e-mail-config-summary-page.c
@@ -0,0 +1,816 @@
+/*
+ * e-mail-config-summary-page.c
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) version 3.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with the program; if not, see <http://www.gnu.org/licenses/>
+ *
+ */
+
+#include "e-mail-config-summary-page.h"
+
+#include <config.h>
+#include <glib/gi18n-lib.h>
+
+#include <camel/camel.h>
+
+#include <libebackend/e-extensible.h>
+#include <libedataserver/e-source-authentication.h>
+#include <libedataserver/e-source-mail-account.h>
+#include <libedataserver/e-source-mail-identity.h>
+#include <libedataserver/e-source-mail-transport.h>
+#include <libedataserver/e-source-security.h>
+
+#define E_MAIL_CONFIG_SUMMARY_PAGE_GET_PRIVATE(obj) \
+	(G_TYPE_INSTANCE_GET_PRIVATE \
+	((obj), E_TYPE_MAIL_CONFIG_SUMMARY_PAGE, EMailConfigSummaryPagePrivate))
+
+struct _EMailConfigSummaryPagePrivate {
+	ESource *account_source;
+	ESource *identity_source;
+	ESource *transport_source;
+
+	/* Widgets (not referenced) */
+	GtkLabel *name_label;
+	GtkLabel *address_label;
+	GtkLabel *recv_backend_label;
+	GtkLabel *recv_host_label;
+	GtkLabel *recv_user_label;
+	GtkLabel *recv_security_label;
+	GtkLabel *send_backend_label;
+	GtkLabel *send_host_label;
+	GtkLabel *send_user_label;
+	GtkLabel *send_security_label;
+	GtkEntry *account_name_entry;
+};
+
+enum {
+	PROP_0,
+	PROP_ACCOUNT_SOURCE,
+	PROP_IDENTITY_SOURCE,
+	PROP_TRANSPORT_SOURCE
+};
+
+enum {
+	REFRESH,
+	LAST_SIGNAL
+};
+
+static gulong signals[LAST_SIGNAL];
+
+/* Forward Declarations */
+static void	e_mail_config_summary_page_interface_init
+					(EMailConfigPageInterface *interface);
+
+G_DEFINE_TYPE_WITH_CODE (
+	EMailConfigSummaryPage,
+	e_mail_config_summary_page,
+	GTK_TYPE_BOX,
+	G_IMPLEMENT_INTERFACE (
+		E_TYPE_EXTENSIBLE, NULL)
+	G_IMPLEMENT_INTERFACE (
+		E_TYPE_MAIL_CONFIG_PAGE,
+		e_mail_config_summary_page_interface_init))
+
+/* Helper for mail_config_summary_page_refresh() */
+static void
+mail_config_summary_page_refresh_auth_labels (ESource *source,
+                                              GtkLabel *host_label,
+                                              GtkLabel *user_label)
+{
+	ESourceAuthentication *extension;
+	const gchar *extension_name;
+	const gchar *value;
+
+	if (source == NULL)
+		return;
+
+	extension_name = E_SOURCE_EXTENSION_AUTHENTICATION;
+	if (!e_source_has_extension (source, extension_name))
+		return;
+
+	extension = e_source_get_extension (source, extension_name);
+
+	value = e_source_authentication_get_host (extension);
+	gtk_label_set_text (host_label, value);
+
+	value = e_source_authentication_get_user (extension);
+	gtk_label_set_text (user_label, value);
+}
+
+/* Helper for mail_config_summary_page_refresh() */
+static void
+mail_config_summary_page_refresh_security_label (ESource *source,
+                                                 GtkLabel *security_label)
+{
+	GEnumClass *enum_class;
+	GEnumValue *enum_value;
+	ESourceSecurity *extension;
+	const gchar *extension_name;
+	const gchar *value;
+
+	if (source == NULL)
+		return;
+
+	extension_name = E_SOURCE_EXTENSION_SECURITY;
+	if (!e_source_has_extension (source, extension_name))
+		return;
+
+	extension = e_source_get_extension (source, extension_name);
+
+	/* XXX This is a pain in the butt, but we want to avoid hard-coding
+	 *     string values from the CamelNetworkSecurityMethod enum class
+	 *     in case they change in the future. */
+	enum_class = g_type_class_ref (CAMEL_TYPE_NETWORK_SECURITY_METHOD);
+	value = e_source_security_get_method (extension);
+	if (value != NULL)
+		enum_value = g_enum_get_value_by_nick (enum_class, value);
+	else
+		enum_value = NULL;
+	if (enum_value == NULL) {
+		gtk_label_set_text (security_label, value);
+	} else switch ((CamelNetworkSecurityMethod) enum_value->value) {
+		case CAMEL_NETWORK_SECURITY_METHOD_NONE:
+			gtk_label_set_text (security_label, _("None"));
+			break;
+		case CAMEL_NETWORK_SECURITY_METHOD_SSL_ON_ALTERNATE_PORT:
+			gtk_label_set_text (security_label, _("SSL"));
+			break;
+		case CAMEL_NETWORK_SECURITY_METHOD_STARTTLS_ON_STANDARD_PORT:
+			gtk_label_set_text (security_label, _("TLS"));
+			break;
+	}
+	g_type_class_unref (enum_class);
+}
+
+static void
+mail_config_summary_page_source_changed (ESource *source,
+                                         EMailConfigSummaryPage *page)
+{
+	e_mail_config_summary_page_refresh (page);
+}
+
+static void
+mail_config_summary_page_set_property (GObject *object,
+                                       guint property_id,
+                                       const GValue *value,
+                                       GParamSpec *pspec)
+{
+	switch (property_id) {
+		case PROP_ACCOUNT_SOURCE:
+			e_mail_config_summary_page_set_account_source (
+				E_MAIL_CONFIG_SUMMARY_PAGE (object),
+				g_value_get_object (value));
+			return;
+
+		case PROP_IDENTITY_SOURCE:
+			e_mail_config_summary_page_set_identity_source (
+				E_MAIL_CONFIG_SUMMARY_PAGE (object),
+				g_value_get_object (value));
+			return;
+
+		case PROP_TRANSPORT_SOURCE:
+			e_mail_config_summary_page_set_transport_source (
+				E_MAIL_CONFIG_SUMMARY_PAGE (object),
+				g_value_get_object (value));
+			return;
+	}
+
+	G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+}
+
+static void
+mail_config_summary_page_get_property (GObject *object,
+                                       guint property_id,
+                                       GValue *value,
+                                       GParamSpec *pspec)
+{
+	switch (property_id) {
+		case PROP_ACCOUNT_SOURCE:
+			g_value_set_object (
+				value,
+				e_mail_config_summary_page_get_account_source (
+				E_MAIL_CONFIG_SUMMARY_PAGE (object)));
+			return;
+
+		case PROP_IDENTITY_SOURCE:
+			g_value_set_object (
+				value,
+				e_mail_config_summary_page_get_identity_source (
+				E_MAIL_CONFIG_SUMMARY_PAGE (object)));
+			return;
+
+		case PROP_TRANSPORT_SOURCE:
+			g_value_set_object (
+				value,
+				e_mail_config_summary_page_get_transport_source (
+				E_MAIL_CONFIG_SUMMARY_PAGE (object)));
+			return;
+	}
+
+	G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+}
+
+static void
+mail_config_summary_page_dispose (GObject *object)
+{
+	EMailConfigSummaryPagePrivate *priv;
+
+	priv = E_MAIL_CONFIG_SUMMARY_PAGE_GET_PRIVATE (object);
+
+	if (priv->account_source != NULL) {
+		g_signal_handlers_disconnect_by_func (
+			priv->account_source,
+			mail_config_summary_page_source_changed, object);
+		g_object_unref (priv->account_source);
+		priv->account_source = NULL;
+	}
+
+	if (priv->identity_source != NULL) {
+		g_signal_handlers_disconnect_by_func (
+			priv->identity_source,
+			mail_config_summary_page_source_changed, object);
+		g_object_unref (priv->identity_source);
+		priv->identity_source = NULL;
+	}
+
+	if (priv->transport_source != NULL) {
+		g_signal_handlers_disconnect_by_func (
+			priv->transport_source,
+			mail_config_summary_page_source_changed, object);
+		g_object_unref (priv->transport_source);
+		priv->transport_source = NULL;
+	}
+
+	/* Chain up to parent's dispose() method. */
+	G_OBJECT_CLASS (e_mail_config_summary_page_parent_class)->
+		dispose (object);
+}
+
+static void
+mail_config_summary_page_constructed (GObject *object)
+{
+	EMailConfigSummaryPage *page;
+	GtkLabel *label;
+	GtkWidget *widget;
+	GtkWidget *container;
+	GtkSizeGroup *size_group;
+	const gchar *text;
+	gchar *markup;
+
+	page = E_MAIL_CONFIG_SUMMARY_PAGE (object);
+
+	/* Chain up to parent's constructed() method. */
+	G_OBJECT_CLASS (e_mail_config_summary_page_parent_class)->
+		constructed (object);
+
+	gtk_orientable_set_orientation (
+		GTK_ORIENTABLE (page), GTK_ORIENTATION_VERTICAL);
+
+	gtk_box_set_spacing (GTK_BOX (page), 12);
+
+	size_group = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL);
+
+	text = _("This is a summary of the settings which will be used "
+		 "to access your mail.");
+	widget = gtk_label_new (text);
+	gtk_misc_set_alignment (GTK_MISC (widget), 0.0, 0.5);
+	gtk_box_pack_start (GTK_BOX (page), widget, FALSE, FALSE, 0);
+	gtk_widget_show (widget);
+
+	/*** Details ***/
+
+	widget = gtk_grid_new ();
+	gtk_grid_set_row_spacing (GTK_GRID (widget), 6);
+	gtk_grid_set_column_spacing (GTK_GRID (widget), 12);
+	gtk_box_pack_start (GTK_BOX (page), widget, FALSE, FALSE, 0);
+	gtk_widget_show (widget);
+
+	container = widget;
+
+	text = _("Personal Details");
+	markup = g_markup_printf_escaped ("<b>%s</b>", text);
+	widget = gtk_label_new (markup);
+	gtk_label_set_use_markup (GTK_LABEL (widget), TRUE);
+	gtk_misc_set_alignment (GTK_MISC (widget), 0.0, 0.5);
+	gtk_grid_attach (GTK_GRID (container), widget, 0, 0, 3, 1);
+	gtk_widget_show (widget);
+	g_free (markup);
+
+	text = _("Full Name:");
+	widget = gtk_label_new (text);
+	gtk_widget_set_margin_left (widget, 12);
+	gtk_misc_set_alignment (GTK_MISC (widget), 1.0, 0.5);
+	gtk_grid_attach (GTK_GRID (container), widget, 0, 1, 1, 1);
+	gtk_widget_show (widget);
+
+	widget = gtk_label_new (NULL);
+	gtk_misc_set_alignment (GTK_MISC (widget), 0.0, 0.5);
+	gtk_label_set_ellipsize (GTK_LABEL (widget), PANGO_ELLIPSIZE_END);
+	gtk_grid_attach (GTK_GRID (container), widget, 1, 1, 2, 1);
+	page->priv->name_label = GTK_LABEL (widget);
+	gtk_widget_show (widget);
+
+	text = _("Email Address:");
+	widget = gtk_label_new (text);
+	gtk_widget_set_margin_left (widget, 12);
+	gtk_misc_set_alignment (GTK_MISC (widget), 1.0, 0.5);
+	gtk_grid_attach (GTK_GRID (container), widget, 0, 2, 1, 1);
+	gtk_widget_show (widget);
+
+	widget = gtk_label_new (NULL);
+	gtk_misc_set_alignment (GTK_MISC (widget), 0.0, 0.5);
+	gtk_label_set_ellipsize (GTK_LABEL (widget), PANGO_ELLIPSIZE_END);
+	gtk_grid_attach (GTK_GRID (container), widget, 1, 2, 2, 1);
+	page->priv->address_label = GTK_LABEL (widget);
+	gtk_widget_show (widget);
+
+	text = _("Receiving");
+	markup = g_markup_printf_escaped ("<b>%s</b>", text);
+	widget = gtk_label_new (markup);
+	gtk_widget_set_hexpand (widget, TRUE);
+	gtk_widget_set_margin_top (widget, 6);
+	gtk_size_group_add_widget (size_group, widget);
+	gtk_label_set_use_markup (GTK_LABEL (widget), TRUE);
+	gtk_misc_set_alignment (GTK_MISC (widget), 0.0, 0.5);
+	gtk_grid_attach (GTK_GRID (container), widget, 1, 3, 1, 1);
+	gtk_widget_show (widget);
+	g_free (markup);
+
+	text = _("Sending");
+	markup = g_markup_printf_escaped ("<b>%s</b>", text);
+	widget = gtk_label_new (markup);
+	gtk_widget_set_hexpand (widget, TRUE);
+	gtk_widget_set_margin_top (widget, 6);
+	gtk_size_group_add_widget (size_group, widget);
+	gtk_label_set_use_markup (GTK_LABEL (widget), TRUE);
+	gtk_misc_set_alignment (GTK_MISC (widget), 0.0, 0.5);
+	gtk_grid_attach (GTK_GRID (container), widget, 2, 3, 1, 1);
+	gtk_widget_show (widget);
+	g_free (markup);
+
+	text = _("Server Type:");
+	widget = gtk_label_new (text);
+	gtk_widget_set_margin_left (widget, 12);
+	gtk_misc_set_alignment (GTK_MISC (widget), 1.0, 0.5);
+	gtk_grid_attach (GTK_GRID (container), widget, 0, 4, 1, 1);
+	gtk_widget_show (widget);
+
+	widget = gtk_label_new (NULL);
+	gtk_misc_set_alignment (GTK_MISC (widget), 0.0, 0.5);
+	gtk_label_set_ellipsize (GTK_LABEL (widget), PANGO_ELLIPSIZE_END);
+	gtk_grid_attach (GTK_GRID (container), widget, 1, 4, 1, 1);
+	page->priv->recv_backend_label = GTK_LABEL (widget);
+	gtk_widget_show (widget);
+
+	widget = gtk_label_new (NULL);
+	gtk_misc_set_alignment (GTK_MISC (widget), 0.0, 0.5);
+	gtk_label_set_ellipsize (GTK_LABEL (widget), PANGO_ELLIPSIZE_END);
+	gtk_grid_attach (GTK_GRID (container), widget, 2, 4, 1, 1);
+	page->priv->send_backend_label = GTK_LABEL (widget);
+	gtk_widget_show (widget);
+
+	text = _("Server:");
+	widget = gtk_label_new (text);
+	gtk_widget_set_margin_left (widget, 12);
+	gtk_misc_set_alignment (GTK_MISC (widget), 1.0, 0.5);
+	gtk_grid_attach (GTK_GRID (container), widget, 0, 5, 1, 1);
+	gtk_widget_show (widget);
+
+	widget = gtk_label_new (NULL);
+	gtk_misc_set_alignment (GTK_MISC (widget), 0.0, 0.5);
+	gtk_label_set_ellipsize (GTK_LABEL (widget), PANGO_ELLIPSIZE_END);
+	gtk_grid_attach (GTK_GRID (container), widget, 1, 5, 1, 1);
+	page->priv->recv_host_label = GTK_LABEL (widget);
+	gtk_widget_show (widget);
+
+	widget = gtk_label_new (NULL);
+	gtk_misc_set_alignment (GTK_MISC (widget), 0.0, 0.5);
+	gtk_label_set_ellipsize (GTK_LABEL (widget), PANGO_ELLIPSIZE_END);
+	gtk_grid_attach (GTK_GRID (container), widget, 2, 5, 1, 1);
+	page->priv->send_host_label = GTK_LABEL (widget);
+	gtk_widget_show (widget);
+
+	text = _("Username:");
+	widget = gtk_label_new (text);
+	gtk_widget_set_margin_left (widget, 12);
+	gtk_misc_set_alignment (GTK_MISC (widget), 1.0, 0.5);
+	gtk_grid_attach (GTK_GRID (container), widget, 0, 6, 1, 1);
+	gtk_widget_show (widget);
+
+	widget = gtk_label_new (NULL);
+	gtk_misc_set_alignment (GTK_MISC (widget), 0.0, 0.5);
+	gtk_label_set_ellipsize (GTK_LABEL (widget), PANGO_ELLIPSIZE_END);
+	gtk_grid_attach (GTK_GRID (container), widget, 1, 6, 1, 1);
+	page->priv->recv_user_label = GTK_LABEL (widget);
+	gtk_widget_show (widget);
+
+	widget = gtk_label_new (NULL);
+	gtk_misc_set_alignment (GTK_MISC (widget), 0.0, 0.5);
+	gtk_label_set_ellipsize (GTK_LABEL (widget), PANGO_ELLIPSIZE_END);
+	gtk_grid_attach (GTK_GRID (container), widget, 2, 6, 1, 1);
+	page->priv->send_user_label = GTK_LABEL (widget);
+	gtk_widget_show (widget);
+
+	text = _("Security:");
+	widget = gtk_label_new (text);
+	gtk_widget_set_margin_left (widget, 12);
+	gtk_misc_set_alignment (GTK_MISC (widget), 1.0, 0.5);
+	gtk_grid_attach (GTK_GRID (container), widget, 0, 7, 1, 1);
+	gtk_widget_show (widget);
+
+	widget = gtk_label_new (NULL);
+	gtk_misc_set_alignment (GTK_MISC (widget), 0.0, 0.5);
+	gtk_label_set_ellipsize (GTK_LABEL (widget), PANGO_ELLIPSIZE_END);
+	gtk_grid_attach (GTK_GRID (container), widget, 1, 7, 1, 1);
+	page->priv->recv_security_label = GTK_LABEL (widget);
+	gtk_widget_show (widget);
+
+	widget = gtk_label_new (NULL);
+	gtk_misc_set_alignment (GTK_MISC (widget), 0.0, 0.5);
+	gtk_label_set_ellipsize (GTK_LABEL (widget), PANGO_ELLIPSIZE_END);
+	gtk_grid_attach (GTK_GRID (container), widget, 2, 7, 1, 1);
+	page->priv->send_security_label = GTK_LABEL (widget);
+	gtk_widget_show (widget);
+
+	/*** Account Information ***/
+
+	widget = gtk_grid_new ();
+	gtk_grid_set_row_spacing (GTK_GRID (widget), 6);
+	gtk_grid_set_column_spacing (GTK_GRID (widget), 6);
+	gtk_box_pack_start (GTK_BOX (page), widget, FALSE, FALSE, 0);
+	gtk_widget_show (widget);
+
+	container = widget;
+
+	text = _("Account Information");
+	markup = g_markup_printf_escaped ("<b>%s</b>", text);
+	widget = gtk_label_new (markup);
+	gtk_label_set_use_markup (GTK_LABEL (widget), TRUE);
+	gtk_misc_set_alignment (GTK_MISC (widget), 0.0, 0.5);
+	gtk_grid_attach (GTK_GRID (container), widget, 0, 0, 2, 1);
+	gtk_widget_show (widget);
+	g_free (markup);
+
+	text = _("Type the name by which you would like to refer to "
+		 "this account.\nFor example, \"Work\" or \"Personal\".");
+	widget = gtk_label_new (text);
+	gtk_widget_set_margin_left (widget, 12);
+	gtk_misc_set_alignment (GTK_MISC (widget), 0.0, 0.5);
+	gtk_grid_attach (GTK_GRID (container), widget, 0, 1, 2, 1);
+	gtk_widget_show (widget);
+
+	text = _("_Name:");
+	widget = gtk_label_new_with_mnemonic (text);
+	gtk_widget_set_margin_left (widget, 12);
+	gtk_misc_set_alignment (GTK_MISC (widget), 1.0, 0.5);
+	gtk_grid_attach (GTK_GRID (container), widget, 0, 2, 1, 1);
+	gtk_widget_show (widget);
+
+	label = GTK_LABEL (widget);
+
+	widget = gtk_entry_new ();
+	gtk_widget_set_hexpand (widget, TRUE);
+	gtk_label_set_mnemonic_widget (label, widget);
+	gtk_grid_attach (GTK_GRID (container), widget, 1, 2, 1, 1);
+	page->priv->account_name_entry = GTK_ENTRY (widget);
+	gtk_widget_show (widget);
+
+	/* This entry affects the "check-complete" result. */
+	g_signal_connect_swapped (
+		widget, "changed",
+		G_CALLBACK (e_mail_config_page_changed), page);
+
+	g_object_unref (size_group);
+}
+
+static void
+mail_config_summary_page_refresh (EMailConfigSummaryPage *page)
+{
+	EMailConfigSummaryPagePrivate *priv;
+
+	priv = E_MAIL_CONFIG_SUMMARY_PAGE_GET_PRIVATE (page);
+
+	/* Clear all labels. */
+	gtk_label_set_text (priv->name_label, "");
+	gtk_label_set_text (priv->address_label, "");
+	gtk_label_set_text (priv->recv_backend_label, "");
+	gtk_label_set_text (priv->recv_host_label, "");
+	gtk_label_set_text (priv->recv_user_label, "");
+	gtk_label_set_text (priv->recv_security_label, "");
+	gtk_label_set_text (priv->send_backend_label, "");
+	gtk_label_set_text (priv->send_host_label, "");
+	gtk_label_set_text (priv->send_user_label, "");
+	gtk_label_set_text (priv->send_security_label, "");
+
+	if (priv->identity_source != NULL) {
+		ESource *source;
+		ESourceMailIdentity *extension;
+		const gchar *extension_name;
+		const gchar *value;
+
+		source = priv->identity_source;
+		extension_name = E_SOURCE_EXTENSION_MAIL_IDENTITY;
+		extension = e_source_get_extension (source, extension_name);
+
+		value = e_source_mail_identity_get_name (extension);
+		gtk_label_set_text (priv->name_label, value);
+
+		value = e_source_mail_identity_get_address (extension);
+		gtk_label_set_text (priv->address_label, value);
+	}
+
+	if (priv->account_source != NULL) {
+		ESource *source;
+		ESourceBackend *extension;
+		const gchar *extension_name;
+		const gchar *value;
+
+		source = priv->account_source;
+		extension_name = E_SOURCE_EXTENSION_MAIL_ACCOUNT;
+		extension = e_source_get_extension (source, extension_name);
+
+		value = e_source_backend_get_backend_name (extension);
+		gtk_label_set_text (priv->recv_backend_label, value);
+	}
+
+	mail_config_summary_page_refresh_auth_labels (
+		priv->account_source,
+		priv->recv_host_label,
+		priv->recv_user_label);
+
+	mail_config_summary_page_refresh_security_label (
+		priv->account_source,
+		priv->recv_security_label);
+
+	if (priv->transport_source != NULL) {
+		ESource *source;
+		ESourceBackend *extension;
+		const gchar *extension_name;
+		const gchar *value;
+
+		source = priv->transport_source;
+		extension_name = E_SOURCE_EXTENSION_MAIL_TRANSPORT;
+		extension = e_source_get_extension (source, extension_name);
+
+		value = e_source_backend_get_backend_name (extension);
+		gtk_label_set_text (priv->send_backend_label, value);
+	}
+
+	mail_config_summary_page_refresh_auth_labels (
+		priv->transport_source,
+		priv->send_host_label,
+		priv->send_user_label);
+
+	mail_config_summary_page_refresh_security_label (
+		priv->transport_source,
+		priv->send_security_label);
+}
+
+static gboolean
+mail_config_summary_page_check_complete (EMailConfigPage *page)
+{
+	EMailConfigSummaryPagePrivate *priv;
+	gchar *stripped_text;
+	const gchar *text;
+	gboolean complete;
+
+	priv = E_MAIL_CONFIG_SUMMARY_PAGE_GET_PRIVATE (page);
+
+	/* Strip the account name of leading and trailing
+	 * whitespace as e_source_set_display_name() does. */
+	text = gtk_entry_get_text (priv->account_name_entry);
+	stripped_text = g_strstrip (g_strdup ((text != NULL) ? text : ""));
+	complete = (*stripped_text != '\0');
+	g_free (stripped_text);
+
+	return complete;
+}
+
+static void
+mail_config_summary_page_commit_changes (EMailConfigPage *page,
+                                         GQueue *source_queue)
+{
+	EMailConfigSummaryPagePrivate *priv;
+	const gchar *text;
+
+	priv = E_MAIL_CONFIG_SUMMARY_PAGE_GET_PRIVATE (page);
+
+	text = gtk_entry_get_text (priv->account_name_entry);
+	e_source_set_display_name (priv->account_source, text);
+}
+
+static void
+e_mail_config_summary_page_class_init (EMailConfigSummaryPageClass *class)
+{
+	GObjectClass *object_class;
+
+	g_type_class_add_private (
+		class, sizeof (EMailConfigSummaryPagePrivate));
+
+	object_class = G_OBJECT_CLASS (class);
+	object_class->set_property = mail_config_summary_page_set_property;
+	object_class->get_property = mail_config_summary_page_get_property;
+	object_class->dispose = mail_config_summary_page_dispose;
+	object_class->constructed = mail_config_summary_page_constructed;
+
+	class->refresh = mail_config_summary_page_refresh;
+
+	g_object_class_install_property (
+		object_class,
+		PROP_ACCOUNT_SOURCE,
+		g_param_spec_object (
+			"account-source",
+			"Account Source",
+			"Mail account source being edited",
+			E_TYPE_SOURCE,
+			G_PARAM_READWRITE |
+			G_PARAM_STATIC_STRINGS));
+
+	g_object_class_install_property (
+		object_class,
+		PROP_IDENTITY_SOURCE,
+		g_param_spec_object (
+			"identity-source",
+			"Identity Source",
+			"Mail identity source being edited",
+			E_TYPE_SOURCE,
+			G_PARAM_READWRITE |
+			G_PARAM_STATIC_STRINGS));
+
+	g_object_class_install_property (
+		object_class,
+		PROP_TRANSPORT_SOURCE,
+		g_param_spec_object (
+			"transport-source",
+			"Transport Source",
+			"Mail transport source being edited",
+			E_TYPE_SOURCE,
+			G_PARAM_READWRITE |
+			G_PARAM_STATIC_STRINGS));
+
+	signals[REFRESH] = g_signal_new (
+		"refresh",
+		G_TYPE_FROM_CLASS (class),
+		G_SIGNAL_RUN_LAST,
+		G_STRUCT_OFFSET (EMailConfigSummaryPageClass, refresh),
+		NULL, NULL,
+		g_cclosure_marshal_VOID__VOID,
+		G_TYPE_NONE, 0);
+}
+
+static void
+e_mail_config_summary_page_interface_init (EMailConfigPageInterface *interface)
+{
+	interface->title = _("Account Summary");
+	interface->sort_order = E_MAIL_CONFIG_SUMMARY_PAGE_SORT_ORDER;
+	interface->check_complete = mail_config_summary_page_check_complete;
+	interface->commit_changes = mail_config_summary_page_commit_changes;
+}
+
+static void
+e_mail_config_summary_page_init (EMailConfigSummaryPage *page)
+{
+	page->priv = E_MAIL_CONFIG_SUMMARY_PAGE_GET_PRIVATE (page);
+}
+
+EMailConfigPage *
+e_mail_config_summary_page_new (void)
+{
+	return g_object_new (E_TYPE_MAIL_CONFIG_SUMMARY_PAGE, NULL);
+}
+
+void
+e_mail_config_summary_page_refresh (EMailConfigSummaryPage *page)
+{
+	g_return_if_fail (E_IS_MAIL_CONFIG_SUMMARY_PAGE (page));
+
+	g_signal_emit (page, signals[REFRESH], 0);
+}
+
+ESource *
+e_mail_config_summary_page_get_account_source (EMailConfigSummaryPage *page)
+{
+	g_return_val_if_fail (E_IS_MAIL_CONFIG_SUMMARY_PAGE (page), NULL);
+
+	return page->priv->account_source;
+}
+
+void
+e_mail_config_summary_page_set_account_source (EMailConfigSummaryPage *page,
+                                               ESource *account_source)
+{
+	g_return_if_fail (E_IS_MAIL_CONFIG_SUMMARY_PAGE (page));
+
+	if (account_source != NULL) {
+		g_return_if_fail (E_IS_SOURCE (account_source));
+		g_object_ref (account_source);
+	}
+
+	if (page->priv->account_source != NULL) {
+		g_signal_handlers_disconnect_by_func (
+			page->priv->account_source,
+			mail_config_summary_page_source_changed, page);
+		g_object_unref (page->priv->account_source);
+	}
+
+	page->priv->account_source = account_source;
+
+	if (account_source != NULL)
+		g_signal_connect (
+			account_source, "changed",
+			G_CALLBACK (mail_config_summary_page_source_changed),
+			page);
+
+	g_object_notify (G_OBJECT (page), "account-source");
+
+	e_mail_config_summary_page_refresh (page);
+}
+
+ESource *
+e_mail_config_summary_page_get_identity_source (EMailConfigSummaryPage *page)
+{
+	g_return_val_if_fail (E_IS_MAIL_CONFIG_SUMMARY_PAGE (page), NULL);
+
+	return page->priv->identity_source;
+}
+
+void
+e_mail_config_summary_page_set_identity_source (EMailConfigSummaryPage *page,
+                                                ESource *identity_source)
+{
+	g_return_if_fail (E_IS_MAIL_CONFIG_SUMMARY_PAGE (page));
+
+	if (identity_source != NULL) {
+		g_return_if_fail (E_IS_SOURCE (identity_source));
+		g_object_ref (identity_source);
+	}
+
+	if (page->priv->identity_source != NULL) {
+		g_signal_handlers_disconnect_by_func (
+			page->priv->identity_source,
+			mail_config_summary_page_source_changed, page);
+		g_object_unref (page->priv->identity_source);
+	}
+
+	page->priv->identity_source = identity_source;
+
+	if (identity_source != NULL)
+		g_signal_connect (
+			identity_source, "changed",
+			G_CALLBACK (mail_config_summary_page_source_changed),
+			page);
+
+	g_object_notify (G_OBJECT (page), "identity-source");
+
+	e_mail_config_summary_page_refresh (page);
+}
+
+ESource *
+e_mail_config_summary_page_get_transport_source (EMailConfigSummaryPage *page)
+{
+	g_return_val_if_fail (E_IS_MAIL_CONFIG_SUMMARY_PAGE (page), NULL);
+
+	return page->priv->transport_source;
+}
+
+void
+e_mail_config_summary_page_set_transport_source (EMailConfigSummaryPage *page,
+                                                 ESource *transport_source)
+{
+	g_return_if_fail (E_IS_MAIL_CONFIG_SUMMARY_PAGE (page));
+
+	if (transport_source != NULL) {
+		g_return_if_fail (E_IS_SOURCE (transport_source));
+		g_object_ref (transport_source);
+	}
+
+	if (page->priv->transport_source != NULL) {
+		g_signal_handlers_disconnect_by_func (
+			page->priv->transport_source,
+			mail_config_summary_page_source_changed, page);
+		g_object_unref (page->priv->transport_source);
+	}
+
+	page->priv->transport_source = transport_source;
+
+	if (transport_source != NULL)
+		g_signal_connect (
+			transport_source, "changed",
+			G_CALLBACK (mail_config_summary_page_source_changed),
+			page);
+
+	g_object_notify (G_OBJECT (page), "transport-source");
+
+	e_mail_config_summary_page_refresh (page);
+}
+
diff --git a/mail/e-mail-config-summary-page.h b/mail/e-mail-config-summary-page.h
new file mode 100644
index 0000000..cb4b33a
--- /dev/null
+++ b/mail/e-mail-config-summary-page.h
@@ -0,0 +1,89 @@
+/*
+ * e-mail-config-summary-page.h
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) version 3.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with the program; if not, see <http://www.gnu.org/licenses/>
+ *
+ */
+
+#ifndef E_MAIL_CONFIG_SUMMARY_PAGE_H
+#define E_MAIL_CONFIG_SUMMARY_PAGE_H
+
+#include <gtk/gtk.h>
+#include <libedataserver/e-source.h>
+
+#include <mail/e-mail-config-page.h>
+
+/* Standard GObject macros */
+#define E_TYPE_MAIL_CONFIG_SUMMARY_PAGE \
+	(e_mail_config_summary_page_get_type ())
+#define E_MAIL_CONFIG_SUMMARY_PAGE(obj) \
+	(G_TYPE_CHECK_INSTANCE_CAST \
+	((obj), E_TYPE_MAIL_CONFIG_SUMMARY_PAGE, EMailConfigSummaryPage))
+#define E_MAIL_CONFIG_SUMMARY_PAGE_CLASS(cls) \
+	(G_TYPE_CHECK_CLASS_CAST \
+	((cls), E_TYPE_MAIL_CONFIG_SUMMARY_PAGE, EMailConfigSummaryPageClass))
+#define E_IS_MAIL_CONFIG_SUMMARY_PAGE(obj) \
+	(G_TYPE_CHECK_INSTANCE_TYPE \
+	((obj), E_TYPE_MAIL_CONFIG_SUMMARY_PAGE))
+#define E_IS_MAIL_CONFIG_SUMMARY_PAGE_CLASS(cls) \
+	(G_TYPE_CHECK_CLASS_TYPE \
+	((cls), E_TYPE_MAIL_CONFIG_SUMMARY_PAGE))
+#define E_MAIL_CONFIG_SUMMARY_GET_CLASS(obj) \
+	(G_TYPE_INSTANCE_GET_CLASS \
+	((obj), E_TYPE_MAIL_CONFIG_SUMMARY_PAGE, EMailConfigSummaryPageClass))
+
+#define E_MAIL_CONFIG_SUMMARY_PAGE_SORT_ORDER (500)
+
+G_BEGIN_DECLS
+
+typedef struct _EMailConfigSummaryPage EMailConfigSummaryPage;
+typedef struct _EMailConfigSummaryPageClass EMailConfigSummaryPageClass;
+typedef struct _EMailConfigSummaryPagePrivate EMailConfigSummaryPagePrivate;
+
+struct _EMailConfigSummaryPage {
+	GtkBox parent;
+	EMailConfigSummaryPagePrivate *priv;
+};
+
+struct _EMailConfigSummaryPageClass {
+	GtkBoxClass parent_class;
+
+	/* Signals */
+	void		(*refresh)		(EMailConfigSummaryPage *page);
+};
+
+GType		e_mail_config_summary_page_get_type
+						(void) G_GNUC_CONST;
+EMailConfigPage *
+		e_mail_config_summary_page_new	(void);
+void		e_mail_config_summary_page_refresh
+						(EMailConfigSummaryPage *page);
+ESource *	e_mail_config_summary_page_get_account_source
+						(EMailConfigSummaryPage *page);
+void		e_mail_config_summary_page_set_account_source
+						(EMailConfigSummaryPage *page,
+						 ESource *account_source);
+ESource *	e_mail_config_summary_page_get_identity_source
+						(EMailConfigSummaryPage *page);
+void		e_mail_config_summary_page_set_identity_source
+						(EMailConfigSummaryPage *page,
+						 ESource *identity_source);
+ESource *	e_mail_config_summary_page_get_transport_source
+						(EMailConfigSummaryPage *page);
+void		e_mail_config_summary_page_set_transport_source
+						(EMailConfigSummaryPage *page,
+						 ESource *transport_source);
+
+#endif /* E_MAIL_CONFIG_SUMMARY_PAGE_H */
+
diff --git a/mail/e-mail-config-welcome-page.c b/mail/e-mail-config-welcome-page.c
new file mode 100644
index 0000000..b0ab66f
--- /dev/null
+++ b/mail/e-mail-config-welcome-page.c
@@ -0,0 +1,197 @@
+/*
+ * e-mail-config-welcome-page.c
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) version 3.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with the program; if not, see <http://www.gnu.org/licenses/>
+ *
+ */
+
+#include "e-mail-config-welcome-page.h"
+
+#include <config.h>
+#include <glib/gi18n-lib.h>
+
+#define E_MAIL_CONFIG_WELCOME_PAGE_GET_PRIVATE(obj) \
+	(G_TYPE_INSTANCE_GET_PRIVATE \
+	((obj), E_TYPE_MAIL_CONFIG_WELCOME_PAGE, EMailConfigWelcomePagePrivate))
+
+struct _EMailConfigWelcomePagePrivate {
+	gchar *text;
+};
+
+enum {
+	PROP_0,
+	PROP_TEXT
+};
+
+/* Forward Declarations */
+static void	e_mail_config_welcome_page_interface_init
+					(EMailConfigPageInterface *interface);
+
+G_DEFINE_TYPE_WITH_CODE (
+	EMailConfigWelcomePage,
+	e_mail_config_welcome_page,
+	GTK_TYPE_BOX,
+	G_IMPLEMENT_INTERFACE (
+		E_TYPE_MAIL_CONFIG_PAGE,
+		e_mail_config_welcome_page_interface_init))
+
+static void
+mail_config_welcome_page_set_property (GObject *object,
+                                       guint property_id,
+                                       const GValue *value,
+                                       GParamSpec *pspec)
+{
+	switch (property_id) {
+		case PROP_TEXT:
+			e_mail_config_welcome_page_set_text (
+				E_MAIL_CONFIG_WELCOME_PAGE (object),
+				g_value_get_string (value));
+			return;
+	}
+
+	G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+}
+
+static void
+mail_config_welcome_page_get_property (GObject *object,
+                                       guint property_id,
+                                       GValue *value,
+                                       GParamSpec *pspec)
+{
+	switch (property_id) {
+		case PROP_TEXT:
+			g_value_set_string (
+				value,
+				e_mail_config_welcome_page_get_text (
+				E_MAIL_CONFIG_WELCOME_PAGE (object)));
+			return;
+	}
+
+	G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+}
+
+static void
+mail_config_welcome_page_finalize (GObject *object)
+{
+	EMailConfigWelcomePagePrivate *priv;
+
+	priv = E_MAIL_CONFIG_WELCOME_PAGE_GET_PRIVATE (object);
+
+	g_free (priv->text);
+
+	/* Chain up to parent's finalize() method. */
+	G_OBJECT_CLASS (e_mail_config_welcome_page_parent_class)->
+		finalize (object);
+}
+
+static void
+mail_config_welcome_page_constructed (GObject *object)
+{
+	EMailConfigWelcomePage *page;
+	GtkWidget *widget;
+
+	page = E_MAIL_CONFIG_WELCOME_PAGE (object);
+
+	/* Chain up to parent's constructed() method. */
+	G_OBJECT_CLASS (e_mail_config_welcome_page_parent_class)->
+		constructed (object);
+
+	gtk_orientable_set_orientation (
+		GTK_ORIENTABLE (page), GTK_ORIENTATION_VERTICAL);
+
+	gtk_box_set_spacing (GTK_BOX (page), 12);
+
+	gtk_widget_set_valign (GTK_WIDGET (page), GTK_ALIGN_CENTER);
+
+	widget = gtk_label_new (NULL);
+	gtk_label_set_line_wrap (GTK_LABEL (widget), TRUE);
+	gtk_misc_set_alignment (GTK_MISC (widget), 0.0, 0.5);
+	gtk_box_pack_start (GTK_BOX (page), widget, FALSE, FALSE, 0);
+	gtk_widget_show (widget);
+
+	g_object_bind_property (
+		page, "text",
+		widget, "label",
+		G_BINDING_BIDIRECTIONAL |
+		G_BINDING_SYNC_CREATE);
+}
+
+static void
+e_mail_config_welcome_page_class_init (EMailConfigWelcomePageClass *class)
+{
+	GObjectClass *object_class;
+
+	g_type_class_add_private (
+		class, sizeof (EMailConfigWelcomePagePrivate));
+
+	object_class = G_OBJECT_CLASS (class);
+	object_class->set_property = mail_config_welcome_page_set_property;
+	object_class->get_property = mail_config_welcome_page_get_property;
+	object_class->finalize = mail_config_welcome_page_finalize;
+	object_class->constructed = mail_config_welcome_page_constructed;
+
+	g_object_class_install_property (
+		object_class,
+		PROP_TEXT,
+		g_param_spec_string (
+			"text",
+			"Text",
+			"Welcome message",
+			_("Welcome to the Evolution Mail Configuration "
+			  "Assistant.\n\nClick \"Continue\" to begin."),
+			G_PARAM_READWRITE |
+			G_PARAM_CONSTRUCT |
+			G_PARAM_STATIC_STRINGS));
+}
+
+static void
+e_mail_config_welcome_page_interface_init (EMailConfigPageInterface *interface)
+{
+	interface->title = _("Welcome");
+	interface->page_type = GTK_ASSISTANT_PAGE_INTRO;
+	interface->sort_order = E_MAIL_CONFIG_WELCOME_PAGE_SORT_ORDER;
+}
+
+static void
+e_mail_config_welcome_page_init (EMailConfigWelcomePage *page)
+{
+	page->priv = E_MAIL_CONFIG_WELCOME_PAGE_GET_PRIVATE (page);
+}
+
+EMailConfigPage *
+e_mail_config_welcome_page_new (void)
+{
+	return g_object_new (E_TYPE_MAIL_CONFIG_WELCOME_PAGE, NULL);
+}
+
+const gchar *
+e_mail_config_welcome_page_get_text (EMailConfigWelcomePage *page)
+{
+	g_return_val_if_fail (E_IS_MAIL_CONFIG_WELCOME_PAGE (page), NULL);
+
+	return page->priv->text;
+}
+
+void
+e_mail_config_welcome_page_set_text (EMailConfigWelcomePage *page,
+                                     const gchar *text)
+{
+	g_return_if_fail (E_IS_MAIL_CONFIG_WELCOME_PAGE (page));
+
+	g_free (page->priv->text);
+	page->priv->text = g_strdup ((text != NULL) ? text : "");
+
+	g_object_notify (G_OBJECT (page), "text");
+}
+
diff --git a/mail/e-mail-config-welcome-page.h b/mail/e-mail-config-welcome-page.h
new file mode 100644
index 0000000..a7665ec
--- /dev/null
+++ b/mail/e-mail-config-welcome-page.h
@@ -0,0 +1,75 @@
+/*
+ * e-mail-config-welcome-page.h
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) version 3.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with the program; if not, see <http://www.gnu.org/licenses/>
+ *
+ */
+
+#ifndef E_MAIL_CONFIG_WELCOME_PAGE_H
+#define E_MAIL_CONFIG_WELCOME_PAGE_H
+
+#include <gtk/gtk.h>
+
+#include <mail/e-mail-config-page.h>
+
+/* Standard GObject macros */
+#define E_TYPE_MAIL_CONFIG_WELCOME_PAGE \
+	(e_mail_config_welcome_page_get_type ())
+#define E_MAIL_CONFIG_WELCOME_PAGE(obj) \
+	(G_TYPE_CHECK_INSTANCE_CAST \
+	((obj), E_TYPE_MAIL_CONFIG_WELCOME_PAGE, EMailConfigWelcomePage))
+#define E_MAIL_CONFIG_WELCOME_PAGE_CLASS(cls) \
+	(G_TYPE_CHECK_CLASS_CAST \
+	((cls), E_TYPE_MAIL_CONFIG_WELCOME_PAGE, EMailConfigWelcomePageClass))
+#define E_IS_MAIL_CONFIG_WELCOME_PAGE(obj) \
+	(G_TYPE_CHECK_INSTANCE_TYPE \
+	((obj), E_TYPE_MAIL_CONFIG_WELCOME_PAGE))
+#define E_IS_MAIL_CONFIG_WELCOME_PAGE_CLASS(cls) \
+	(G_TYPE_CHECK_CLASS_TYPE \
+	((cls), E_TYPE_MAIL_CONFIG_WELCOME_PAGE))
+#define E_MAIL_CONFIG_WELCOME_PAGE_GET_CLASS(obj) \
+	(G_TYPE_INSTANCE_GET_CLASS \
+	((obj), E_TYPE_MAIL_CONFIG_WELCOME_PAGE, EMailConfigWelcomePageClass))
+
+#define E_MAIL_CONFIG_WELCOME_PAGE_SORT_ORDER (0)
+
+G_BEGIN_DECLS
+
+typedef struct _EMailConfigWelcomePage EMailConfigWelcomePage;
+typedef struct _EMailConfigWelcomePageClass EMailConfigWelcomePageClass;
+typedef struct _EMailConfigWelcomePagePrivate EMailConfigWelcomePagePrivate;
+
+struct _EMailConfigWelcomePage {
+	GtkBox parent;
+	EMailConfigWelcomePagePrivate *priv;
+};
+
+struct _EMailConfigWelcomePageClass {
+	GtkBoxClass parent_class;
+};
+
+GType		e_mail_config_welcome_page_get_type
+						(void) G_GNUC_CONST;
+EMailConfigPage *
+		e_mail_config_welcome_page_new	(void);
+const gchar *	e_mail_config_welcome_page_get_text
+						(EMailConfigWelcomePage *page);
+void		e_mail_config_welcome_page_set_text
+						(EMailConfigWelcomePage *page,
+						 const gchar *text);
+
+G_END_DECLS
+
+#endif /* E_MAIL_CONFIG_WELCOME_PAGE_H */
+
diff --git a/mail/e-mail-config-window.c b/mail/e-mail-config-window.c
new file mode 100644
index 0000000..6dfe482
--- /dev/null
+++ b/mail/e-mail-config-window.c
@@ -0,0 +1,500 @@
+/*
+ * e-mail-config-window.c
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) version 3.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with the program; if not, see <http://www.gnu.org/licenses/>
+ *
+ */
+
+#include "e-mail-config-window.h"
+
+#include <config.h>
+#include <glib/gi18n-lib.h>
+
+#include <libedataserver/e-source-mail-account.h>
+#include <libedataserver/e-source-mail-submission.h>
+
+#include <libevolution-utils/e-alert-dialog.h>
+#include <libevolution-utils/e-alert-sink.h>
+#include <misc/e-alert-bar.h>
+
+#include <mail/e-mail-config-notebook.h>
+#include <mail/e-mail-config-sidebar.h>
+
+#define E_MAIL_CONFIG_WINDOW_GET_PRIVATE(obj) \
+	(G_TYPE_INSTANCE_GET_PRIVATE \
+	((obj), E_TYPE_MAIL_CONFIG_WINDOW, EMailConfigWindowPrivate))
+
+struct _EMailConfigWindowPrivate {
+	EMailSession *session;
+	ESource *original_source;
+
+	/* Scratch Sources */
+	ESource *account_source;
+	ESource *identity_source;
+	ESource *transport_source;
+
+	GtkWidget *sidebar;   /* not referenced */
+	GtkWidget *notebook;  /* not referenced */
+	GtkWidget *alert_bar; /* not referenced */
+};
+
+enum {
+	PROP_0,
+	PROP_ORIGINAL_SOURCE,
+	PROP_SESSION
+};
+
+/* Forward Declarations */
+static void	e_mail_config_window_alert_sink_init
+					(EAlertSinkInterface *interface);
+
+G_DEFINE_TYPE_WITH_CODE (
+	EMailConfigWindow,
+	e_mail_config_window,
+	GTK_TYPE_DIALOG,
+	G_IMPLEMENT_INTERFACE (
+		E_TYPE_ALERT_SINK,
+		e_mail_config_window_alert_sink_init))
+
+static void
+mail_config_window_setup_scratch_sources (EMailConfigWindow *window)
+{
+	ESource *source;
+	ESourceRegistry *registry;
+	ESourceMailAccount *account_ext;
+	ESourceMailSubmission *submission_ext;
+	EMailSession *session;
+	EDBusObject *dbus_object;
+	const gchar *extension_name;
+	const gchar *uid;
+
+	session = e_mail_config_window_get_session (window);
+	registry = e_mail_session_get_registry (session);
+
+	source = window->priv->original_source;
+	dbus_object = e_source_get_dbus_object (source);
+	source = e_source_new (dbus_object, NULL);
+	window->priv->account_source = source;
+
+	extension_name = E_SOURCE_EXTENSION_MAIL_ACCOUNT;
+	account_ext = e_source_get_extension (source, extension_name);
+	uid = e_source_mail_account_get_identity_uid (account_ext);
+	source = e_source_registry_lookup_by_uid (registry, uid);
+	dbus_object = e_source_get_dbus_object (source);
+	source = e_source_new (dbus_object, NULL);
+	window->priv->identity_source = source;
+
+	extension_name = E_SOURCE_EXTENSION_MAIL_SUBMISSION;
+	submission_ext = e_source_get_extension (source, extension_name);
+	uid = e_source_mail_submission_get_transport_uid (submission_ext);
+	source = e_source_registry_lookup_by_uid (registry, uid);
+	dbus_object = e_source_get_dbus_object (source);
+	source = e_source_new (dbus_object, NULL);
+	window->priv->transport_source = source;
+
+	/* Keep all three display names synchronized. */
+
+	g_object_bind_property (
+		window->priv->account_source, "display-name",
+		window->priv->identity_source, "display-name",
+		G_BINDING_BIDIRECTIONAL);
+
+	g_object_bind_property (
+		window->priv->account_source, "display-name",
+		window->priv->transport_source, "display-name",
+		G_BINDING_BIDIRECTIONAL);
+}
+
+static void
+mail_config_window_commit_cb (GObject *object,
+                              GAsyncResult *result,
+                              gpointer user_data)
+{
+	EMailConfigWindow *window;
+	EMailConfigNotebook *notebook;
+	GdkWindow *gdk_window;
+	GError *error = NULL;
+
+	window = E_MAIL_CONFIG_WINDOW (user_data);
+	notebook = E_MAIL_CONFIG_NOTEBOOK (object);
+
+	/* Set the cursor back to normal. */
+	gdk_window = gtk_widget_get_window (GTK_WIDGET (window));
+	gdk_window_set_cursor (gdk_window, NULL);
+
+	/* Allow user interaction with window content. */
+	gtk_widget_set_sensitive (GTK_WIDGET (window), TRUE);
+
+	e_mail_config_notebook_commit_finish (notebook, result, &error);
+
+	/* Ignore cancellations. */
+	if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) {
+		g_object_unref (window);
+		g_error_free (error);
+
+	} else if (error != NULL) {
+		e_alert_submit (
+			E_ALERT_SINK (window),
+			"mail:session-message-error",
+			error->message, NULL);
+		g_object_unref (window);
+		g_error_free (error);
+
+	} else {
+		gtk_widget_destroy (GTK_WIDGET (window));
+	}
+}
+
+static void
+mail_config_window_commit (EMailConfigWindow *window)
+{
+	GdkCursor *gdk_cursor;
+	GdkWindow *gdk_window;
+	EMailConfigNotebook *notebook;
+
+	notebook = E_MAIL_CONFIG_NOTEBOOK (window->priv->notebook);
+
+	/* Clear any previous alerts. */
+	e_alert_bar_clear (E_ALERT_BAR (window->priv->alert_bar));
+
+	/* Make the cursor appear busy. */
+	gdk_cursor = gdk_cursor_new (GDK_WATCH);
+	gdk_window = gtk_widget_get_window (GTK_WIDGET (window));
+	gdk_window_set_cursor (gdk_window, gdk_cursor);
+	g_object_unref (gdk_cursor);
+
+	/* Prevent user interaction with window content. */
+	gtk_widget_set_sensitive (GTK_WIDGET (window), FALSE);
+
+	/* XXX This operation is not cancellable. */
+	e_mail_config_notebook_commit (
+		notebook, NULL,
+		mail_config_window_commit_cb,
+		g_object_ref (window));
+}
+
+static void
+mail_config_window_set_original_source (EMailConfigWindow *window,
+                                        ESource *original_source)
+{
+	g_return_if_fail (E_IS_SOURCE (original_source));
+	g_return_if_fail (window->priv->original_source == NULL);
+
+	window->priv->original_source = g_object_ref (original_source);
+}
+
+static void
+mail_config_window_set_session (EMailConfigWindow *window,
+                                EMailSession *session)
+{
+	g_return_if_fail (E_IS_MAIL_SESSION (session));
+	g_return_if_fail (window->priv->session == NULL);
+
+	window->priv->session = g_object_ref (session);
+}
+
+static void
+mail_config_window_set_property (GObject *object,
+                                 guint property_id,
+                                 const GValue *value,
+                                 GParamSpec *pspec)
+{
+	switch (property_id) {
+		case PROP_ORIGINAL_SOURCE:
+			mail_config_window_set_original_source (
+				E_MAIL_CONFIG_WINDOW (object),
+				g_value_get_object (value));
+			return;
+
+		case PROP_SESSION:
+			mail_config_window_set_session (
+				E_MAIL_CONFIG_WINDOW (object),
+				g_value_get_object (value));
+			return;
+	}
+
+	G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+}
+
+static void
+mail_config_window_get_property (GObject *object,
+                                 guint property_id,
+                                 GValue *value,
+                                 GParamSpec *pspec)
+{
+	switch (property_id) {
+		case PROP_ORIGINAL_SOURCE:
+			g_value_set_object (
+				value,
+				e_mail_config_window_get_original_source (
+				E_MAIL_CONFIG_WINDOW (object)));
+			return;
+
+		case PROP_SESSION:
+			g_value_set_object (
+				value,
+				e_mail_config_window_get_session (
+				E_MAIL_CONFIG_WINDOW (object)));
+			return;
+	}
+
+	G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+}
+
+static void
+mail_config_window_dispose (GObject *object)
+{
+	EMailConfigWindowPrivate *priv;
+
+	priv = E_MAIL_CONFIG_WINDOW_GET_PRIVATE (object);
+
+	if (priv->session != NULL) {
+		g_object_unref (priv->session);
+		priv->session = NULL;
+	}
+
+	if (priv->original_source != NULL) {
+		g_object_unref (priv->original_source);
+		priv->original_source = NULL;
+	}
+
+	if (priv->account_source != NULL) {
+		g_object_unref (priv->account_source);
+		priv->account_source = NULL;
+	}
+
+	if (priv->identity_source != NULL) {
+		g_object_unref (priv->identity_source);
+		priv->identity_source = NULL;
+	}
+
+	if (priv->transport_source != NULL) {
+		g_object_unref (priv->transport_source);
+		priv->transport_source = NULL;
+	}
+
+	/* Chain up to parent's dispose() method. */
+	G_OBJECT_CLASS (e_mail_config_window_parent_class)->dispose (object);
+}
+
+static void
+mail_config_window_constructed (GObject *object)
+{
+	EMailConfigWindow *window;
+	GtkWidget *container;
+	GtkWidget *widget;
+
+	window = E_MAIL_CONFIG_WINDOW (object);
+
+	/* Chain up to parent's constructed() method. */
+	G_OBJECT_CLASS (e_mail_config_window_parent_class)->
+		constructed (object);
+
+	mail_config_window_setup_scratch_sources (window);
+
+	gtk_container_set_border_width (GTK_CONTAINER (window), 5);
+	gtk_window_set_title (GTK_WINDOW (window), _("Account Editor"));
+	gtk_window_set_position (GTK_WINDOW (window), GTK_WIN_POS_CENTER);
+
+	gtk_dialog_add_buttons (
+		GTK_DIALOG (window),
+		GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
+		GTK_STOCK_APPLY, GTK_RESPONSE_APPLY,
+		NULL);
+
+	container = gtk_dialog_get_content_area (GTK_DIALOG (window));
+
+	widget = gtk_grid_new ();
+	gtk_container_set_border_width (GTK_CONTAINER (widget), 5);
+	gtk_box_pack_start (GTK_BOX (container), widget, TRUE, TRUE, 0);
+	gtk_widget_show (widget);
+
+	container = widget;
+
+	widget = e_alert_bar_new ();
+	gtk_grid_attach (GTK_GRID (container), widget, 0, 0, 2, 1);
+	window->priv->alert_bar = widget;  /* not referenced */
+	/* EAlertBar controls its own visibility. */
+
+	/* Add an extra-wide margin to the left and bottom.
+	 *
+	 * XXX The bottom margin is tricky.  We want a 24px margin between
+	 *     the notebook and the dialog action buttons, but we have to
+	 *     take style property defaults into consideration:
+	 *
+	 *     24 - action-area-border (5) - content-area-border (2) = 17
+	 */
+	widget = e_mail_config_notebook_new (
+		window->priv->session,
+		window->priv->account_source,
+		window->priv->identity_source,
+		window->priv->transport_source);
+	gtk_widget_set_hexpand (widget, TRUE);
+	gtk_widget_set_vexpand (widget, TRUE);
+	gtk_widget_set_margin_left (widget, 24);
+	gtk_widget_set_margin_bottom (widget, 17);
+	gtk_notebook_set_show_tabs (GTK_NOTEBOOK (widget), FALSE);
+	gtk_grid_attach (GTK_GRID (container), widget, 1, 0, 1, 1);
+	window->priv->notebook = widget;  /* not referenced */
+	gtk_widget_show (widget);
+
+	widget = e_mail_config_sidebar_new (
+		E_MAIL_CONFIG_NOTEBOOK (window->priv->notebook));
+	gtk_widget_set_vexpand (widget, TRUE);
+	gtk_grid_attach (GTK_GRID (container), widget, 0, 0, 1, 1);
+	window->priv->sidebar = widget;  /* not referenced */
+	gtk_widget_show (widget);
+
+	/* Make the Apply button insensitive when required
+	 * fields in the notebook pages are incomplete. */
+
+	widget = gtk_dialog_get_widget_for_response (
+		GTK_DIALOG (window), GTK_RESPONSE_APPLY);
+
+	g_object_bind_property (
+		window->priv->notebook, "complete",
+		widget, "sensitive",
+		G_BINDING_SYNC_CREATE);
+}
+
+static void
+mail_config_window_response (GtkDialog *dialog,
+                             gint response_id)
+{
+	/* Do not chain up.  GtkDialog does not implement this method. */
+
+	switch (response_id) {
+		case GTK_RESPONSE_APPLY:
+			mail_config_window_commit (
+				E_MAIL_CONFIG_WINDOW (dialog));
+			break;
+		case GTK_RESPONSE_CANCEL:
+			gtk_widget_destroy (GTK_WIDGET (dialog));
+			break;
+		default:
+			break;
+	}
+}
+
+static void
+mail_config_window_submit_alert (EAlertSink *alert_sink,
+                                 EAlert *alert)
+{
+	EMailConfigWindowPrivate *priv;
+	EAlertBar *alert_bar;
+	GtkWidget *dialog;
+	GtkWindow *parent;
+
+	priv = E_MAIL_CONFIG_WINDOW_GET_PRIVATE (alert_sink);
+
+	switch (e_alert_get_message_type (alert)) {
+		case GTK_MESSAGE_INFO:
+		case GTK_MESSAGE_WARNING:
+		case GTK_MESSAGE_ERROR:
+			alert_bar = E_ALERT_BAR (priv->alert_bar);
+			e_alert_bar_add_alert (alert_bar, alert);
+			break;
+
+		default:
+			parent = GTK_WINDOW (alert_sink);
+			dialog = e_alert_dialog_new (parent, alert);
+			gtk_dialog_run (GTK_DIALOG (dialog));
+			gtk_widget_destroy (dialog);
+			break;
+	}
+}
+
+static void
+e_mail_config_window_class_init (EMailConfigWindowClass *class)
+{
+	GObjectClass *object_class;
+	GtkDialogClass *dialog_class;
+
+	g_type_class_add_private (class, sizeof (EMailConfigWindowPrivate));
+
+	object_class = G_OBJECT_CLASS (class);
+	object_class->set_property = mail_config_window_set_property;
+	object_class->get_property = mail_config_window_get_property;
+	object_class->dispose = mail_config_window_dispose;
+	object_class->constructed = mail_config_window_constructed;
+
+	dialog_class = GTK_DIALOG_CLASS (class);
+	dialog_class->response = mail_config_window_response;
+
+	g_object_class_install_property (
+		object_class,
+		PROP_ORIGINAL_SOURCE,
+		g_param_spec_object (
+			"original-source",
+			"Original Source",
+			"Original mail account source",
+			E_TYPE_SOURCE,
+			G_PARAM_READWRITE |
+			G_PARAM_CONSTRUCT_ONLY |
+			G_PARAM_STATIC_STRINGS));
+
+	g_object_class_install_property (
+		object_class,
+		PROP_SESSION,
+		g_param_spec_object (
+			"session",
+			"Session",
+			"Mail session",
+			E_TYPE_MAIL_SESSION,
+			G_PARAM_READWRITE |
+			G_PARAM_CONSTRUCT_ONLY |
+			G_PARAM_STATIC_STRINGS));
+}
+
+static void
+e_mail_config_window_alert_sink_init (EAlertSinkInterface *interface)
+{
+	interface->submit_alert = mail_config_window_submit_alert;
+}
+
+static void
+e_mail_config_window_init (EMailConfigWindow *window)
+{
+	window->priv = E_MAIL_CONFIG_WINDOW_GET_PRIVATE (window);
+}
+
+GtkWidget *
+e_mail_config_window_new (EMailSession *session,
+                          ESource *original_source)
+{
+	g_return_val_if_fail (E_IS_MAIL_SESSION (session), NULL);
+	g_return_val_if_fail (E_IS_SOURCE (original_source), NULL);
+
+	return g_object_new (
+		E_TYPE_MAIL_CONFIG_WINDOW,
+		"original-source", original_source,
+		"session", session, NULL);
+}
+
+EMailSession *
+e_mail_config_window_get_session (EMailConfigWindow *window)
+{
+	g_return_val_if_fail (E_IS_MAIL_CONFIG_WINDOW (window), NULL);
+
+	return window->priv->session;
+}
+
+ESource *
+e_mail_config_window_get_original_source (EMailConfigWindow *window)
+{
+	g_return_val_if_fail (E_IS_MAIL_CONFIG_WINDOW (window), NULL);
+
+	return window->priv->original_source;
+}
+
diff --git a/mail/e-mail-config-window.h b/mail/e-mail-config-window.h
new file mode 100644
index 0000000..78a7c07
--- /dev/null
+++ b/mail/e-mail-config-window.h
@@ -0,0 +1,71 @@
+/*
+ * e-mail-config-window.h
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) version 3.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with the program; if not, see <http://www.gnu.org/licenses/>
+ *
+ */
+
+#ifndef E_MAIL_CONFIG_WINDOW_H
+#define E_MAIL_CONFIG_WINDOW_H
+
+#include <gtk/gtk.h>
+
+#include <libemail-engine/e-mail-session.h>
+
+/* Standard GObject macros */
+#define E_TYPE_MAIL_CONFIG_WINDOW \
+	(e_mail_config_window_get_type ())
+#define E_MAIL_CONFIG_WINDOW(obj) \
+	(G_TYPE_CHECK_INSTANCE_CAST \
+	((obj), E_TYPE_MAIL_CONFIG_WINDOW, EMailConfigWindow))
+#define E_MAIL_CONFIG_WINDOW_CLASS(cls) \
+	(G_TYPE_CHECK_CLASS_CAST \
+	((cls), E_TYPE_MAIL_CONFIG_WINDOW, EMailConfigWindowClass))
+#define E_IS_MAIL_CONFIG_WINDOW(obj) \
+	(G_TYPE_CHECK_INSTANCE_TYPE \
+	((obj), E_TYPE_MAIL_CONFIG_WINDOW))
+#define E_IS_MAIL_CONFIG_WINDOW_CLASS(cls) \
+	(G_TYPE_CHECK_CLASS_TYPE \
+	((cls), E_TYPE_MAIL_CONFIG_WINDOW))
+#define E_MAIL_CONFIG_WINDOW_GET_CLASS(obj) \
+	(G_TYPE_INSTANCE_GET_CLASS \
+	((obj), E_TYPE_MAIL_CONFIG_WINDOW, EMailConfigWindowClass))
+
+G_BEGIN_DECLS
+
+typedef struct _EMailConfigWindow EMailConfigWindow;
+typedef struct _EMailConfigWindowClass EMailConfigWindowClass;
+typedef struct _EMailConfigWindowPrivate EMailConfigWindowPrivate;
+
+struct _EMailConfigWindow {
+	GtkDialog parent;
+	EMailConfigWindowPrivate *priv;
+};
+
+struct _EMailConfigWindowClass {
+	GtkDialogClass parent_class;
+};
+
+GType		e_mail_config_window_get_type	(void) G_GNUC_CONST;
+GtkWidget *	e_mail_config_window_new	(EMailSession *session,
+						 ESource *original_source);
+EMailSession *	e_mail_config_window_get_session
+						(EMailConfigWindow *window);
+ESource *	e_mail_config_window_get_original_source
+						(EMailConfigWindow *window);
+
+G_END_DECLS
+
+#endif /* E_MAIL_CONFIG_WINDOW_H */
+
diff --git a/mail/e-mail-folder-pane.c b/mail/e-mail-folder-pane.c
index 7e0457e..03168ce 100644
--- a/mail/e-mail-folder-pane.c
+++ b/mail/e-mail-folder-pane.c
@@ -74,7 +74,10 @@ folder_pane_set_preview_visible (EMailView *view,
 static guint
 mail_paned_view_open_selected_mail (EMailPanedView *view)
 {
+	EShell *shell;
 	EMailReader *reader;
+	EMailBackend *backend;
+	ESourceRegistry *registry;
 	GPtrArray *uids;
 	gint i;
 	GtkWindow *window;
@@ -88,6 +91,10 @@ mail_paned_view_open_selected_mail (EMailPanedView *view)
 	uids = e_mail_reader_get_selected_uids (reader);
 	g_return_val_if_fail (uids != NULL, 0);
 
+	backend = e_mail_reader_get_backend (reader);
+	shell = e_shell_backend_get_shell (E_SHELL_BACKEND (backend));
+	registry = e_shell_get_registry (shell);
+
 	/* XXX Either e_mail_reader_get_selected_uids()
 	 *     or MessageList should do this itself. */
 	g_ptr_array_set_free_func (uids, (GDestroyNotify) g_free);
@@ -97,9 +104,9 @@ mail_paned_view_open_selected_mail (EMailPanedView *view)
 		return 0;
 	}
 
-	if (em_utils_folder_is_drafts (folder) ||
-		em_utils_folder_is_outbox (folder) ||
-		em_utils_folder_is_templates (folder)) {
+	if (em_utils_folder_is_drafts (registry, folder) ||
+		em_utils_folder_is_outbox (registry, folder) ||
+		em_utils_folder_is_templates (registry, folder)) {
 		em_utils_edit_messages (reader, folder, uids, TRUE);
 		g_ptr_array_unref (uids);
 		return 0;
@@ -127,8 +134,8 @@ mail_paned_view_open_selected_mail (EMailPanedView *view)
 			CAMEL_VEE_FOLDER (folder),
 			(CamelVeeMessageInfo *) info, &real_uid);
 
-		if (em_utils_folder_is_drafts (real_folder) ||
-			em_utils_folder_is_outbox (real_folder)) {
+		if (em_utils_folder_is_drafts (registry, real_folder) ||
+			em_utils_folder_is_outbox (registry, real_folder)) {
 			GPtrArray *edits;
 
 			edits = g_ptr_array_new_with_free_func (
diff --git a/mail/e-mail-migrate.c b/mail/e-mail-migrate.c
index b54a764..4bc3610 100644
--- a/mail/e-mail-migrate.c
+++ b/mail/e-mail-migrate.c
@@ -61,9 +61,6 @@
 #include <e-util/e-util-private.h>
 #include <e-util/e-plugin.h>
 
-#include <libemail-utils/e-account-utils.h>
-#include <libemail-utils/e-signature-utils.h>
-
 #include <libemail-engine/e-mail-folder-utils.h>
 
 #include "e-mail-backend.h"
@@ -229,6 +226,7 @@ cp (const gchar *src,
 static void
 em_update_accounts_2_11 (void)
 {
+#if 0  /* ACCOUNT_MGMT */
 	EAccountList *accounts;
 	EIterator *iter;
 	gboolean changed = FALSE;
@@ -261,6 +259,7 @@ em_update_accounts_2_11 (void)
 
 	if (changed)
 		e_account_list_save (accounts);
+#endif /* ACCOUNT_MGMT */
 }
 
 #endif	/* !G_OS_WIN32 */
@@ -670,6 +669,7 @@ static gboolean
 create_mbox_account (EShellBackend *shell_backend,
                      EMMigrateSession *session)
 {
+#if 0 /* ACCOUNT_MGMT */
 	EMailBackend *mail_backend;
 	EMailSession *mail_session;
 	CamelService *service;
@@ -739,6 +739,7 @@ exit:
 	g_free (uri);
 	g_free (name);
 	g_free (id);
+#endif /* ACCOUNT_MGMT */
 
 	return TRUE;
 }
@@ -746,6 +747,7 @@ exit:
 static void
 change_sent_and_drafts_local_folders (EShellBackend *shell_backend)
 {
+#if 0  /* ACCOUNT_MGMT */
 	EMailBackend *backend;
 	EMailSession *session;
 	EAccountList *accounts;
@@ -830,243 +832,7 @@ change_sent_and_drafts_local_folders (EShellBackend *shell_backend)
 
 	if (changed)
 		e_account_list_save (accounts);
-}
-
-static void
-em_rename_camel_url_params (CamelURL *url)
-{
-	/* This list includes known URL parameters from built-in providers
-	 * in Camel, as well as from evolution-exchange, evolution-groupwise,
-	 * and evolution-mapi.  Add more as needed. */
-	static struct {
-		const gchar *url_parameter;
-		const gchar *property_name;
-	} camel_url_conversion[] = {
-		{ "ad_auth",			"gc-auth-method" },
-		{ "ad_browse",			"gc-allow-browse" },
-		{ "ad_expand_groups",		"gc-expand-groups" },
-		{ "ad_limit",			"gc-results-limit" },
-		{ "ad_server",			"gc-server-name" },
-		{ "all_headers",		"fetch-headers" },
-		{ "basic_headers",		"fetch-headers" },
-		{ "cachedconn"			"concurrent-connections" },
-		{ "check_all",			"check-all" },
-		{ "check_lsub",			"check-subscribed" },
-		{ "command",			"shell-command" },
-		{ "delete_after",		"delete-after-days" },
-		{ "delete_expunged",		"delete-expunged" },
-		{ "disable_extensions",		"disable-extensions" },
-		{ "dotfolders",			"use-dot-folders" },
-		{ "filter",			"filter-inbox" },
-		{ "filter_junk",		"filter-junk" },
-		{ "filter_junk_inbox",		"filter-junk-inbox" },
-		{ "folder_hierarchy_relative",	"folder-hierarchy-relative" },
-		{ "imap_custom_headers",	"fetch-headers-extra" },
-		{ "keep_on_server",		"keep-on-server" },
-		{ "offline_sync",		"stay-synchronized" },
-		{ "override_namespace",		"use-namespace" },
-		{ "owa_path",			"owa-path" },
-		{ "owa_url",			"owa-url" },
-		{ "password_exp_warn_period",	"password-exp-warn-period" },
-		{ "real_junk_path",		"real-junk-path" },
-		{ "real_trash_path",		"real-trash-path" },
-		{ "show_short_notation",	"short-folder-names" },
-		{ "soap_port",			"soap-port" },
-		{ "ssl",			"security-method" },
-		{ "sync_offline",		"stay-synchronized" },
-		{ "use_command",		"use-shell-command" },
-		{ "use_idle",			"use-idle" },
-		{ "use_lsub",			"use-subscriptions" },
-		{ "use_qresync",		"use-qresync" },
-		{ "use_ssl",			"security-method" },
-		{ "xstatus",			"use-xstatus-headers" }
-	};
-
-	const gchar *param;
-	const gchar *use_param;
-	gint ii;
-
-	for (ii = 0; ii < G_N_ELEMENTS (camel_url_conversion); ii++) {
-		const gchar *key;
-		gpointer value;
-
-		key = camel_url_conversion[ii].url_parameter;
-		value = g_datalist_get_data (&url->params, key);
-
-		if (value == NULL)
-			continue;
-
-		g_datalist_remove_no_notify (&url->params, key);
-
-		key = camel_url_conversion[ii].property_name;
-
-		/* Deal with a few special enum cases where
-		 * the parameter value also needs renamed. */
-
-		if (strcmp (key, "all_headers") == 0) {
-			GEnumClass *enum_class;
-			GEnumValue *enum_value;
-
-			enum_class = g_type_class_ref (
-				CAMEL_TYPE_FETCH_HEADERS_TYPE);
-			enum_value = g_enum_get_value (
-				enum_class, CAMEL_FETCH_HEADERS_ALL);
-			if (enum_value != NULL) {
-				g_free (value);
-				value = g_strdup (enum_value->value_nick);
-			} else
-				g_warn_if_reached ();
-			g_type_class_unref (enum_class);
-		}
-
-		if (strcmp (key, "basic_headers") == 0) {
-			GEnumClass *enum_class;
-			GEnumValue *enum_value;
-
-			enum_class = g_type_class_ref (
-				CAMEL_TYPE_FETCH_HEADERS_TYPE);
-			enum_value = g_enum_get_value (
-				enum_class, CAMEL_FETCH_HEADERS_BASIC);
-			if (enum_value != NULL) {
-				g_free (value);
-				value = g_strdup (enum_value->value_nick);
-			} else
-				g_warn_if_reached ();
-			g_type_class_unref (enum_class);
-		}
-
-		if (strcmp (key, "imap_custom_headers") == 0)
-			g_strdelimit (value, " ", ',');
-
-		if (strcmp (key, "security-method") == 0) {
-			CamelNetworkSecurityMethod method;
-			GEnumClass *enum_class;
-			GEnumValue *enum_value;
-
-			if (strcmp (value, "always") == 0)
-				method = CAMEL_NETWORK_SECURITY_METHOD_SSL_ON_ALTERNATE_PORT;
-			else if (strcmp (value, "1") == 0)
-				method = CAMEL_NETWORK_SECURITY_METHOD_SSL_ON_ALTERNATE_PORT;
-			else if (strcmp (value, "when-possible") == 0)
-				method = CAMEL_NETWORK_SECURITY_METHOD_STARTTLS_ON_STANDARD_PORT;
-			else
-				method = CAMEL_NETWORK_SECURITY_METHOD_NONE;
-
-			enum_class = g_type_class_ref (
-				CAMEL_TYPE_NETWORK_SECURITY_METHOD);
-			enum_value = g_enum_get_value (enum_class, method);
-			if (enum_value != NULL) {
-				g_free (value);
-				value = g_strdup (enum_value->value_nick);
-			} else
-				g_warn_if_reached ();
-			g_type_class_unref (enum_class);
-		}
-
-		g_datalist_set_data_full (&url->params, key, value, g_free);
-	}
-
-	/* A few more adjustments...
-	 *
-	 * These are all CAMEL_PROVIDER_CONF_CHECKSPIN settings.  The spin
-	 * button value is bound to "param" and the checkbox state is bound
-	 * to "use-param".  The "use-param" settings are new.  If "param"
-	 * exists but no "use-param", then set "use-param" to "true". */
-
-	param = g_datalist_get_data (&url->params, "gc-results-limit");
-	use_param = g_datalist_get_data (&url->params, "use-gc-results-limit");
-	if (param != NULL && *param != '\0' && use_param == NULL) {
-		g_datalist_set_data_full (
-			&url->params, "use-gc-results-limit",
-			g_strdup ("true"), (GDestroyNotify) g_free);
-	}
-
-	param = g_datalist_get_data (&url->params, "kerberos");
-	if (g_strcmp0 (param, "required") == 0) {
-		g_datalist_set_data_full (
-			&url->params, "kerberos",
-			g_strdup ("true"), (GDestroyNotify) g_free);
-	}
-
-	param = g_datalist_get_data (
-		&url->params, "password-exp-warn-period");
-	use_param = g_datalist_get_data (
-		&url->params, "use-password-exp-warn-period");
-	if (param != NULL && *param != '\0' && use_param == NULL) {
-		g_datalist_set_data_full (
-			&url->params, "use-password-exp-warn-period",
-			g_strdup ("true"), (GDestroyNotify) g_free);
-	}
-
-	param = g_datalist_get_data (&url->params, "real-junk-path");
-	use_param = g_datalist_get_data (&url->params, "use-real-junk-path");
-	if (param != NULL && *param != '\0' && use_param == NULL) {
-		g_datalist_set_data_full (
-			&url->params, "use-real-junk-path",
-			g_strdup ("true"), (GDestroyNotify) g_free);
-	}
-
-	param = g_datalist_get_data (&url->params, "real-trash-path");
-	use_param = g_datalist_get_data (&url->params, "use-real-trash-path");
-	if (param != NULL && *param != '\0' && use_param == NULL) {
-		g_datalist_set_data_full (
-			&url->params, "use-real-trash-path",
-			g_strdup ("true"), (GDestroyNotify) g_free);
-	}
-}
-
-static void
-em_rename_account_params (void)
-{
-	EAccountList *account_list;
-	EIterator *iterator;
-
-	/* XXX As of 3.2, CamelServices store settings in GObject properties,
-	 *     not CamelURL parameters.  CamelURL parameters are still used
-	 *     for storage in GConf until we can move account information to
-	 *     key files, but this is only within Evolution.  Some of the new
-	 *     GObject property names differ from the old CamelURL parameter
-	 *     names.  This routine renames the CamelURL parameter names to
-	 *     the GObject property names for all accounts, both the source
-	 *     and tranport URLs. */
-
-	account_list = e_get_account_list ();
-	iterator = e_list_get_iterator (E_LIST (account_list));
-
-	while (e_iterator_is_valid (iterator)) {
-		EAccount *account;
-		CamelURL *url = NULL;
-
-		/* XXX EIterator misuses const. */
-		account = (EAccount *) e_iterator_get (iterator);
-
-		if (account->source->url != NULL)
-			url = camel_url_new (account->source->url, NULL);
-
-		if (url != NULL) {
-			em_rename_camel_url_params (url);
-			g_free (account->source->url);
-			account->source->url = camel_url_to_string (url, 0);
-			camel_url_free (url);
-		}
-
-		url = NULL;
-
-		if (account->transport->url != NULL)
-			url = camel_url_new (account->transport->url, NULL);
-
-		if (url != NULL) {
-			em_rename_camel_url_params (url);
-			g_free (account->transport->url);
-			account->transport->url = camel_url_to_string (url, 0);
-			camel_url_free (url);
-		}
-
-		e_iterator_next (iterator);
-	}
-
-	g_object_unref (iterator);
-	e_account_list_save (account_list);
+#endif /* ACCOUNT_MGMT */
 }
 
 static gboolean
@@ -1296,10 +1062,6 @@ e_mail_migrate (EShellBackend *shell_backend,
 		em_ensure_proxy_ignore_hosts_being_list ();
 	}
 
-	/* Rename account URL parameters to
-	 * match CamelSettings property names. */
-	em_rename_account_params ();
-
 	if (!migrate_local_store (shell_backend))
 		return FALSE;
 
diff --git a/mail/e-mail-paned-view.c b/mail/e-mail-paned-view.c
index e1779a8..6fe3211 100644
--- a/mail/e-mail-paned-view.c
+++ b/mail/e-mail-paned-view.c
@@ -817,6 +817,7 @@ mail_paned_view_update_view_instance (EMailView *view)
 	EShellWindow *shell_window;
 	EShellViewClass *shell_view_class;
 	EShellSettings *shell_settings;
+	ESourceRegistry *registry;
 	GalViewCollection *view_collection;
 	GalViewInstance *view_instance;
 	CamelFolder *folder;
@@ -834,6 +835,7 @@ mail_paned_view_update_view_instance (EMailView *view)
 
 	shell_window = e_shell_view_get_shell_window (shell_view);
 	shell = e_shell_window_get_shell (shell_window);
+	registry = e_shell_get_registry (shell);
 	shell_settings = e_shell_get_shell_settings (shell);
 
 	reader = E_MAIL_READER (view);
@@ -852,9 +854,9 @@ mail_paned_view_update_view_instance (EMailView *view)
 	e_filename_make_safe (view_id);
 
 	outgoing_folder =
-		em_utils_folder_is_drafts (folder) ||
-		em_utils_folder_is_outbox (folder) ||
-		em_utils_folder_is_sent (folder);
+		em_utils_folder_is_drafts (registry, folder) ||
+		em_utils_folder_is_outbox (registry, folder) ||
+		em_utils_folder_is_sent (registry, folder);
 
 	if (e_shell_settings_get_boolean (shell_settings, "mail-global-view-setting"))
 		view_instance = e_shell_view_new_view_instance (
diff --git a/mail/e-mail-reader-utils.c b/mail/e-mail-reader-utils.c
index bc87295..7809270 100644
--- a/mail/e-mail-reader-utils.c
+++ b/mail/e-mail-reader-utils.c
@@ -30,6 +30,7 @@
 #include <glib/gi18n.h>
 #include <libxml/tree.h>
 #include <gtkhtml/gtkhtml.h>
+#include <gconf/gconf-client.h>
 #include <camel/camel.h>
 
 #include "libevolution-utils/e-alert-dialog.h"
@@ -344,7 +345,9 @@ copy_tree_state (EMailReader *src_reader,
 guint
 e_mail_reader_open_selected (EMailReader *reader)
 {
+	EShell *shell;
 	EMailBackend *backend;
+	ESourceRegistry *registry;
 	CamelFolder *folder;
 	GtkWindow *window;
 	GPtrArray *views;
@@ -354,6 +357,9 @@ e_mail_reader_open_selected (EMailReader *reader)
 	g_return_val_if_fail (E_IS_MAIL_READER (reader), 0);
 
 	backend = e_mail_reader_get_backend (reader);
+	shell = e_shell_backend_get_shell (E_SHELL_BACKEND (backend));
+	registry = e_shell_get_registry (shell);
+
 	folder = e_mail_reader_get_folder (reader);
 	uids = e_mail_reader_get_selected_uids (reader);
 	window = e_mail_reader_get_window (reader);
@@ -363,9 +369,9 @@ e_mail_reader_open_selected (EMailReader *reader)
 		return 0;
 	}
 
-	if (em_utils_folder_is_drafts (folder) ||
-		em_utils_folder_is_outbox (folder) ||
-		em_utils_folder_is_templates (folder)) {
+	if (em_utils_folder_is_drafts (registry, folder) ||
+		em_utils_folder_is_outbox (registry, folder) ||
+		em_utils_folder_is_templates (registry, folder)) {
 		em_utils_edit_messages (reader, folder, uids, TRUE);
 		return uids->len;
 	}
@@ -392,8 +398,8 @@ e_mail_reader_open_selected (EMailReader *reader)
 			CAMEL_VEE_FOLDER (folder),
 			(CamelVeeMessageInfo *) info, &real_uid);
 
-		if (em_utils_folder_is_drafts (real_folder) ||
-			em_utils_folder_is_outbox (real_folder)) {
+		if (em_utils_folder_is_drafts (registry, real_folder) ||
+			em_utils_folder_is_outbox (registry, real_folder)) {
 			GPtrArray *edits;
 
 			edits = g_ptr_array_new ();
@@ -1153,9 +1159,12 @@ void
 e_mail_reader_create_filter_from_selected (EMailReader *reader,
                                            gint filter_type)
 {
+	EShell *shell;
 	EActivity *activity;
+	EMailBackend *backend;
 	AsyncContext *context;
 	GCancellable *cancellable;
+	ESourceRegistry *registry;
 	CamelFolder *folder;
 	GPtrArray *uids;
 	const gchar *filter_source;
@@ -1163,12 +1172,16 @@ e_mail_reader_create_filter_from_selected (EMailReader *reader,
 
 	g_return_if_fail (E_IS_MAIL_READER (reader));
 
+	backend = e_mail_reader_get_backend (reader);
+	shell = e_shell_backend_get_shell (E_SHELL_BACKEND (backend));
+	registry = e_shell_get_registry (shell);
+
 	folder = e_mail_reader_get_folder (reader);
 	g_return_if_fail (CAMEL_IS_FOLDER (folder));
 
-	if (em_utils_folder_is_sent (folder))
+	if (em_utils_folder_is_sent (registry, folder))
 		filter_source = E_FILTER_SOURCE_OUTGOING;
-	else if (em_utils_folder_is_outbox (folder))
+	else if (em_utils_folder_is_outbox (registry, folder))
 		filter_source = E_FILTER_SOURCE_OUTGOING;
 	else
 		filter_source = E_FILTER_SOURCE_INCOMING;
diff --git a/mail/e-mail-reader.c b/mail/e-mail-reader.c
index 53d4c31..ef990ef 100644
--- a/mail/e-mail-reader.c
+++ b/mail/e-mail-reader.c
@@ -28,6 +28,8 @@
 #include <glib/gi18n.h>
 #include <gdk/gdkkeysyms.h>
 
+#include <libedataserver/e-source-mail-account.h>
+
 #ifdef HAVE_XFREE
 #include <X11/XF86keysym.h>
 #endif
@@ -39,7 +41,6 @@
 #include "widgets/misc/e-popup-action.h"
 #include "widgets/misc/e-menu-tool-action.h"
 
-#include "libemail-utils/e-account-utils.h"
 #include "libemail-utils/mail-mt.h"
 
 #include "libemail-engine/mail-ops.h"
@@ -768,6 +769,9 @@ static void
 action_mail_message_edit_cb (GtkAction *action,
                              EMailReader *reader)
 {
+	EShell *shell;
+	EMailBackend *backend;
+	ESourceRegistry *registry;
 	CamelFolder *folder;
 	GPtrArray *uids;
 	gboolean replace;
@@ -776,11 +780,15 @@ action_mail_message_edit_cb (GtkAction *action,
 	uids = e_mail_reader_get_selected_uids (reader);
 	g_return_if_fail (uids != NULL);
 
+	backend = e_mail_reader_get_backend (reader);
+	shell = e_shell_backend_get_shell (E_SHELL_BACKEND (backend));
+	registry = e_shell_get_registry (shell);
+
 	/* XXX Either e_mail_reader_get_selected_uids()
 	 *     or MessageList should do this itself. */
 	g_ptr_array_set_free_func (uids, (GDestroyNotify) g_free);
 
-	replace = em_utils_folder_is_drafts (folder);
+	replace = em_utils_folder_is_drafts (registry, folder);
 	em_utils_edit_messages (reader, folder, uids, replace);
 
 	g_ptr_array_unref (uids);
@@ -2871,6 +2879,7 @@ mail_reader_set_folder (EMailReader *reader,
 	EMailReaderPrivate *priv;
 	EMFormatHTML *formatter;
 	CamelFolder *previous_folder;
+	ESourceRegistry *registry;
 	GtkWidget *message_list;
 	EMailBackend *backend;
 	EShell *shell;
@@ -2878,13 +2887,14 @@ mail_reader_set_folder (EMailReader *reader,
 
 	priv = E_MAIL_READER_GET_PRIVATE (reader);
 
-	backend = e_mail_reader_get_backend (reader);
 	formatter = e_mail_reader_get_formatter (reader);
 	message_list = e_mail_reader_get_message_list (reader);
 
 	previous_folder = e_mail_reader_get_folder (reader);
 
+	backend = e_mail_reader_get_backend (reader);
 	shell = e_shell_backend_get_shell (E_SHELL_BACKEND (backend));
+	registry = e_shell_get_registry (shell);
 
 	/* Only synchronize the folder if we're online. */
 	if (previous_folder != NULL && e_shell_get_online (shell))
@@ -2895,9 +2905,9 @@ mail_reader_set_folder (EMailReader *reader,
 		return;
 
 	outgoing = folder != NULL && (
-		em_utils_folder_is_drafts (folder) ||
-		em_utils_folder_is_outbox (folder) ||
-		em_utils_folder_is_sent (folder));
+		em_utils_folder_is_drafts (registry, folder) ||
+		em_utils_folder_is_outbox (registry, folder) ||
+		em_utils_folder_is_sent (registry, folder));
 
 	/* FIXME Need to pass a GCancellable. */
 	em_format_format (EM_FORMAT (formatter), NULL, NULL, NULL, NULL);
@@ -3894,9 +3904,14 @@ e_mail_reader_changed (EMailReader *reader)
 guint32
 e_mail_reader_check_state (EMailReader *reader)
 {
+	EShell *shell;
 	GPtrArray *uids;
 	CamelFolder *folder;
 	CamelStore *store = NULL;
+	EMailBackend *backend;
+	ESourceRegistry *registry;
+	GList *list, *iter;
+	const gchar *extension_name;
 	const gchar *tag;
 	gboolean can_clear_flags = FALSE;
 	gboolean can_flag_completed = FALSE;
@@ -3910,6 +3925,7 @@ e_mail_reader_check_state (EMailReader *reader)
 	gboolean has_undeleted = FALSE;
 	gboolean has_unimportant = FALSE;
 	gboolean has_unread = FALSE;
+	gboolean have_enabled_account = FALSE;
 	gboolean drafts_or_outbox = FALSE;
 	gboolean store_supports_vjunk = FALSE;
 	gboolean is_mailing_list;
@@ -3919,6 +3935,10 @@ e_mail_reader_check_state (EMailReader *reader)
 
 	g_return_val_if_fail (E_IS_MAIL_READER (reader), 0);
 
+	backend = e_mail_reader_get_backend (reader);
+	shell = e_shell_backend_get_shell (E_SHELL_BACKEND (backend));
+	registry = e_shell_get_registry (shell);
+
 	folder = e_mail_reader_get_folder (reader);
 	uids = e_mail_reader_get_selected_uids (reader);
 
@@ -3928,8 +3948,8 @@ e_mail_reader_check_state (EMailReader *reader)
 		is_junk_folder =
 			(folder->folder_flags & CAMEL_FOLDER_IS_JUNK) != 0;
 		drafts_or_outbox =
-			em_utils_folder_is_drafts (folder) ||
-			em_utils_folder_is_outbox (folder);
+			em_utils_folder_is_drafts (registry, folder) ||
+			em_utils_folder_is_outbox (registry, folder);
 	}
 
 	/* Initialize this flag based on whether there are any
@@ -4014,7 +4034,21 @@ e_mail_reader_check_state (EMailReader *reader)
 		camel_folder_free_message_info (folder, info);
 	}
 
-	if (e_get_any_enabled_account () != NULL)
+	extension_name = E_SOURCE_EXTENSION_MAIL_ACCOUNT;
+	list = e_source_registry_list_sources (registry, extension_name);
+
+	for (iter = list; iter != NULL; iter = g_list_next (iter)) {
+		ESource *source = E_SOURCE (iter->data);
+
+		if (e_source_get_enabled (source)) {
+			have_enabled_account = TRUE;
+			break;
+		}
+	}
+
+	g_list_free (list);
+
+	if (have_enabled_account)
 		state |= E_MAIL_READER_HAVE_ENABLED_ACCOUNT;
 	if (uids->len == 1)
 		state |= E_MAIL_READER_SELECTION_SINGLE;
diff --git a/mail/e-mail-ui-session.c b/mail/e-mail-ui-session.c
index fd9a4a9..f5f5bdd 100644
--- a/mail/e-mail-ui-session.c
+++ b/mail/e-mail-ui-session.c
@@ -44,13 +44,13 @@
 
 #include <libedataserver/e-flag.h>
 #include <libedataserver/e-proxy.h>
+#include <libedataserver/e-source-mail-account.h>
 #include <libebackend/e-extensible.h>
 #include <libedataserverui/e-passwords.h>
 
 #include "e-mail-account-store.h"
 
 #include "e-util/e-util.h"
-#include "libemail-utils/e-account-utils.h"
 #include "libevolution-utils/e-alert-dialog.h"
 #include "e-util/e-util-private.h"
 
@@ -82,11 +82,11 @@ typedef struct _SourceContext SourceContext;
 
 struct _EMailUISessionPrivate {
 	FILE *filter_logfile;
+	ESourceRegistry *registry;
 	EMailAccountStore *account_store;
 	EMailLabelListStore *label_store;
 
-	EAccountList *account_list;
-	gulong account_changed_handler_id;
+	gulong source_changed_handler_id;
 };
 
 enum {
@@ -475,62 +475,28 @@ source_context_free (SourceContext *context)
 }
 
 static void
-mail_ui_session_dispose (GObject *object)
-{
-	EMailUISessionPrivate *priv;
-
-	priv = E_MAIL_UI_SESSION_GET_PRIVATE (object);
-
-	if (priv->account_store != NULL) {
-		e_mail_account_store_clear (priv->account_store);
-		g_object_unref (priv->account_store);
-		priv->account_store = NULL;
-	}
-
-	if (priv->label_store != NULL) {
-		g_object_unref (priv->label_store);
-		priv->label_store = NULL;
-	}
-
-	if (priv->account_list != NULL) {
-		g_signal_handler_disconnect (
-			priv->account_list,
-			priv->account_changed_handler_id);
-		g_object_unref (priv->account_list);
-		priv->account_list = NULL;
-	}
-
-	/* Chain up to parent's dispose() method. */
-	G_OBJECT_CLASS (e_mail_ui_session_parent_class)->dispose (object);
-}
-
-static void
-mail_ui_session_account_changed_cb (EAccountList *account_list,
-                                 EAccount *account,
-                                 EMailSession *session)
+mail_ui_session_source_changed_cb (ESourceRegistry *registry,
+                                   ESource *source,
+                                   EMailSession *session)
 {
 	EMFolderTreeModel *folder_tree_model;
 	CamelService *service;
+	const gchar *extension_name;
+	const gchar *uid;
 
-	service = camel_session_get_service (
-		CAMEL_SESSION (session), account->uid);
+	uid = e_source_get_uid (source);
 
-	if (!CAMEL_IS_STORE (service))
+	/* We're only interested in mail account data sources. */
+	extension_name = E_SOURCE_EXTENSION_MAIL_ACCOUNT;
+	if (!e_source_has_extension (source, extension_name))
 		return;
 
-	/* Update the display name of the corresponding CamelStore.
-	 * EMailAccountStore listens for "notify" signals from each
-	 * service so it will detect this and update the model.
-	 *
-	 * XXX If EAccount defined GObject properties we could just
-	 *     bind EAccount:name to CamelService:display-name and
-	 *     be done with it.  Oh well.
-	 */
-
-	camel_service_set_display_name (service, account->name);
+	/* There should be a CamelStore with the same UID. */
+	service = camel_session_get_service (CAMEL_SESSION (session), uid);
+	g_return_if_fail (CAMEL_IS_STORE (service));
 
 	/* Remove the store from the folder tree model and, if the
-	 * account is still enabled, re-add it.  Easier than trying
+	 * source is still enabled, re-add it.  Easier than trying
 	 * to update the model with the store in place.
 	 *
 	 * em_folder_tree_model_add_store() already knows which types
@@ -542,34 +508,76 @@ mail_ui_session_account_changed_cb (EAccountList *account_list,
 	em_folder_tree_model_remove_store (
 		folder_tree_model, CAMEL_STORE (service));
 
-	if (account->enabled)
+	if (e_source_get_enabled (source))
 		em_folder_tree_model_add_store (
 			folder_tree_model, CAMEL_STORE (service));
 }
 
 static gboolean
-mail_ui_session_initialize_stores_idle (gpointer user_data)
+mail_ui_session_add_service_cb (SourceContext *context)
 {
-	EMailUISession *session = user_data;
-	EMailAccountStore *account_store;
-	EAccount *account;
+	EMailAccountStore *store;
+
+	/* The CamelService should be fully initialized by now. */
+	store = e_mail_ui_session_get_account_store (context->session);
+	e_mail_account_store_add_service (store, context->service);
+
+	return FALSE;
+}
+
+static void
+mail_ui_session_get_property (GObject *object,
+                              guint property_id,
+                              GValue *value,
+                              GParamSpec *pspec)
+{
+	switch (property_id) {
+		case PROP_ACCOUNT_STORE:
+			g_value_set_object (
+				value,
+				e_mail_ui_session_get_account_store (
+				E_MAIL_UI_SESSION (object)));
+			return;
+
+		case PROP_LABEL_STORE:
+			g_value_set_object (
+				value,
+				e_mail_ui_session_get_label_store (
+				E_MAIL_UI_SESSION (object)));
+			return;
+	}
+
+	G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+}
+
+static void
+mail_ui_session_dispose (GObject *object)
+{
+	EMailUISessionPrivate *priv;
 
-	g_return_val_if_fail (session != NULL, FALSE);
+	priv = E_MAIL_UI_SESSION_GET_PRIVATE (object);
 
-	account_store = e_mail_ui_session_get_account_store (session);
+	if (priv->registry != NULL) {
+		g_signal_handler_disconnect (
+			priv->registry,
+			priv->source_changed_handler_id);
+		g_object_unref (priv->registry);
+		priv->registry = NULL;
+	}
 
-	/* Initialize which account is default. */
-	account = e_get_default_account ();
-	if (account != NULL) {
-		CamelService *service;
+	if (priv->account_store != NULL) {
+		e_mail_account_store_clear (priv->account_store);
+		g_object_unref (priv->account_store);
+		priv->account_store = NULL;
+	}
 
-		service = camel_session_get_service (
-			CAMEL_SESSION (session), account->uid);
-		e_mail_account_store_set_default_service (
-			account_store, service);
+	if (priv->label_store != NULL) {
+		g_object_unref (priv->label_store);
+		priv->label_store = NULL;
 	}
 
-	return FALSE;
+	/* Chain up to parent's dispose() method. */
+	G_OBJECT_CLASS (e_mail_ui_session_parent_class)->dispose (object);
 }
 
 static void
@@ -577,19 +585,19 @@ mail_ui_session_constructed (GObject *object)
 {
 	EMailUISessionPrivate *priv;
 	EMFolderTreeModel *folder_tree_model;
+	ESourceRegistry *registry;
 	EMailSession *session;
-	EMailUISession *uisession;
-	EAccountList *account_list;
 	gulong handler_id;
 
 	session = E_MAIL_SESSION (object);
-	uisession = E_MAIL_UI_SESSION (object);
-	uisession->priv = priv = E_MAIL_UI_SESSION_GET_PRIVATE (object);
 
+	priv = E_MAIL_UI_SESSION_GET_PRIVATE (object);
 	priv->account_store = e_mail_account_store_new (session);
 
-	account_list = e_get_account_list ();
-	uisession->priv->account_list = g_object_ref (account_list);
+	/* Keep our own reference to the ESourceRegistry so we
+	 * can easily disconnect signal handlers in dispose(). */
+	registry = e_mail_session_get_registry (session);
+	priv->registry = g_object_ref (registry);
 
 	/* XXX Make sure the folder tree model is created before we
 	 *     add built-in CamelStores so it gets signals from the
@@ -601,19 +609,62 @@ mail_ui_session_constructed (GObject *object)
 	 * FIXME EMailSession should just own the default instance.
 	 */
 	folder_tree_model = em_folder_tree_model_get_default ();
+	em_folder_tree_model_set_session (folder_tree_model, session);
 
 	/* Chain up to parent's constructed() method. */
 	G_OBJECT_CLASS (e_mail_ui_session_parent_class)->constructed (object);
 
-	em_folder_tree_model_set_session (folder_tree_model, session);
-
-	g_idle_add (mail_ui_session_initialize_stores_idle, object);
+	/* Listen for registry changes. */
 
 	handler_id = g_signal_connect (
-		account_list, "account-changed",
-		G_CALLBACK (mail_ui_session_account_changed_cb), session);
-	priv->account_changed_handler_id = handler_id;
+		registry, "source-changed",
+		G_CALLBACK (mail_ui_session_source_changed_cb), session);
+	priv->source_changed_handler_id = handler_id;
+}
+
+static CamelService *
+mail_ui_session_add_service (CamelSession *session,
+                             const gchar *uid,
+                             const gchar *protocol,
+                             CamelProviderType type,
+                             GError **error)
+{
+	CamelService *service;
+
+	/* Chain up to parent's constructed() method. */
+	service = CAMEL_SESSION_CLASS (e_mail_ui_session_parent_class)->
+		add_service (session, uid, protocol, type, error);
+
+	/* Inform the EMailAccountStore of the new CamelService
+	 * from an idle callback so the service has a chance to
+	 * fully initialize first. */
+	if (CAMEL_IS_STORE (service)) {
+		SourceContext *context;
 
+		context = g_slice_new0 (SourceContext);
+		context->session = g_object_ref (session);
+		context->service = g_object_ref (service);
+
+		g_idle_add_full (
+			G_PRIORITY_DEFAULT_IDLE,
+			(GSourceFunc) mail_ui_session_add_service_cb,
+			context, (GDestroyNotify) source_context_free);
+	}
+
+	return service;
+}
+
+static void
+mail_ui_session_remove_service (CamelSession *session,
+                                CamelService *service)
+{
+	EMailAccountStore *store;
+	EMailUISession *ui_session;
+
+	/* Passing a NULL parent window skips confirmation prompts. */
+	ui_session = E_MAIL_UI_SESSION (session);
+	store = e_mail_ui_session_get_account_store (ui_session);
+	e_mail_account_store_remove_service (store, NULL, service);
 }
 
 static gint
@@ -659,8 +710,8 @@ mail_ui_session_alert_user (CamelSession *session,
 
 static CamelFilterDriver *
 mail_ui_session_get_filter_driver (CamelSession *session,
-                                const gchar *type,
-                                GError **error)
+                                   const gchar *type,
+                                   GError **error)
 {
 	return (CamelFilterDriver *) mail_call_main (
 		MAIL_CALL_p_ppp, (MailMainFunc) main_get_filter_driver,
@@ -668,80 +719,14 @@ mail_ui_session_get_filter_driver (CamelSession *session,
 }
 
 static void
-mail_ui_session_set_property (GObject *object,
-                           guint property_id,
-                           const GValue *value,
-                           GParamSpec *pspec)
+mail_ui_session_refresh_service (EMailSession *session,
+                                 CamelService *service)
 {
-	G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
-}
+	g_debug ("*** Refreshing %s ***",
+		camel_service_get_display_name (service));
 
-static void
-mail_ui_session_get_property (GObject *object,
-                           guint property_id,
-                           GValue *value,
-                           GParamSpec *pspec)
-{
-	switch (property_id) {
-		case PROP_ACCOUNT_STORE:
-			g_value_set_object (
-				value,
-				e_mail_ui_session_get_account_store (
-				E_MAIL_UI_SESSION (object)));
-			return;
-
-		case PROP_LABEL_STORE:
-			g_value_set_object (
-				value,
-				e_mail_ui_session_get_label_store (
-				E_MAIL_UI_SESSION (object)));
-			return;
-	}
-
-	G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
-}
-
-static gboolean
-mail_ui_session_add_service_cb (SourceContext *context)
-{
-	EMailAccountStore *store;
-
-	store = e_mail_ui_session_get_account_store (context->session);
-	e_mail_account_store_add_service (store, context->service);
-
-	return FALSE;
-}
-
-static CamelService *
-mail_ui_session_add_service (CamelSession *session,
-                             const gchar *uid,
-                             const gchar *protocol,
-                             CamelProviderType type,
-                             GError **error)
-{
-	CamelService *service;
-
-	/* Chain up to parent's constructed() method. */
-	service = CAMEL_SESSION_CLASS (e_mail_ui_session_parent_class)->
-		add_service (session, uid, protocol, type, error);
-
-	/* Inform the EMailAccountStore of the new CamelService
-	 * from an idle callback so the service has a chance to
-	 * fully initialize first. */
-	if (CAMEL_IS_STORE (service)) {
-		SourceContext *context;
-
-		context = g_slice_new0 (SourceContext);
-		context->session = g_object_ref (session);
-		context->service = g_object_ref (service);
-
-		g_idle_add_full (
-			G_PRIORITY_DEFAULT_IDLE,
-			(GSourceFunc) mail_ui_session_add_service_cb,
-			context, (GDestroyNotify) source_context_free);
-	}
-
-	return service;
+	if (camel_session_get_online (CAMEL_SESSION (session)))
+		mail_receive_service (service);
 }
 
 static EMVFolderContext *
@@ -755,23 +740,24 @@ e_mail_ui_session_class_init (EMailUISessionClass *class)
 {
 	GObjectClass *object_class;
 	CamelSessionClass *session_class;
-	EMailSessionClass *emailsession_class;
+	EMailSessionClass *mail_session_class;
 
 	g_type_class_add_private (class, sizeof (EMailUISessionPrivate));
 
 	object_class = G_OBJECT_CLASS (class);
-	object_class->set_property = mail_ui_session_set_property;
 	object_class->get_property = mail_ui_session_get_property;
 	object_class->dispose = mail_ui_session_dispose;
 	object_class->constructed = mail_ui_session_constructed;
 
 	session_class = CAMEL_SESSION_CLASS (class);
+	session_class->add_service = mail_ui_session_add_service;
+	session_class->remove_service = mail_ui_session_remove_service;
 	session_class->alert_user = mail_ui_session_alert_user;
 	session_class->get_filter_driver = mail_ui_session_get_filter_driver;
-	session_class->add_service = mail_ui_session_add_service;
 
-	emailsession_class = E_MAIL_SESSION_CLASS (class);
-	emailsession_class->create_vfolder_context = mail_ui_session_create_vfolder_context;
+	mail_session_class = E_MAIL_SESSION_CLASS (class);
+	mail_session_class->create_vfolder_context = mail_ui_session_create_vfolder_context;
+	mail_session_class->refresh_service = mail_ui_session_refresh_service;
 
 	g_object_class_install_property (
 		object_class,
@@ -803,16 +789,19 @@ e_mail_ui_session_init (EMailUISession *session)
 }
 
 EMailSession *
-e_mail_ui_session_new (void)
+e_mail_ui_session_new (ESourceRegistry *registry)
 {
 	const gchar *user_data_dir;
 	const gchar *user_cache_dir;
 
+	g_return_val_if_fail (E_IS_SOURCE_REGISTRY (registry), NULL);
+
 	user_data_dir = mail_session_get_data_dir ();
 	user_cache_dir = mail_session_get_cache_dir ();
 
 	return g_object_new (
 		E_TYPE_MAIL_UI_SESSION,
+		"registry", registry,
 		"user-data-dir", user_data_dir,
 		"user-cache-dir", user_cache_dir,
 		NULL);
@@ -826,6 +815,14 @@ e_mail_ui_session_get_account_store (EMailUISession *session)
 	return session->priv->account_store;
 }
 
+EMailLabelListStore *
+e_mail_ui_session_get_label_store (EMailUISession *session)
+{
+	g_return_val_if_fail (E_IS_MAIL_UI_SESSION (session), NULL);
+
+	return session->priv->label_store;
+}
+
 void
 e_mail_ui_session_add_activity (EMailUISession *session,
                                 EActivity *activity)
@@ -836,11 +833,3 @@ e_mail_ui_session_add_activity (EMailUISession *session,
 	g_signal_emit (session, signals[ACTIVITY_ADDED], 0, activity);
 }
 
-EMailLabelListStore *
-e_mail_ui_session_get_label_store (EMailUISession *session)
-{
-	g_return_val_if_fail (E_IS_MAIL_UI_SESSION (session), NULL);
-
-	return session->priv->label_store;
-}
-
diff --git a/mail/e-mail-ui-session.h b/mail/e-mail-ui-session.h
index f6ef4b4..ebab600 100644
--- a/mail/e-mail-ui-session.h
+++ b/mail/e-mail-ui-session.h
@@ -75,16 +75,16 @@ struct _EMailUISessionClass {
 
 };
 
-GType		e_mail_ui_session_get_type		(void);
-EMailSession *	e_mail_ui_session_new			(void);
+GType		e_mail_ui_session_get_type	(void);
+EMailSession *	e_mail_ui_session_new		(ESourceRegistry *registry);
 EMailAccountStore *
 		e_mail_ui_session_get_account_store
 						(EMailUISession *session);
-void		e_mail_ui_session_add_activity	(EMailUISession *session,
-						 EActivity *activity);
 EMailLabelListStore *
 		e_mail_ui_session_get_label_store
 						(EMailUISession *session);
+void		e_mail_ui_session_add_activity	(EMailUISession *session,
+						 EActivity *activity);
 
 G_END_DECLS
 
diff --git a/mail/e-mail.h b/mail/e-mail.h
index 3b0d02d..694b8e3 100644
--- a/mail/e-mail.h
+++ b/mail/e-mail.h
@@ -20,6 +20,7 @@
 #define E_MAIL_H
 
 #include <mail/e-mail-attachment-bar.h>
+#include <mail/e-mail-authenticator.h>
 #include <mail/e-mail-backend.h>
 #include <mail/e-mail-browser.h>
 #include <mail/e-mail-display.h>
diff --git a/mail/em-composer-utils.c b/mail/em-composer-utils.c
index 745609f..62d2f1e 100644
--- a/mail/em-composer-utils.c
+++ b/mail/em-composer-utils.c
@@ -31,12 +31,16 @@
 #include <glib/gi18n.h>
 
 #include <libedataserver/e-data-server-util.h>
+#include <libedataserver/e-source-mail-account.h>
+#include <libedataserver/e-source-mail-composition.h>
+#include <libedataserver/e-source-mail-identity.h>
+#include <libedataserver/e-source-mail-submission.h>
+#include <libedataserver/e-source-mdn.h>
 
 #include <libevolution-utils/e-alert-dialog.h>
 #include <libevolution-utils/e-alert-sink.h>
 #include <e-util/e-util.h>
 
-#include <libemail-utils/e-account-utils.h>
 #include <libemail-utils/mail-mt.h>
 
 #include <libemail-engine/e-mail-folder-utils.h>
@@ -364,23 +368,27 @@ finished:
 }
 
 static gboolean
-composer_presend_check_account (EMsgComposer *composer,
-                                EMailSession *session)
+composer_presend_check_identity (EMsgComposer *composer,
+                                 EMailSession *session)
 {
 	EComposerHeaderTable *table;
-	EAccount *account;
-	gboolean check_passed;
+	ESourceRegistry *registry;
+	ESource *source;
+	const gchar *uid;
 
 	table = e_msg_composer_get_header_table (composer);
-	account = e_composer_header_table_get_account (table);
-	check_passed = (account != NULL && account->enabled);
+	registry = e_composer_header_table_get_registry (table);
+	uid = e_composer_header_table_get_identity_uid (table);
+	source = e_source_registry_lookup_by_uid (registry, uid);
 
-	if (!check_passed)
+	if (!em_utils_mail_identity_is_enabled (registry, source)) {
 		e_alert_submit (
 			E_ALERT_SINK (composer),
 			"mail:send-no-account-enabled", NULL);
+		return FALSE;
+	}
 
-	return check_passed;
+	return TRUE;
 }
 
 static gboolean
@@ -810,9 +818,11 @@ em_utils_composer_save_to_drafts_cb (EMsgComposer *composer,
 {
 	AsyncContext *context;
 	EComposerHeaderTable *table;
+	ESourceRegistry *registry;
+	ESource *source;
 	const gchar *drafts_folder_uri = NULL;
 	const gchar *local_drafts_folder_uri;
-	EAccount *account;
+	const gchar *identity_uid;
 
 	context = g_slice_new0 (AsyncContext);
 	context->message = g_object_ref (message);
@@ -820,18 +830,29 @@ em_utils_composer_save_to_drafts_cb (EMsgComposer *composer,
 	context->composer = g_object_ref (composer);
 	context->activity = g_object_ref (activity);
 
-	local_drafts_folder_uri =
-		e_mail_session_get_local_folder_uri (
-		session, E_MAIL_LOCAL_FOLDER_DRAFTS);
-
 	table = e_msg_composer_get_header_table (composer);
-	account = e_composer_header_table_get_account (table);
 
-	if (account != NULL && account->enabled)
-		drafts_folder_uri = account->drafts_folder_uri;
+	registry = e_composer_header_table_get_registry (table);
+	identity_uid = e_composer_header_table_get_identity_uid (table);
+	source = e_source_registry_lookup_by_uid (registry, identity_uid);
+
+	/* Get the selected identity's preferred Drafts folder. */
+	if (source != NULL) {
+		ESourceMailComposition *extension;
+		const gchar *extension_name;
+		const gchar *uri;
 
-	if (g_strcmp0 (drafts_folder_uri, local_drafts_folder_uri) == 0)
-		drafts_folder_uri = NULL;
+		extension_name = E_SOURCE_EXTENSION_MAIL_COMPOSITION;
+		extension = e_source_get_extension (source, extension_name);
+		uri = e_source_mail_composition_get_drafts_folder (extension);
+
+		if (uri != NULL && *uri != '\0')
+			drafts_folder_uri = uri;
+	}
+
+	local_drafts_folder_uri =
+		e_mail_session_get_local_folder_uri (
+		session, E_MAIL_LOCAL_FOLDER_DRAFTS);
 
 	if (drafts_folder_uri == NULL) {
 		composer_save_to_drafts_append_mail (context, NULL);
@@ -950,12 +971,15 @@ create_new_composer (EShell *shell,
                      CamelFolder *folder)
 {
 	EMsgComposer *composer;
+	ESourceRegistry *registry;
 	EComposerHeaderTable *table;
-	EAccount *account = NULL;
+	ESource *source = NULL;
+	const gchar *identity = NULL;
 
 	composer = e_msg_composer_new (shell);
 
 	table = e_msg_composer_get_header_table (composer);
+	registry = e_composer_header_table_get_registry (table);
 
 	if (folder != NULL) {
 		CamelStore *store;
@@ -965,7 +989,7 @@ create_new_composer (EShell *shell,
 
 		store = camel_folder_get_parent_store (folder);
 		uid = camel_service_get_uid (CAMEL_SERVICE (store));
-		account = e_get_account_by_uid (uid);
+		source = e_source_registry_lookup_by_uid (registry, uid);
 
 		folder_uri = e_mail_folder_uri_from_folder (folder);
 
@@ -976,8 +1000,17 @@ create_new_composer (EShell *shell,
 		g_free (folder_uri);
 	}
 
-	e_composer_header_table_set_account (table, account);
+	if (source != NULL) {
+		ESourceMailAccount *extension;
+		const gchar *extension_name;
+
+		extension_name = E_SOURCE_EXTENSION_MAIL_ACCOUNT;
+		extension = e_source_get_extension (source, extension_name);
+		identity = e_source_mail_account_get_identity_uid (extension);
+	}
+
 	e_composer_header_table_set_subject (table, subject);
+	e_composer_header_table_set_identity_uid (table, identity);
 
 	return composer;
 }
@@ -1023,8 +1056,8 @@ em_utils_compose_new_message_with_mailto (EShell *shell,
                                           CamelFolder *folder)
 {
 	EMsgComposer *composer;
+	ESourceRegistry *registry;
 	EComposerHeaderTable *table;
-	CamelService *service = NULL;
 
 	g_return_val_if_fail (E_IS_SHELL (shell), NULL);
 
@@ -1037,25 +1070,37 @@ em_utils_compose_new_message_with_mailto (EShell *shell,
 		composer = e_msg_composer_new (shell);
 
 	table = e_msg_composer_get_header_table (composer);
+	registry = e_composer_header_table_get_registry (table);
+
+	composer_set_no_change (composer);
+
+	gtk_window_present (GTK_WINDOW (composer));
+
+	/* If a CamelFolder was given, we need to backtrack and find
+	 * the corresponding ESource with a Mail Identity extension. */
 
 	if (folder != NULL) {
+		ESource *source;
 		CamelStore *store;
+		ESourceMailAccount *extension;
+		const gchar *extension_name;
+		const gchar *uid;
 
 		store = camel_folder_get_parent_store (folder);
-		service = CAMEL_SERVICE (store);
-	}
+		uid = camel_service_get_uid (CAMEL_SERVICE (store));
+		source = e_source_registry_lookup_by_uid (registry, uid);
+		g_return_val_if_fail (source != NULL, composer);
 
-	if (service != NULL) {
-		const gchar *display_name;
+		extension_name = E_SOURCE_EXTENSION_MAIL_ACCOUNT;
+		if (e_source_has_extension (source, extension_name))
+			goto exit;
 
-		display_name = camel_service_get_display_name (service);
-		e_composer_header_table_set_account_name (table, display_name);
+		extension = e_source_get_extension (source, extension_name);
+		uid = e_source_mail_account_get_identity_uid (extension);
+		e_composer_header_table_set_identity_uid (table, uid);
 	}
 
-	composer_set_no_change (composer);
-
-	gtk_window_present (GTK_WINDOW (composer));
-
+exit:
 	return composer;
 }
 
@@ -1276,6 +1321,7 @@ em_utils_edit_message (EShell *shell,
                        const gchar *message_uid)
 {
 	EMsgComposer *composer;
+	ESourceRegistry *registry;
 	gboolean folder_is_drafts;
 	gboolean folder_is_outbox;
 	gboolean folder_is_templates;
@@ -1284,9 +1330,10 @@ em_utils_edit_message (EShell *shell,
 	g_return_val_if_fail (CAMEL_IS_FOLDER (folder), NULL);
 	g_return_val_if_fail (CAMEL_IS_MIME_MESSAGE (message), NULL);
 
-	folder_is_drafts = em_utils_folder_is_drafts (folder);
-	folder_is_outbox = em_utils_folder_is_outbox (folder);
-	folder_is_templates = em_utils_folder_is_templates (folder);
+	registry = e_shell_get_registry (shell);
+	folder_is_drafts = em_utils_folder_is_drafts (registry, folder);
+	folder_is_outbox = em_utils_folder_is_outbox (registry, folder);
+	folder_is_templates = em_utils_folder_is_templates (registry, folder);
 
 	/* Template specific code follows. */
 	if (folder_is_templates) {
@@ -1313,10 +1360,12 @@ em_utils_edit_message (EShell *shell,
 	}
 
 	composer = e_msg_composer_new_with_message (shell, message, NULL);
-	if (folder && !folder_is_templates) {
+	if (!folder_is_templates) {
 		EComposerHeaderTable *table;
-		EAccount *account;
+		ESourceMailAccount *extension;
+		ESource *source;
 		CamelStore *store;
+		const gchar *extension_name;
 		const gchar *uid;
 		gchar *folder_uri;
 		GList *list;
@@ -1325,7 +1374,11 @@ em_utils_edit_message (EShell *shell,
 
 		store = camel_folder_get_parent_store (folder);
 		uid = camel_service_get_uid (CAMEL_SERVICE (store));
-		account = e_get_account_by_uid (uid);
+		source = e_source_registry_lookup_by_uid (registry, uid);
+
+		extension_name = E_SOURCE_EXTENSION_MAIL_ACCOUNT;
+		extension = e_source_get_extension (source, extension_name);
+		uid = e_source_mail_account_get_identity_uid (extension);
 
 		folder_uri = e_mail_folder_uri_from_folder (folder);
 
@@ -1335,7 +1388,7 @@ em_utils_edit_message (EShell *shell,
 
 		g_free (folder_uri);
 
-		e_composer_header_table_set_account (table, account);
+		e_composer_header_table_set_identity_uid (table, uid);
 	}
 
 	e_msg_composer_remove_header (
@@ -1869,8 +1922,10 @@ static EMsgComposer *
 redirect_get_composer (EShell *shell,
                        CamelMimeMessage *message)
 {
+	ESourceRegistry *registry;
 	CamelMedium *medium;
-	EAccount *account;
+	ESource *source;
+	const gchar *identity_uid = NULL;
 
 	medium = CAMEL_MEDIUM (message);
 
@@ -1886,10 +1941,15 @@ redirect_get_composer (EShell *shell,
 	while (camel_medium_get_header (medium, "Resent-Bcc"))
 		camel_medium_remove_header (medium, "Resent-Bcc");
 
-	account = em_utils_guess_account_with_recipients (message, NULL);
+	registry = e_shell_get_registry (shell);
+
+	source = em_utils_guess_mail_identity_with_recipients (
+		registry, message, NULL);
+	if (source != NULL)
+		identity_uid = e_source_get_uid (source);
 
 	return e_msg_composer_new_redirect (
-		shell, message, account ? account->name : NULL, NULL);
+		shell, message, identity_uid, NULL);
 }
 
 /**
@@ -1956,7 +2016,7 @@ em_utils_camel_address_to_destination (CamelInternetAddress *iaddr)
 static EMsgComposer *
 reply_get_composer (EShell *shell,
                     CamelMimeMessage *message,
-                    EAccount *account,
+                    const gchar *identity_uid,
                     CamelInternetAddress *to,
                     CamelInternetAddress *cc,
                     CamelFolder *folder,
@@ -1997,9 +2057,9 @@ reply_get_composer (EShell *shell,
 	}
 
 	table = e_msg_composer_get_header_table (composer);
-	e_composer_header_table_set_account (table, account);
 	e_composer_header_table_set_subject (table, subject);
 	e_composer_header_table_set_destinations_to (table, tov);
+	e_composer_header_table_set_identity_uid (table, identity_uid);
 
 	/* Add destinations instead of setting, so we don't remove
 	 * automatic CC addresses that have already been added. */
@@ -2278,64 +2338,6 @@ get_reply_recipient (CamelMimeMessage *message,
 
 }
 
-static GHashTable *
-generate_recipient_hash (void)
-{
-	GHashTable *rcpt_hash;
-	EAccount *account, *def;
-	EAccountList *account_list;
-	EIterator *iterator;
-
-	account_list = e_get_account_list ();
-	rcpt_hash = g_hash_table_new (camel_strcase_hash, camel_strcase_equal);
-
-	def = e_get_default_account ();
-
-	iterator = e_list_get_iterator (E_LIST (account_list));
-
-	while (e_iterator_is_valid (iterator)) {
-		account = (EAccount *) e_iterator_get (iterator);
-
-		if (account->id->address) {
-			EAccount *acnt;
-
-			/* Accounts with identical email addresses that are
-			 * enabled take precedence over the accounts that
-			 * aren't. If all accounts with matching email
-			 * addresses are disabled, then the first one in
-			 * the list takes precedence. The default account
-			 * always takes precedence no matter what. */
-			acnt = g_hash_table_lookup (
-				rcpt_hash, account->id->address);
-			if (acnt && acnt != def && !acnt->enabled && account->enabled) {
-				g_hash_table_remove (
-					rcpt_hash, acnt->id->address);
-				acnt = NULL;
-			}
-
-			if (!acnt)
-				g_hash_table_insert (
-					rcpt_hash, (gchar *)
-					account->id->address,
-					(gpointer) account);
-		}
-
-		e_iterator_next (iterator);
-	}
-
-	g_object_unref (iterator);
-
-	/* The default account has to be there if none
-	 * of the enabled accounts are present. */
-	if (g_hash_table_size (rcpt_hash) == 0 && def && def->id->address)
-		g_hash_table_insert (
-			rcpt_hash, (gchar *)
-			def->id->address,
-			(gpointer) def);
-
-	return rcpt_hash;
-}
-
 static void
 concat_unique_addrs (CamelInternetAddress *dest,
                      CamelInternetAddress *src,
@@ -2352,8 +2354,96 @@ concat_unique_addrs (CamelInternetAddress *dest,
 	}
 }
 
+static GHashTable *
+generate_recipient_hash (ESourceRegistry *registry)
+{
+	GHashTable *rcpt_hash;
+	ESource *default_source;
+	GList *list, *link;
+	const gchar *extension_name;
+
+	g_return_val_if_fail (E_IS_SOURCE_REGISTRY (registry), NULL);
+
+	rcpt_hash = g_hash_table_new (
+		(GHashFunc) camel_strcase_hash,
+		(GEqualFunc) camel_strcase_equal);
+
+	default_source = e_source_registry_get_default_mail_account (registry);
+
+	extension_name = E_SOURCE_EXTENSION_MAIL_ACCOUNT;
+	list = e_source_registry_list_sources (registry, extension_name);
+
+	for (link = list; link != NULL; link = g_list_next (link)) {
+		ESource *source = E_SOURCE (link->data);
+		ESource *cached_source;
+		ESource *identity_source;
+		ESourceExtension *extension;
+		const gchar *address;
+		gboolean insert_source;
+		gboolean cached_is_default;
+		gboolean cached_is_enabled;
+		gboolean source_is_default;
+		gboolean source_is_enabled;
+
+		source_is_default = e_source_equal (source, default_source);
+		source_is_enabled = e_source_get_enabled (source);
+
+		extension_name = E_SOURCE_EXTENSION_MAIL_ACCOUNT;
+		extension = e_source_get_extension (source, extension_name);
+
+		identity_source = e_source_mail_account_get_identity (
+			E_SOURCE_MAIL_ACCOUNT (extension));
+
+		if (identity_source == NULL)
+			continue;
+
+		extension_name = E_SOURCE_EXTENSION_MAIL_IDENTITY;
+		extension = e_source_get_extension (
+			identity_source, extension_name);
+
+		address = e_source_mail_identity_get_address (
+			E_SOURCE_MAIL_IDENTITY (extension));
+
+		if (address == NULL)
+			continue;
+
+		cached_source = g_hash_table_lookup (rcpt_hash, address);
+
+		if (cached_source != NULL) {
+			cached_is_default = e_source_equal (
+				cached_source, default_source);
+			cached_is_enabled =
+				e_source_get_enabled (cached_source);
+		} else {
+			cached_is_default = FALSE;
+			cached_is_enabled = FALSE;
+		}
+
+		/* Accounts with identical email addresses that are enabled
+		 * take precedence over disabled accounts.  If all accounts
+		 * with matching email addresses are disabled, the first
+		 * one in the list takes precedence.  The default account
+		 * always takes precedence no matter what. */
+		insert_source =
+			source_is_default ||
+			cached_source == NULL ||
+			(source_is_enabled &&
+			 !cached_is_enabled &&
+			 !cached_is_default);
+
+		if (insert_source)
+			g_hash_table_insert (
+				rcpt_hash, (gchar *) address, source);
+	}
+
+	g_list_free (list);
+
+	return rcpt_hash;
+}
+
 void
-em_utils_get_reply_all (CamelMimeMessage *message,
+em_utils_get_reply_all (ESourceRegistry *registry,
+                        CamelMimeMessage *message,
                         CamelInternetAddress *to,
                         CamelInternetAddress *cc,
                         CamelNNTPAddress *postto)
@@ -2366,6 +2456,7 @@ em_utils_get_reply_all (CamelMimeMessage *message,
 	const gchar *posthdr = NULL;
 	GHashTable *rcpt_hash;
 
+	g_return_if_fail (E_IS_SOURCE_REGISTRY (registry));
 	g_return_if_fail (CAMEL_IS_MIME_MESSAGE (message));
 	g_return_if_fail (CAMEL_IS_INTERNET_ADDRESS (to));
 	g_return_if_fail (CAMEL_IS_INTERNET_ADDRESS (cc));
@@ -2382,7 +2473,7 @@ em_utils_get_reply_all (CamelMimeMessage *message,
 	if (postto != NULL && posthdr != NULL)
 		camel_address_decode (CAMEL_ADDRESS (postto), posthdr);
 
-	rcpt_hash = generate_recipient_hash ();
+	rcpt_hash = generate_recipient_hash (registry);
 
 	reply_to = get_reply_to (message);
 	to_addrs = camel_mime_message_get_recipients (
@@ -2765,10 +2856,12 @@ em_utils_reply_to_message (EShell *shell,
                            EMFormat *source_formatter,
                            CamelInternetAddress *address)
 {
+	ESourceRegistry *registry;
 	CamelInternetAddress *to, *cc;
 	CamelNNTPAddress *postto = NULL;
 	EMsgComposer *composer;
-	EAccount *account;
+	ESource *source;
+	const gchar *identity_uid = NULL;
 	guint32 flags;
 
 	g_return_val_if_fail (E_IS_SHELL (shell), NULL);
@@ -2777,7 +2870,11 @@ em_utils_reply_to_message (EShell *shell,
 	to = camel_internet_address_new ();
 	cc = camel_internet_address_new ();
 
-	account = em_utils_guess_account_with_recipients (message, folder);
+	registry = e_shell_get_registry (shell);
+	source = em_utils_guess_mail_identity_with_recipients (
+		registry, message, folder);
+	if (source != NULL)
+		identity_uid = e_source_get_uid (source);
 	flags = CAMEL_MESSAGE_ANSWERED | CAMEL_MESSAGE_SEEN;
 
 	switch (type) {
@@ -2809,12 +2906,12 @@ em_utils_reply_to_message (EShell *shell,
 		if (folder)
 			postto = camel_nntp_address_new ();
 
-		em_utils_get_reply_all (message, to, cc, postto);
+		em_utils_get_reply_all (registry, message, to, cc, postto);
 		break;
 	}
 
 	composer = reply_get_composer (
-		shell, message, account, to, cc, folder, postto);
+		shell, message, identity_uid, to, cc, folder, postto);
 	e_msg_composer_add_message_attachments (composer, message, TRUE);
 
 	if (postto)
@@ -2926,7 +3023,7 @@ em_configure_new_composer (EMsgComposer *composer,
 
 	g_signal_connect (
 		composer, "presend",
-		G_CALLBACK (composer_presend_check_account), session);
+		G_CALLBACK (composer_presend_check_identity), session);
 
 	g_signal_connect (
 		composer, "presend",
diff --git a/mail/em-composer-utils.h b/mail/em-composer-utils.h
index 5b3d3a4..c4c1bad 100644
--- a/mail/em-composer-utils.h
+++ b/mail/em-composer-utils.h
@@ -65,7 +65,8 @@ gboolean	em_utils_is_munged_list_message	(CamelMimeMessage *message);
 void		em_utils_get_reply_sender	(CamelMimeMessage *message,
 						 CamelInternetAddress *to,
 						 CamelNNTPAddress *postto);
-void		em_utils_get_reply_all		(CamelMimeMessage *message,
+void		em_utils_get_reply_all		(ESourceRegistry *registry,
+						 CamelMimeMessage *message,
 						 CamelInternetAddress *to,
 						 CamelInternetAddress *cc,
 						 CamelNNTPAddress *postto);
diff --git a/mail/em-filter-source-element.c b/mail/em-filter-source-element.c
index 5848f93..bc4dcf2 100644
--- a/mail/em-filter-source-element.c
+++ b/mail/em-filter-source-element.c
@@ -32,23 +32,18 @@
 #include <gtk/gtk.h>
 #include <camel/camel.h>
 
+#include <libedataserver/e-source-mail-account.h>
+#include <libedataserver/e-source-mail-identity.h>
+
+#include <shell/e-shell.h>
 #include <filter/e-filter-part.h>
-#include <libemail-utils/e-account-utils.h>
 
 #define EM_FILTER_SOURCE_ELEMENT_GET_PRIVATE(obj) \
 	(G_TYPE_INSTANCE_GET_PRIVATE \
 	((obj), EM_TYPE_FILTER_SOURCE_ELEMENT, EMFilterSourceElementPrivate))
 
-typedef struct _SourceInfo {
-	gchar *account_name;
-	gchar *name;
-	gchar *address;
-	gchar *uid;
-} SourceInfo;
-
 struct _EMFilterSourceElementPrivate {
 	EMailSession *session;
-	GList *sources;
 	gchar *active_id;
 };
 
@@ -63,16 +58,6 @@ enum {
 };
 
 static void
-source_info_free (SourceInfo *info)
-{
-	g_free (info->account_name);
-	g_free (info->name);
-	g_free (info->address);
-	g_free (info->uid);
-	g_free (info);
-}
-
-static void
 filter_source_element_source_changed (GtkComboBox *combo_box,
                                       EMFilterSourceElement *fs)
 {
@@ -85,52 +70,6 @@ filter_source_element_source_changed (GtkComboBox *combo_box,
 }
 
 static void
-filter_source_element_add_source (EMFilterSourceElement *fs,
-                                  const gchar *account_name,
-                                  const gchar *name,
-                                  const gchar *addr,
-                                  const gchar *uid)
-{
-	SourceInfo *info;
-
-	g_return_if_fail (EM_IS_FILTER_SOURCE_ELEMENT (fs));
-
-	info = g_new0 (SourceInfo, 1);
-	info->account_name = g_strdup (account_name);
-	info->name = g_strdup (name);
-	info->address = g_strdup (addr);
-	info->uid = g_strdup (uid);
-
-	fs->priv->sources = g_list_append (fs->priv->sources, info);
-}
-
-static void
-filter_source_element_get_sources (EMFilterSourceElement *fs)
-{
-	EAccountList *accounts;
-	const EAccount *account;
-	EIterator *it;
-
-	/* should this get the global object from mail? */
-	accounts = e_get_account_list ();
-
-	for (it = e_list_get_iterator ((EList *) accounts);
-	     e_iterator_is_valid (it);
-	     e_iterator_next (it)) {
-		account = (const EAccount *) e_iterator_get (it);
-
-		if (account->source == NULL)
-			continue;
-
-		filter_source_element_add_source (
-			fs, account->name, account->id->name,
-			account->id->address, account->uid);
-	}
-
-	g_object_unref (it);
-}
-
-static void
 filter_source_element_set_session (EMFilterSourceElement *element,
                                    EMailSession *session)
 {
@@ -198,8 +137,6 @@ filter_source_element_finalize (GObject *object)
 
 	priv = EM_FILTER_SOURCE_ELEMENT_GET_PRIVATE (object);
 
-	g_list_foreach (priv->sources, (GFunc) source_info_free, NULL);
-	g_list_free (priv->sources);
 	g_free (priv->active_id);
 
 	/* Chain up to parent's finalize() method. */
@@ -305,7 +242,6 @@ filter_source_element_clone (EFilterElement *fe)
 	EMFilterSourceElement *fs = (EMFilterSourceElement *) fe;
 	EMFilterSourceElement *cpy;
 	EMailSession *session;
-	GList *i;
 
 	session = em_filter_source_element_get_session (fs);
 	cpy = (EMFilterSourceElement *) em_filter_source_element_new (session);
@@ -313,13 +249,6 @@ filter_source_element_clone (EFilterElement *fe)
 
 	cpy->priv->active_id = g_strdup (fs->priv->active_id);
 
-	for (i = fs->priv->sources; i != NULL; i = g_list_next (i)) {
-		SourceInfo *info = (SourceInfo *) i->data;
-		filter_source_element_add_source (
-			cpy, info->account_name, info->name,
-			info->address, info->uid);
-	}
-
 	return (EFilterElement *) cpy;
 }
 
@@ -327,29 +256,42 @@ static GtkWidget *
 filter_source_element_get_widget (EFilterElement *fe)
 {
 	EMFilterSourceElement *fs = (EMFilterSourceElement *) fe;
+	EMailSession *session;
+	ESourceRegistry *registry;
+	GList *list, *link;
 	GtkWidget *widget;
 	GtkComboBox *combo_box;
-	GList *i;
-
-	if (fs->priv->sources == NULL)
-		filter_source_element_get_sources (fs);
+	const gchar *extension_name;
 
 	widget = gtk_combo_box_text_new ();
 	combo_box = GTK_COMBO_BOX (widget);
 
-	for (i = fs->priv->sources; i != NULL; i = g_list_next (i)) {
-		SourceInfo *info = (SourceInfo *) i->data;
+	session = em_filter_source_element_get_session (fs);
+	registry = e_mail_session_get_registry (session);
+
+	extension_name = E_SOURCE_EXTENSION_MAIL_ACCOUNT;
+	list = e_source_registry_list_sources (registry, extension_name);
+
+	for (link = list; link != NULL; link = g_list_next (link)) {
+		ESource *source = E_SOURCE (link->data);
+		ESourceMailIdentity *extension;
 		const gchar *display_name;
 		const gchar *address;
 		const gchar *name;
 		const gchar *uid;
 		gchar *label;
 
-		uid = info->uid;
-		display_name = info->account_name;
+		uid = e_source_get_uid (source);
+		display_name = e_source_get_display_name (source);
 
-		name = info->name;
-		address = info->address;
+		extension_name = E_SOURCE_EXTENSION_MAIL_IDENTITY;
+		extension = e_source_get_extension (source, extension_name);
+
+		name = e_source_mail_identity_get_name (extension);
+		address = e_source_mail_identity_get_address (extension);
+
+		if (name == NULL || address == NULL)
+			continue;
 
 		if (g_strcmp0 (display_name, address) == 0)
 			label = g_strdup_printf (
@@ -365,6 +307,8 @@ filter_source_element_get_widget (EFilterElement *fe)
 		g_free (label);
 	}
 
+	g_list_free (link);
+
 	if (fs->priv->active_id != NULL) {
 		gtk_combo_box_set_active_id (combo_box, fs->priv->active_id);
 	} else {
diff --git a/mail/em-folder-tree-model.c b/mail/em-folder-tree-model.c
index 623fd55..9ade232 100644
--- a/mail/em-folder-tree-model.c
+++ b/mail/em-folder-tree-model.c
@@ -36,10 +36,14 @@
 
 #include <glib/gi18n.h>
 
+#include <libedataserver/e-source-mail-account.h>
+#include <libedataserver/e-source-mail-composition.h>
+#include <libedataserver/e-source-mail-identity.h>
+#include <libedataserver/e-source-mail-submission.h>
+
 #include <e-util/e-util.h>
 #include <shell/e-shell.h>
 
-#include <libemail-utils/e-account-utils.h>
 #include <libemail-utils/mail-mt.h>
 
 #include <libemail-engine/e-mail-folder-utils.h>
@@ -627,8 +631,9 @@ em_folder_tree_model_set_folder_info (EMFolderTreeModel *model,
 	GtkTreeRowReference *uri_row, *path_row;
 	GtkTreeStore *tree_store;
 	MailFolderCache *folder_cache;
+	ESourceRegistry *registry;
 	EMailSession *session;
-	EAccount *account;
+	ESource *source;
 	guint unread;
 	GtkTreePath *path;
 	GtkTreeIter sub;
@@ -654,10 +659,11 @@ em_folder_tree_model_set_folder_info (EMFolderTreeModel *model,
 
 	session = em_folder_tree_model_get_session (model);
 	folder_cache = e_mail_session_get_folder_cache (session);
+	registry = e_mail_session_get_registry (session);
 
 	uid = camel_service_get_uid (CAMEL_SERVICE (si->store));
+	source = e_source_registry_lookup_by_uid (registry, uid);
 	store_is_local = (g_strcmp0 (uid, E_MAIL_SESSION_LOCAL_UID) == 0);
-	account = e_get_account_by_uid (uid);
 
 	if (!fully_loaded)
 		load = (fi->child == NULL) && !(fi->flags &
@@ -684,8 +690,8 @@ em_folder_tree_model_set_folder_info (EMFolderTreeModel *model,
 	unread = fi->unread;
 	if (mail_folder_cache_get_folder_from_uri (
 		folder_cache, uri, &folder) && folder) {
-		folder_is_drafts = em_utils_folder_is_drafts (folder);
-		folder_is_outbox = em_utils_folder_is_outbox (folder);
+		folder_is_drafts = em_utils_folder_is_drafts (registry, folder);
+		folder_is_outbox = em_utils_folder_is_outbox (registry, folder);
 
 		if (folder_is_drafts || folder_is_outbox) {
 			gint total;
@@ -728,17 +734,43 @@ em_folder_tree_model_set_folder_info (EMFolderTreeModel *model,
 		}
 	}
 
-	if (account != NULL && (flags & CAMEL_FOLDER_TYPE_MASK) == 0) {
-		if (!folder_is_drafts && account->drafts_folder_uri != NULL) {
+	if (source != NULL && (flags & CAMEL_FOLDER_TYPE_MASK) == 0) {
+		ESource *identity;
+		ESourceExtension *extension;
+		const gchar *extension_name;
+		const gchar *drafts_folder_uri;
+		const gchar *sent_folder_uri;
+
+		extension_name = E_SOURCE_EXTENSION_MAIL_ACCOUNT;
+		extension = e_source_get_extension (source, extension_name);
+
+		identity = e_source_mail_account_get_identity (
+			E_SOURCE_MAIL_ACCOUNT (extension));
+
+		extension_name = E_SOURCE_EXTENSION_MAIL_COMPOSITION;
+		extension = e_source_get_extension (identity, extension_name);
+
+		drafts_folder_uri =
+			e_source_mail_composition_get_drafts_folder (
+			E_SOURCE_MAIL_COMPOSITION (extension));
+
+		extension_name = E_SOURCE_EXTENSION_MAIL_SUBMISSION;
+		extension = e_source_get_extension (identity, extension_name);
+
+		sent_folder_uri =
+			e_source_mail_submission_get_sent_folder (
+			E_SOURCE_MAIL_SUBMISSION (extension));
+
+		if (!folder_is_drafts && drafts_folder_uri != NULL) {
 			folder_is_drafts = e_mail_folder_uri_equal (
-				CAMEL_SESSION (session), uri,
-				account->drafts_folder_uri);
+				CAMEL_SESSION (session),
+				uri, drafts_folder_uri);
 		}
 
-		if (account->sent_folder_uri != NULL) {
+		if (sent_folder_uri != NULL) {
 			if (e_mail_folder_uri_equal (
-				CAMEL_SESSION (session), uri,
-				account->sent_folder_uri)) {
+				CAMEL_SESSION (session),
+				uri, sent_folder_uri)) {
 				add_flags = CAMEL_FOLDER_TYPE_SENT;
 			}
 		}
diff --git a/mail/em-format-html.c b/mail/em-format-html.c
index 3c130e6..bc9ddf0 100644
--- a/mail/em-format-html.c
+++ b/mail/em-format-html.c
@@ -1594,6 +1594,8 @@ static void
 emfh_gethttp (struct _EMFormatHTMLJob *job,
               GCancellable *cancellable)
 {
+	CamelSession *session;
+	ESourceRegistry *registry;
 	CamelStream *cistream = NULL, *costream = NULL, *instream = NULL;
 	CamelURL *url;
 	CamelHttpStream *tmp_stream;
@@ -1605,20 +1607,27 @@ emfh_gethttp (struct _EMFormatHTMLJob *job,
 	    || (url = camel_url_new (job->u.uri, NULL)) == NULL)
 		goto badurl;
 
+	session = EM_FORMAT (job->format)->session;
+	registry = e_mail_session_get_registry (E_MAIL_SESSION (session));
+
 	d(printf(" running load uri task: %s\n", job->u.uri));
 
 	if (emfh_http_cache)
 		instream = cistream = camel_data_cache_get (emfh_http_cache, EMFH_HTTP_CACHE_PATH, job->u.uri, NULL);
 
 	if (instream == NULL) {
+		CamelMimeMessage *message;
+		CamelInternetAddress *address;
 		EMailImageLoadingPolicy policy;
 
+		message = job->format->parent.message;
+		address = camel_mime_message_get_from (message);
 		policy = em_format_html_get_image_loading_policy (job->format);
 
 		if (!(job->format->priv->load_images_now
 		      || policy == E_MAIL_IMAGE_LOADING_POLICY_ALWAYS
 		      || (policy == E_MAIL_IMAGE_LOADING_POLICY_SOMETIMES
-			  && em_utils_in_addressbook ((CamelInternetAddress *) camel_mime_message_get_from (job->format->parent.message), FALSE)))) {
+			  && em_utils_in_addressbook (registry, address, FALSE)))) {
 			/* TODO: Ideally we would put the http requests into
 			 * another queue and only send them out if the user
 			 * selects 'load images', when they do.  The problem
@@ -1629,7 +1638,7 @@ emfh_gethttp (struct _EMFormatHTMLJob *job,
 			goto done;
 		}
 
-		instream = camel_http_stream_new (CAMEL_HTTP_METHOD_GET, ((EMFormat *) job->format)->session, url);
+		instream = camel_http_stream_new (CAMEL_HTTP_METHOD_GET, session, url);
 		camel_http_stream_set_user_agent((CamelHttpStream *) instream, "CamelHttpStream/1.0 Evolution/" VERSION);
 		emfh_configure_stream_for_proxy ((CamelHttpStream *) instream, job->u.uri);
 
@@ -2954,6 +2963,8 @@ efh_format_headers (EMFormatHTML *efh,
                     CamelMedium *part,
                     GCancellable *cancellable)
 {
+	CamelSession *session;
+	ESourceRegistry *registry;
 	EMFormat *emf = (EMFormat *) efh;
 	const gchar *charset;
 	CamelContentType *ct;
@@ -2972,6 +2983,9 @@ efh_format_headers (EMFormatHTML *efh,
 	if (!part)
 		return;
 
+	session = EM_FORMAT (efh)->session;
+	registry = e_mail_session_get_registry (E_MAIL_SESSION (session));
+
 	ct = camel_mime_part_get_content_type ((CamelMimePart *) part);
 	charset = camel_content_type_param (ct, "charset");
 	charset = camel_iconv_charset_name (charset);
@@ -3249,7 +3263,8 @@ efh_format_headers (EMFormatHTML *efh,
 			cia = camel_internet_address_new ();
 			camel_address_decode ((CamelAddress *) cia, (const gchar *) photo_name);
 			only_local_photo = em_format_html_get_only_local_photos (efh);
-			photopart = em_utils_contact_photo (cia, only_local_photo);
+			photopart = em_utils_contact_photo (
+				registry, cia, only_local_photo);
 
 			if (photopart) {
 				contact_has_photo = TRUE;
diff --git a/mail/em-subscription-editor.c b/mail/em-subscription-editor.c
index f695a88..438d8ef 100644
--- a/mail/em-subscription-editor.c
+++ b/mail/em-subscription-editor.c
@@ -25,7 +25,6 @@
 #include <string.h>
 #include <glib/gi18n-lib.h>
 
-#include <libemail-utils/e-account-utils.h>
 #include <libemail-utils/mail-mt.h>
 #include <libemail-engine/mail-tools.h>
 #include <libemail-engine/mail-ops.h>
@@ -1555,16 +1554,19 @@ subscription_editor_constructed (GObject *object)
 	/* Pick an initial store based on the default mail account, if
 	 * one wasn't already given in em_subscription_editor_new(). */
 	if (editor->priv->initial_store == NULL) {
-		EAccount *account;
+		ESource *source;
+		ESourceRegistry *registry;
 		CamelService *service;
 		EMailSession *session;
 
-		account = e_get_default_account ();
-
 		session = em_subscription_editor_get_session (editor);
+		registry = e_mail_session_get_registry (session);
+
+		source = e_source_registry_get_default_mail_account (registry);
 
 		service = camel_session_get_service (
-			CAMEL_SESSION (session), account->uid);
+			CAMEL_SESSION (session),
+			e_source_get_uid (source));
 
 		if (CAMEL_IS_SUBSCRIBABLE (service))
 			editor->priv->initial_store = g_object_ref (service);
diff --git a/mail/em-utils.c b/mail/em-utils.c
index 4d74b80..980d919 100644
--- a/mail/em-utils.c
+++ b/mail/em-utils.c
@@ -52,6 +52,15 @@
 #include <libedataserver/e-data-server-util.h>
 #include <libedataserver/e-flag.h>
 #include <libedataserver/e-proxy.h>
+#include <libedataserver/e-source-address-book.h>
+#include <libedataserver/e-source-autocomplete.h>
+#include <libedataserver/e-source-mail-account.h>
+#include <libedataserver/e-source-mail-composition.h>
+#include <libedataserver/e-source-mail-identity.h>
+#include <libedataserver/e-source-mail-submission.h>
+#include <libedataserver/e-data-server-util.h>
+#include <libedataserver/e-flag.h>
+#include <libedataserver/e-proxy.h>
 
 #include <e-util/e-util.h>
 #include <e-util/e-util-private.h>
@@ -62,7 +71,6 @@
 #include <shell/e-shell.h>
 #include <widgets/misc/e-attachment.h>
 
-#include <libemail-utils/e-account-utils.h>
 #include <libemail-utils/mail-mt.h>
 
 #include <libemail-engine/e-mail-folder-utils.h>
@@ -1217,10 +1225,13 @@ void
 em_utils_empty_trash (GtkWidget *parent,
                       EMailSession *session)
 {
+	ESourceRegistry *registry;
 	GList *list, *link;
 
 	g_return_if_fail (E_IS_MAIL_SESSION (session));
 
+	registry = e_mail_session_get_registry (session);
+
 	if (!em_utils_prompt_user ((GtkWindow *) parent,
 		"prompt-on-empty-trash",
 		"mail:ask-empty-trash", NULL))
@@ -1229,9 +1240,9 @@ em_utils_empty_trash (GtkWidget *parent,
 	list = camel_session_list_services (CAMEL_SESSION (session));
 
 	for (link = list; link != NULL; link = g_list_next (link)) {
-		EAccount *account;
 		CamelProvider *provider;
 		CamelService *service;
+		ESource *source;
 		const gchar *uid;
 
 		service = CAMEL_SERVICE (link->data);
@@ -1244,14 +1255,10 @@ em_utils_empty_trash (GtkWidget *parent,
 		if ((provider->flags & CAMEL_PROVIDER_IS_STORAGE) == 0)
 			continue;
 
-		account = e_get_account_by_uid (uid);
+		source = e_source_registry_lookup_by_uid (registry, uid);
 
-		/* The local store has no corresponding
-		 * EAccount, so skip the enabled check. */
-		if (account != NULL) {
-			if (!account->enabled)
-				continue;
-		}
+		if (source != NULL && !e_source_get_enabled (source))
+			continue;
 
 		mail_empty_trash (CAMEL_STORE (service));
 	}
@@ -1261,29 +1268,6 @@ em_utils_empty_trash (GtkWidget *parent,
 
 /* ********************************************************************** */
 
-void
-em_utils_clear_get_password_canceled_accounts_flag (void)
-{
-	EAccountList *account_list;
-	EIterator *iterator;
-
-	account_list = e_get_account_list ();
-
-	for (iterator = e_list_get_iterator (E_LIST (account_list));
-	     e_iterator_is_valid (iterator);
-	     e_iterator_next (iterator)) {
-		EAccount *account = (EAccount *) e_iterator_get (iterator);
-
-		if (account && account->source)
-			account->source->get_password_canceled = FALSE;
-
-		if (account && account->transport)
-			account->transport->get_password_canceled = FALSE;
-	}
-
-	g_object_unref (iterator);
-}
-
 gchar *
 em_utils_url_unescape_amp (const gchar *url)
 {
diff --git a/mail/em-utils.h b/mail/em-utils.h
index 09ae4a5..4fe0277 100644
--- a/mail/em-utils.h
+++ b/mail/em-utils.h
@@ -27,7 +27,6 @@
 #include <sys/types.h>
 #include <camel/camel.h>
 #include <libedataserver/e-proxy.h>
-#include <libedataserver/e-account.h>
 
 #include <libemail-engine/e-mail-session.h>
 #include <libemail-engine/e-mail-utils.h>
@@ -73,14 +72,9 @@ gchar *em_utils_message_to_html (CamelMimeMessage *msg, const gchar *credits, gu
 void		em_utils_empty_trash		(GtkWidget *parent,
 						 EMailSession *session);
 
-/* clears flag 'get_password_canceled' at every known accounts, so if needed, get_password will show dialog */
-void em_utils_clear_get_password_canceled_accounts_flag (void);
-
 /* Unescapes &amp; back to a real & in URIs */
 gchar *em_utils_url_unescape_amp (const gchar *url);
 
-void emu_free_mail_account_sort_order_cache (void);
-
 void emu_restore_folder_tree_state (EMFolderTree *folder_tree);
 
 gboolean em_utils_is_re_in_subject (struct _EShell *shell,
diff --git a/mail/mail-config.ui b/mail/mail-config.ui
index 0d906ed..91ed611 100644
--- a/mail/mail-config.ui
+++ b/mail/mail-config.ui
@@ -845,56 +845,6 @@ for display purposes only. </property>
             <property name="position">0</property>
           </packing>
         </child>
-        <child>
-          <object class="GtkVBox" id="signature-preview-section">
-            <property name="visible">True</property>
-            <property name="can_focus">False</property>
-            <property name="spacing">6</property>
-            <child>
-              <object class="GtkLabel" id="signature-preview-header">
-                <property name="visible">True</property>
-                <property name="can_focus">False</property>
-                <property name="xalign">0</property>
-                <property name="label" translatable="yes">Preview</property>
-                <attributes>
-                  <attribute name="weight" value="bold"/>
-                </attributes>
-              </object>
-              <packing>
-                <property name="expand">False</property>
-                <property name="fill">False</property>
-                <property name="position">0</property>
-              </packing>
-            </child>
-            <child>
-              <object class="GtkAlignment" id="signature-preview-alignment">
-                <property name="visible">True</property>
-                <property name="can_focus">False</property>
-                <property name="left_padding">12</property>
-                <child>
-                  <object class="GtkScrolledWindow" id="signature-preview-scrolled-window">
-                    <property name="visible">True</property>
-                    <property name="can_focus">True</property>
-                    <property name="shadow_type">in</property>
-                    <child>
-                      <placeholder/>
-                    </child>
-                  </object>
-                </child>
-              </object>
-              <packing>
-                <property name="expand">True</property>
-                <property name="fill">True</property>
-                <property name="position">1</property>
-              </packing>
-            </child>
-          </object>
-          <packing>
-            <property name="expand">True</property>
-            <property name="fill">True</property>
-            <property name="position">1</property>
-          </packing>
-        </child>
       </object>
       <packing>
         <property name="position">1</property>
diff --git a/mail/mail-send-recv.c b/mail/mail-send-recv.c
index 9cfbb86..6b93cf2 100644
--- a/mail/mail-send-recv.c
+++ b/mail/mail-send-recv.c
@@ -29,12 +29,12 @@
 
 #include <glib/gi18n.h>
 
-#include <libedataserver/e-account-list.h>
+#include <libedataserver/e-source-mail-account.h>
+#include <libedataserver/e-source-mail-submission.h>
 
 #include <shell/e-shell.h>
 #include <e-util/e-util.h>
 
-#include <libemail-utils/e-account-utils.h>
 #include <libemail-utils/mail-mt.h>
 
 /* This is our hack, not part of libcamel. */
@@ -489,7 +489,7 @@ static struct _send_data *
 build_dialog (GtkWindow *parent,
               EMailSession *session,
               CamelFolder *outbox,
-              EAccount *outgoing_account,
+              CamelService *transport,
               gboolean allow_send)
 {
 	GtkDialog *gd;
@@ -506,7 +506,6 @@ build_dialog (GtkWindow *parent,
 	GtkWidget *progress_bar;
 	GtkWidget *cancel_button;
 	EMailAccountStore *account_store;
-	CamelService *transport = NULL;
 	struct _send_info *info;
 	gchar *pretty_url;
 	EMEventTargetSendReceive *target;
@@ -514,17 +513,6 @@ build_dialog (GtkWindow *parent,
 
 	account_store = e_mail_ui_session_get_account_store (E_MAIL_UI_SESSION (session));
 
-	/* Convert the outgoing account to a CamelTransport. */
-	if (outgoing_account != NULL) {
-		gchar *transport_uid;
-
-		transport_uid = g_strdup_printf (
-			"%s-transport", outgoing_account->uid);
-		transport = camel_session_get_service (
-			CAMEL_SESSION (session), transport_uid);
-		g_free (transport_uid);
-	}
-
 	send_recv_dialog = gtk_dialog_new ();
 
 	gd = GTK_DIALOG (send_recv_dialog);
@@ -1132,14 +1120,59 @@ receive_update_got_store (CamelStore *store,
 	}
 }
 
+static CamelService *
+get_default_transport (EMailSession *session)
+{
+	ESource *source;
+	ESourceRegistry *registry;
+	const gchar *extension_name;
+
+	registry = e_mail_session_get_registry (session);
+	source = e_source_registry_get_default_mail_account (registry);
+
+	if (source == NULL)
+		return NULL;
+
+	extension_name = E_SOURCE_EXTENSION_MAIL_ACCOUNT;
+	if (e_source_has_extension (source, extension_name)) {
+		ESourceMailAccount *extension;
+		const gchar *uid;
+
+		extension = e_source_get_extension (source, extension_name);
+		uid = e_source_mail_account_get_identity_uid (extension);
+		source = e_source_registry_lookup_by_uid (registry, uid);
+	} else
+		source = NULL;
+
+	if (source == NULL)
+		return NULL;
+
+	extension_name = E_SOURCE_EXTENSION_MAIL_SUBMISSION;
+	if (e_source_has_extension (source, extension_name)) {
+		ESourceMailSubmission *extension;
+		const gchar *uid;
+
+		extension = e_source_get_extension (source, extension_name);
+		uid = e_source_mail_submission_get_transport_uid (extension);
+		source = e_source_registry_lookup_by_uid (registry, uid);
+	} else
+		source = NULL;
+
+	if (source == NULL)
+		return NULL;
+
+	return camel_session_get_service (
+		CAMEL_SESSION (session), e_source_get_uid (source));
+}
+
 static GtkWidget *
 send_receive (GtkWindow *parent,
               EMailSession *session,
               gboolean allow_send)
 {
 	CamelFolder *local_outbox;
+	CamelService *transport;
 	struct _send_data *data;
-	EAccount *account;
 	GList *scan;
 
 	if (send_recv_dialog != NULL) {
@@ -1152,16 +1185,14 @@ send_receive (GtkWindow *parent,
 	if (!camel_session_get_online (CAMEL_SESSION (session)))
 		return send_recv_dialog;
 
-	account = e_get_default_account ();
-	if (!account || !account->transport->url)
-		return send_recv_dialog;
+	transport = get_default_transport (session);
 
 	local_outbox =
 		e_mail_session_get_local_folder (
 		session, E_MAIL_LOCAL_FOLDER_OUTBOX);
 
 	data = build_dialog (
-		parent, session, local_outbox, account, allow_send);
+		parent, session, local_outbox, transport, allow_send);
 
 	for (scan = data->infos; scan != NULL; scan = scan->next) {
 		struct _send_info *info = scan->data;
@@ -1173,7 +1204,6 @@ send_receive (GtkWindow *parent,
 		case SEND_RECEIVE:
 			mail_fetch_mail (
 				CAMEL_STORE (info->service),
-				info->keep_on_server,
 				E_FILTER_SOURCE_INCOMING,
 				info->cancellable,
 				receive_get_folder, info,
@@ -1217,201 +1247,6 @@ mail_receive (GtkWindow *parent,
 	return send_receive (parent, session, FALSE);
 }
 
-struct _auto_data {
-	EAccount *account;
-	EMailSession *session;
-	gint period;		/* in seconds */
-	gint timeout_id;
-};
-
-static GHashTable *auto_active;
-
-static gboolean
-auto_timeout (gpointer data)
-{
-	CamelService *service;
-	CamelSession *session;
-	struct _auto_data *info = data;
-
-	session = CAMEL_SESSION (info->session);
-
-	service = camel_session_get_service (
-		session, info->account->uid);
-	g_return_val_if_fail (CAMEL_IS_SERVICE (service), TRUE);
-
-	if (camel_session_get_online (session))
-		mail_receive_service (service);
-
-	return TRUE;
-}
-
-static void
-auto_account_removed (EAccountList *eal,
-                      EAccount *ea,
-                      gpointer dummy)
-{
-	struct _auto_data *info = g_object_get_data((GObject *)ea, "mail-autoreceive");
-
-	g_return_if_fail (info != NULL);
-
-	if (info->timeout_id) {
-		g_source_remove (info->timeout_id);
-		info->timeout_id = 0;
-	}
-}
-
-static void
-auto_account_finalized (struct _auto_data *info)
-{
-	if (info->session != NULL)
-		g_object_unref (info->session);
-	if (info->timeout_id)
-		g_source_remove (info->timeout_id);
-	g_free (info);
-}
-
-static void
-auto_account_commit (struct _auto_data *info)
-{
-	gint period, check;
-
-	check = info->account->enabled
-		&& e_account_get_bool (info->account, E_ACCOUNT_SOURCE_AUTO_CHECK)
-		&& e_account_get_string (info->account, E_ACCOUNT_SOURCE_URL);
-	period = e_account_get_int (info->account, E_ACCOUNT_SOURCE_AUTO_CHECK_TIME) * 60;
-	period = MAX (60, period);
-
-	if (info->timeout_id
-	    && (!check
-		|| period != info->period)) {
-		g_source_remove (info->timeout_id);
-		info->timeout_id = 0;
-	}
-	info->period = period;
-	if (check && info->timeout_id == 0)
-		info->timeout_id = g_timeout_add_seconds (info->period, auto_timeout, info);
-}
-
-static void
-auto_account_added (EAccountList *eal,
-                    EAccount *ea,
-                    EMailSession *session)
-{
-	struct _auto_data *info;
-
-	info = g_malloc0 (sizeof (*info));
-	info->account = ea;
-	info->session = g_object_ref (session);
-	g_object_set_data_full (
-		G_OBJECT (ea), "mail-autoreceive", info,
-		(GDestroyNotify) auto_account_finalized);
-	auto_account_commit (info);
-}
-
-static void
-auto_account_changed (EAccountList *eal,
-                      EAccount *ea,
-                      gpointer dummy)
-{
-	struct _auto_data *info;
-
-	info = g_object_get_data (G_OBJECT (ea), "mail-autoreceive");
-
-	if (info != NULL)
-		auto_account_commit (info);
-}
-
-static void
-auto_online (EShell *shell)
-{
-	EIterator *iter;
-	EAccountList *accounts;
-	EShellSettings *shell_settings;
-	struct _auto_data *info;
-	gboolean can_update_all;
-
-	if (!e_shell_get_online (shell))
-		return;
-
-	shell_settings = e_shell_get_shell_settings (shell);
-
-	can_update_all =
-		e_shell_settings_get_boolean (
-			shell_settings, "mail-check-on-start") &&
-		e_shell_settings_get_boolean (
-			shell_settings, "mail-check-all-on-start");
-
-	accounts = e_get_account_list ();
-	for (iter = e_list_get_iterator ((EList *) accounts);
-	     e_iterator_is_valid (iter);
-	     e_iterator_next (iter)) {
-		EAccount *account = (EAccount *) e_iterator_get (iter);
-
-		if (!account || !account->enabled)
-			continue;
-
-		info = g_object_get_data (
-			G_OBJECT (account), "mail-autoreceive");
-		if (info && (info->timeout_id || can_update_all))
-			auto_timeout (info);
-	}
-
-	if (iter)
-		g_object_unref (iter);
-}
-
-/* call to setup initial, and after changes are made to the config */
-/* FIXME: Need a cleanup funciton for when object is deactivated */
-void
-mail_autoreceive_init (EMailSession *session)
-{
-	EShell *shell;
-	EShellSettings *shell_settings;
-	EAccountList *accounts;
-	EIterator *iter;
-
-	g_return_if_fail (E_IS_MAIL_SESSION (session));
-
-	if (auto_active)
-		return;
-
-	accounts = e_get_account_list ();
-	auto_active = g_hash_table_new (g_str_hash, g_str_equal);
-
-	g_signal_connect (
-		accounts, "account-added",
-		G_CALLBACK (auto_account_added), session);
-	g_signal_connect (
-		accounts, "account-removed",
-		G_CALLBACK (auto_account_removed), NULL);
-	g_signal_connect (
-		accounts, "account-changed",
-		G_CALLBACK (auto_account_changed), NULL);
-
-	for (iter = e_list_get_iterator ((EList *) accounts);
-	     e_iterator_is_valid (iter);
-	     e_iterator_next (iter))
-		auto_account_added (
-			accounts, (EAccount *)
-			e_iterator_get (iter), session);
-
-	shell = e_shell_get_default ();
-	shell_settings = e_shell_get_shell_settings (shell);
-
-	if (e_shell_settings_get_boolean (
-		shell_settings, "mail-check-on-start")) {
-		auto_online (shell);
-
-		/* also flush outbox on start */
-		if (e_shell_get_online (shell))
-			mail_send (session);
-	}
-
-	g_signal_connect (
-		shell, "notify::online",
-		G_CALLBACK (auto_online), NULL);
-}
-
 /* We setup the download info's in a hashtable, if we later
  * need to build the gui, we insert them in to add them. */
 void
@@ -1465,7 +1300,6 @@ mail_receive_service (CamelService *service)
 	case SEND_RECEIVE:
 		mail_fetch_mail (
 			CAMEL_STORE (service),
-			info->keep_on_server,
 			E_FILTER_SOURCE_INCOMING,
 			info->cancellable,
 			receive_get_folder, info,
@@ -1501,17 +1335,14 @@ mail_send (EMailSession *session)
 {
 	CamelFolder *local_outbox;
 	CamelService *service;
-	EAccount *account;
 	struct _send_info *info;
 	struct _send_data *data;
 	send_info_t type = SEND_INVALID;
-	gchar *transport_uid;
 
 	g_return_if_fail (E_IS_MAIL_SESSION (session));
 
-	account = e_get_default_transport ();
-	if (account == NULL || account->transport->url == NULL)
-		return;
+	service = get_default_transport (session);
+	g_return_if_fail (CAMEL_IS_TRANSPORT (service));
 
 	data = setup_send_data (session);
 	info = g_hash_table_lookup (data->active, SEND_URI_KEY);
@@ -1521,24 +1352,12 @@ mail_send (EMailSession *session)
 		return;
 	}
 
-	transport_uid = g_strconcat (account->uid, "-transport", NULL);
-
-	service = camel_session_get_service (
-		CAMEL_SESSION (session), transport_uid);
-
-	if (!CAMEL_IS_TRANSPORT (service)) {
-		g_free (transport_uid);
-		return;
-	}
-
 	d(printf("starting non-interactive send of '%s'\n", transport->url));
 
 	type = get_receive_type (service);
 
-	if (type == SEND_INVALID) {
-		g_free (transport_uid);
+	if (type == SEND_INVALID)
 		return;
-	}
 
 	info = g_malloc0 (sizeof (*info));
 	info->type = SEND_SEND;
@@ -1562,10 +1381,6 @@ mail_send (EMailSession *session)
 		e_mail_session_get_local_folder (
 		session, E_MAIL_LOCAL_FOLDER_OUTBOX);
 
-	g_free (transport_uid);
-
-	g_return_if_fail (CAMEL_IS_TRANSPORT (service));
-
 	mail_send_queue (
 		session, local_outbox,
 		CAMEL_TRANSPORT (service),
diff --git a/mail/mail.error.xml b/mail/mail.error.xml
index 2a516d9..abc08bf 100644
--- a/mail/mail.error.xml
+++ b/mail/mail.error.xml
@@ -300,24 +300,6 @@ all proxy information will be deleted permanently.</_secondary>
     <button _label="_Disable" response="GTK_RESPONSE_YES"/>
   </error>
 
-  <error id="no-save-signature" type="error">
-    <_primary>Could not save signature file.</_primary>
-    <secondary xml:space="preserve">{0}.</secondary>
-  </error>
-
-  <error id="signature-notscript" type="error">
-    <_primary>Cannot set signature script "{0}".</_primary>
-    <_secondary xml:space="preserve">The script file must exist and be executable.</_secondary>
-  </error>
-
-  <error id="ask-signature-changed" type="question" default="GTK_RESPONSE_YES">
-    <_primary>Do you wish to save your changes?</_primary>
-    <_secondary xml:space="preserve">This signature has been changed, but has not been saved.</_secondary>
-    <button _label="_Discard changes" response="GTK_RESPONSE_NO"/>
-    <button stock="gtk-cancel" response="GTK_RESPONSE_CANCEL"/>
-    <button stock="gtk-save" response="GTK_RESPONSE_YES"/>
-  </error>
-
   <error id="vfolder-notexist" type="error">
     <_primary>Cannot edit Search Folder "{0}" as it does not exist.</_primary>
     <_secondary xml:space="preserve">This folder may have been added implicitly,
@@ -426,16 +408,6 @@ An mbox account will be created to preserve the old mbox folders. You can delete
     <button _label="N_ever" response="GTK_RESPONSE_CANCEL"/>
   </error>
 
-  <error id="signature-already-exists" type="error" modal="true">
-    <_primary>Signature Already Exists</_primary>
-    <_secondary>A signature already exists with the name "{0}". Please specify a different name. </_secondary>
-  </error>
-  
-  <error id="blank-signature" type="error" modal="true">
-    <_primary>Blank Signature</_primary>
-    <_secondary>Please provide an unique name to identify this signature.</_secondary>
-  </error>
-  
   <error id="send-no-account-enabled" type="warning">
     <_primary>This message cannot be sent because the account you chose to send with is not enabled</_primary>
     <_secondary xml:space="preserve">Please enable the account or send using another account.</_secondary>



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]