diff --git a/mail/em-account-editor.c b/mail/em-account-editor.c
index 1f0fdb8..5fb2711 100644
--- a/mail/em-account-editor.c
+++ b/mail/em-account-editor.c
@@ -55,6 +55,7 @@
 #include <e-util/e-signature-list.h>
 
 #include "e-util/e-error.h"
+#include "e-util/e-dialog-utils.h"
 #include "e-util/e-util-private.h"
 
 #include "em-config.h"
@@ -155,6 +156,12 @@ typedef struct _EMAccountEditorPrivate {
 	/* special folders */
 	struct _GtkButton *drafts_folder_button;
 	struct _GtkButton *sent_folder_button;
+	GtkToggleButton *trash_folder_check;
+	GtkButton *trash_folder_button;
+	GtkWidget *trash_folder_fixed;
+	GtkToggleButton *junk_folder_check;
+	GtkButton *junk_folder_button;
+	GtkWidget *junk_folder_fixed;
 	struct _GtkButton *restore_folders_button;
 
 	/* Security */
@@ -475,6 +482,9 @@ default_folders_clicked (GtkButton *button, gpointer user_data)
 	uri = mail_component_get_folder_uri(NULL, MAIL_COMPONENT_FOLDER_SENT);
 	em_folder_selection_button_set_selection((EMFolderSelectionButton *)emae->priv->sent_folder_button, uri);
 	emae_account_folder_changed((EMFolderSelectionButton *)emae->priv->sent_folder_button, emae);
+
+	gtk_toggle_button_set_active (emae->priv->trash_folder_check, FALSE);
+	gtk_toggle_button_set_active (emae->priv->junk_folder_check, FALSE);
 }
 
 /* custom widget factories */
@@ -2382,6 +2392,173 @@ emae_send_page(EConfig *ec, EConfigItem *item, struct _GtkWidget *parent, struct
 	return w;
 }
 
+static void
+emae_get_checkable_folder_keys_widgets (EMAccountEditor *emae, guint32 flag, GtkWidget **check, GtkWidget **button, const gchar **param_key)
+{
+	g_return_if_fail (emae != NULL);
+	g_return_if_fail (flag == CAMEL_PROVIDER_ALLOW_REAL_TRASH_FOLDER || flag == CAMEL_PROVIDER_ALLOW_REAL_JUNK_FOLDER);
+
+	if (flag == CAMEL_PROVIDER_ALLOW_REAL_TRASH_FOLDER) {
+		if (check) *check = (GtkWidget *) emae->priv->trash_folder_check;
+		if (button) *button = (GtkWidget *) emae->priv->trash_folder_button;
+		if (param_key) *param_key = "real_trash_path";
+	} else {
+		if (check) *check = (GtkWidget *) emae->priv->junk_folder_check;
+		if (button) *button = (GtkWidget *) emae->priv->junk_folder_button;
+		if (param_key) *param_key = "real_junk_path";
+	}
+}
+
+static void
+emae_real_url_toggled (GtkToggleButton *check, EMAccountEditor *emae)
+{
+	guint32 flag;
+	GtkWidget *butt = NULL;
+	gboolean checked;
+	const gchar *param_key;
+
+	g_return_if_fail (check != NULL);
+	g_return_if_fail (emae != NULL);
+
+	if (!GTK_WIDGET_IS_SENSITIVE (check) || !GTK_WIDGET_VISIBLE (check))
+		return;
+
+	flag = GPOINTER_TO_INT (g_object_get_data ((GObject *)check, "url-flag"));
+	g_return_if_fail (flag == CAMEL_PROVIDER_ALLOW_REAL_TRASH_FOLDER || flag == CAMEL_PROVIDER_ALLOW_REAL_JUNK_FOLDER);
+
+	emae_get_checkable_folder_keys_widgets (emae, flag, NULL, &butt, &param_key);
+
+	checked = gtk_toggle_button_get_active (check);
+	gtk_widget_set_sensitive (butt, checked);
+
+	if (!checked) {
+		CamelURL *url;
+
+		url = emae_account_url (emae, emae_service_info[emae->priv->source.type].account_uri_key);
+		camel_url_set_param (url, param_key, NULL);
+		emae_uri_changed (&emae->priv->source, url);
+		camel_url_free (url);
+
+		/* clear the previous selection */
+		em_folder_selection_button_set_selection ((EMFolderSelectionButton *)butt, "");
+	}
+}
+
+static void
+emae_real_url_folder_changed (EMFolderSelectionButton *folder, EMAccountEditor *emae)
+{
+	CamelURL *url;
+	guint32 flag;
+	GtkWidget *check = NULL;
+	gboolean changed = FALSE;
+	const gchar *param_key = NULL, *curi_selected;
+
+	g_return_if_fail (folder != NULL);
+	g_return_if_fail (emae != NULL);
+
+	if (!GTK_WIDGET_IS_SENSITIVE (folder) || !GTK_WIDGET_VISIBLE (folder))
+		return;
+
+	flag = GPOINTER_TO_INT (g_object_get_data ((GObject *)folder, "url-flag"));
+	g_return_if_fail (flag == CAMEL_PROVIDER_ALLOW_REAL_TRASH_FOLDER || flag == CAMEL_PROVIDER_ALLOW_REAL_JUNK_FOLDER);
+
+	emae_get_checkable_folder_keys_widgets (emae, flag, &check, NULL, &param_key);
+
+	if (!gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (check)))
+		return;
+
+	url = emae_account_url (emae, emae_service_info[emae->priv->source.type].account_uri_key);
+
+	curi_selected = em_folder_selection_button_get_selection (folder);
+	if (!curi_selected || !*curi_selected) {
+		camel_url_set_param (url, param_key, NULL);
+		changed = TRUE;
+	} else {
+		CamelURL *url_selected = camel_url_new (curi_selected, NULL);
+
+		if (url_selected && emae->priv->source.provider && emae->priv->source.provider->url_equal (url, url_selected) && url_selected->path) {
+			camel_url_set_param (url, param_key, (*url_selected->path) == '/' ? url_selected->path + 1 : url_selected->path);
+			changed = TRUE;
+		} else {
+			e_notice (NULL, GTK_MESSAGE_ERROR, "%s", _("You cannot select folder from other account than this here."));
+			em_folder_selection_button_set_selection (folder, "");
+		}
+
+		if (url_selected)
+			camel_url_free (url_selected);
+	}
+
+	if (changed)
+		emae_uri_changed (&emae->priv->source, url);
+	camel_url_free (url);
+}
+
+static void
+setup_checkable_folder (EMAccountEditor *emae, guint32 flag, GtkWidget *check, GtkWidget *button, GtkWidget *fixed)
+{
+	gboolean available;
+	EMFolderSelectionButton *folderbutt;
+	CamelURL *url;
+	const gchar *value, *param_key = NULL;
+
+	g_return_if_fail (emae != NULL);
+	g_return_if_fail (check != NULL);
+	g_return_if_fail (button != NULL);
+	g_return_if_fail (flag == CAMEL_PROVIDER_ALLOW_REAL_TRASH_FOLDER || flag == CAMEL_PROVIDER_ALLOW_REAL_JUNK_FOLDER);
+
+	folderbutt = (EMFolderSelectionButton *)button;
+	url = emae_account_url (emae, emae_service_info[emae->priv->source.type].account_uri_key);
+
+	emae_get_checkable_folder_keys_widgets (emae, flag, NULL, NULL, &param_key);
+
+	value = camel_url_get_param (url, param_key);
+	available = emae->account->enabled;
+	gtk_widget_set_sensitive (check, available);
+
+	if (value && *value) {
+		gchar *url_string = camel_url_to_string (url, CAMEL_URL_HIDE_ALL);
+		if (!url_string) {
+			em_folder_selection_button_set_selection (folderbutt, "");
+		} else {
+			CamelURL *copy = camel_url_new (url_string, NULL);
+
+			if (copy->path)
+				g_free (copy->path);
+			copy->path = g_strconcat ("/", value, NULL);
+			g_free (url_string);
+
+			url_string = camel_url_to_string (copy, CAMEL_URL_HIDE_ALL);
+			em_folder_selection_button_set_selection (folderbutt, url_string ? url_string : "");
+			g_free (url_string);
+		}
+	} else {
+		em_folder_selection_button_set_selection (folderbutt, "");
+	}
+
+	value = em_folder_selection_button_get_selection (folderbutt);
+	gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (check), value && *value);
+	gtk_widget_set_sensitive (button, available && value && *value);
+
+	g_object_set_data ((GObject *)check, "url-flag", GINT_TO_POINTER(flag));
+	g_object_set_data ((GObject *)folderbutt, "url-flag", GINT_TO_POINTER(flag));
+
+	g_signal_connect (check, "toggled", G_CALLBACK (emae_real_url_toggled), emae);
+	g_signal_connect (folderbutt, "selected", G_CALLBACK (emae_real_url_folder_changed), emae);
+
+	available = emae->priv->source.provider && ((emae->priv->source.provider->flags & flag) == flag);
+	if (available) {
+		gtk_widget_show (check);
+		gtk_widget_show (button);
+		gtk_widget_show (fixed);
+	} else {
+		gtk_widget_hide (check);
+		gtk_widget_hide (button);
+		gtk_widget_hide (fixed);
+	}
+
+	camel_url_free (url);
+}
+
 static GtkWidget *
 emae_defaults_page(EConfig *ec, EConfigItem *item, struct _GtkWidget *parent, struct _GtkWidget *old, gpointer data)
 {
@@ -2404,6 +2581,16 @@ emae_defaults_page(EConfig *ec, EConfigItem *item, struct _GtkWidget *parent, st
 	gui->drafts_folder_button = (GtkButton *)emae_account_folder(emae, "drafts_button", E_ACCOUNT_DRAFTS_FOLDER_URI, MAIL_COMPONENT_FOLDER_DRAFTS, xml);
 	gui->sent_folder_button = (GtkButton *)emae_account_folder(emae, "sent_button", E_ACCOUNT_SENT_FOLDER_URI, MAIL_COMPONENT_FOLDER_SENT, xml);
 
+	gui->trash_folder_check = GTK_TOGGLE_BUTTON (glade_xml_get_widget (xml, "trash_folder_check"));
+	gui->trash_folder_button = GTK_BUTTON (glade_xml_get_widget (xml, "trash_folder_butt"));
+	gui->trash_folder_fixed = glade_xml_get_widget (xml, "trash_folder_fixed");
+	setup_checkable_folder (emae, CAMEL_PROVIDER_ALLOW_REAL_TRASH_FOLDER, GTK_WIDGET (gui->trash_folder_check), GTK_WIDGET (gui->trash_folder_button), gui->trash_folder_fixed);
+
+	gui->junk_folder_check = GTK_TOGGLE_BUTTON (glade_xml_get_widget (xml, "junk_folder_check"));
+	gui->junk_folder_button = GTK_BUTTON (glade_xml_get_widget (xml, "junk_folder_butt"));
+	gui->junk_folder_fixed = glade_xml_get_widget (xml, "junk_folder_fixed");
+	setup_checkable_folder (emae, CAMEL_PROVIDER_ALLOW_REAL_JUNK_FOLDER, GTK_WIDGET (gui->junk_folder_check), GTK_WIDGET (gui->junk_folder_button), gui->junk_folder_fixed);
+
 	/* Special Folders "Reset Defaults" button */
 	gui->restore_folders_button = (GtkButton *)glade_xml_get_widget (xml, "default_folders_button");
 	g_signal_connect (gui->restore_folders_button, "clicked", G_CALLBACK (default_folders_clicked), emae);
diff --git a/mail/mail-config.glade b/mail/mail-config.glade
index f435b95..ec8fb2d 100644
--- a/mail/mail-config.glade
+++ b/mail/mail-config.glade
@@ -2736,7 +2736,7 @@ For example: &quot;Work&quot; or &quot;Personal&quot;</property>
 			  <child>
 			    <widget class="GtkTable" id="folders_table">
 			      <property name="visible">True</property>
-			      <property name="n_rows">3</property>
+			      <property name="n_rows">5</property>
 			      <property name="n_columns">3</property>
 			      <property name="homogeneous">False</property>
 			      <property name="row_spacing">6</property>
@@ -2900,8 +2900,118 @@ For example: &quot;Work&quot; or &quot;Personal&quot;</property>
 				<packing>
 				  <property name="left_attach">1</property>
 				  <property name="right_attach">3</property>
+				  <property name="top_attach">4</property>
+				  <property name="bottom_attach">5</property>
+				</packing>
+			      </child>
+
+			      <child>
+				<widget class="GtkCheckButton" id="trash_folder_check">
+				  <property name="visible">True</property>
+				  <property name="can_focus">True</property>
+				  <property name="label" translatable="yes">_Trash Folder:</property>
+				  <property name="use_underline">True</property>
+				  <property name="relief">GTK_RELIEF_NORMAL</property>
+				  <property name="focus_on_click">True</property>
+				  <property name="active">False</property>
+				  <property name="inconsistent">False</property>
+				  <property name="draw_indicator">True</property>
+				</widget>
+				<packing>
+				  <property name="left_attach">0</property>
+				  <property name="right_attach">1</property>
+				  <property name="top_attach">2</property>
+				  <property name="bottom_attach">3</property>
+				  <property name="x_options">fill</property>
+				  <property name="y_options"></property>
+				</packing>
+			      </child>
+
+			      <child>
+				<widget class="Custom" id="trash_folder_butt">
+				  <property name="visible">True</property>
+				  <property name="creation_function">em_account_editor_folder_selector_button_new</property>
+				  <property name="string1">Select Trash Folder</property>
+				  <property name="int1">0</property>
+				  <property name="int2">0</property>
+				  <property name="last_modification_time">Tue, 14 Dec 2004 17:07:09 GMT</property>
+				</widget>
+				<packing>
+				  <property name="left_attach">1</property>
+				  <property name="right_attach">2</property>
 				  <property name="top_attach">2</property>
 				  <property name="bottom_attach">3</property>
+				  <property name="x_options">fill</property>
+				  <property name="y_options">fill</property>
+				</packing>
+			      </child>
+
+			      <child>
+				<widget class="GtkCheckButton" id="junk_folder_check">
+				  <property name="visible">True</property>
+				  <property name="can_focus">True</property>
+				  <property name="label" translatable="yes">_Junk Folder:</property>
+				  <property name="use_underline">True</property>
+				  <property name="relief">GTK_RELIEF_NORMAL</property>
+				  <property name="focus_on_click">True</property>
+				  <property name="active">False</property>
+				  <property name="inconsistent">False</property>
+				  <property name="draw_indicator">True</property>
+				</widget>
+				<packing>
+				  <property name="left_attach">0</property>
+				  <property name="right_attach">1</property>
+				  <property name="top_attach">3</property>
+				  <property name="bottom_attach">4</property>
+				  <property name="x_options">fill</property>
+				  <property name="y_options"></property>
+				</packing>
+			      </child>
+
+			      <child>
+				<widget class="Custom" id="junk_folder_butt">
+				  <property name="visible">True</property>
+				  <property name="creation_function">em_account_editor_folder_selector_button_new</property>
+				  <property name="string1">Select Junk Folder</property>
+				  <property name="int1">0</property>
+				  <property name="int2">0</property>
+				  <property name="last_modification_time">Tue, 14 Dec 2004 17:07:09 GMT</property>
+				</widget>
+				<packing>
+				  <property name="left_attach">1</property>
+				  <property name="right_attach">2</property>
+				  <property name="top_attach">3</property>
+				  <property name="bottom_attach">4</property>
+				  <property name="x_options">fill</property>
+				  <property name="y_options">fill</property>
+				</packing>
+			      </child>
+
+			      <child>
+				<widget class="GtkFixed" id="trash_folder_fixed">
+				  <property name="visible">True</property>
+				</widget>
+				<packing>
+				  <property name="left_attach">2</property>
+				  <property name="right_attach">3</property>
+				  <property name="top_attach">2</property>
+				  <property name="bottom_attach">3</property>
+				  <property name="x_options">fill</property>
+				  <property name="y_options">fill</property>
+				</packing>
+			      </child>
+
+			      <child>
+				<widget class="GtkFixed" id="junk_folder_fixed">
+				  <property name="visible">True</property>
+				</widget>
+				<packing>
+				  <property name="left_attach">2</property>
+				  <property name="right_attach">3</property>
+				  <property name="top_attach">3</property>
+				  <property name="bottom_attach">4</property>
+				  <property name="x_options">fill</property>
+				  <property name="y_options">fill</property>
 				</packing>
 			      </child>
 			    </widget>
