2008-06-22 [colin] 3.4.0cvs104
[claws.git] / src / compose.c
index fa082a8b150f3c8050437e06352aedf1511c9c0d..e0f9654fe1447e5b72d799f0aad99dee791330f4 100644 (file)
 #include "hooks.h"
 #include "privacy.h"
 #include "timing.h"
+#include "autofaces.h"
 
 enum
 {
@@ -152,7 +153,6 @@ typedef enum
        COMPOSE_CALL_ADVANCED_ACTION_DELETE_FORWARD_WORD,
        COMPOSE_CALL_ADVANCED_ACTION_DELETE_BACKWARD_WORD,
        COMPOSE_CALL_ADVANCED_ACTION_DELETE_LINE,
-       COMPOSE_CALL_ADVANCED_ACTION_DELETE_LINE_N,
        COMPOSE_CALL_ADVANCED_ACTION_DELETE_TO_LINE_END
 } ComposeCallAdvancedAction;
 
@@ -235,7 +235,8 @@ static void compose_template_apply          (Compose        *compose,
 static void compose_destroy                    (Compose        *compose);
 
 static void compose_entries_set                        (Compose        *compose,
-                                                const gchar    *mailto);
+                                                const gchar    *mailto,
+                                                ComposeEntryType to_type);
 static gint compose_parse_header               (Compose        *compose,
                                                 MsgInfo        *msginfo);
 static gchar *compose_parse_references         (const gchar    *ref,
@@ -546,6 +547,9 @@ static MsgInfo *compose_msginfo_new_from_compose(Compose *compose);
 static void compose_set_dictionaries_from_folder_prefs(Compose *compose,
                                                FolderItem *folder_item);
 #endif
+static void compose_attach_update_label(Compose *compose);
+
+static void compose_attach_from_list(Compose *compose, GList *file_list, gboolean free_data);
 
 static GtkItemFactoryEntry compose_popup_entries[] =
 {
@@ -653,11 +657,6 @@ static GtkItemFactoryEntry compose_entries[] =
                                        compose_advanced_action_cb,
                                        COMPOSE_CALL_ADVANCED_ACTION_DELETE_LINE,
                                        NULL},
-       {N_("/_Edit/A_dvanced/Delete entire line"),
-                                       NULL,
-                                       compose_advanced_action_cb,
-                                       COMPOSE_CALL_ADVANCED_ACTION_DELETE_LINE_N,
-                                       NULL},
        {N_("/_Edit/A_dvanced/Delete to end of line"),
                                        "<control>K",
                                        compose_advanced_action_cb,
@@ -722,7 +721,7 @@ static GtkItemFactoryEntry compose_entries[] =
                        NULL, compose_set_encoding_cb, C_AUTO, "<RadioItem>"},
        {N_("/_Options/Character _encoding/---"), NULL, NULL, 0, "<Separator>"},
 
-       {N_("/_Options/Character _encoding/7bit ascii (US-ASC_II)"),
+       {N_("/_Options/Character _encoding/7bit ASCII (US-ASC_II)"),
         ENC_ACTION(C_US_ASCII)},
        {N_("/_Options/Character _encoding/Unicode (_UTF-8)"),
         ENC_ACTION(C_UTF_8)},
@@ -1000,15 +999,71 @@ Compose *compose_generic_new(PrefsAccount *account, const gchar *mailto, FolderI
        GtkItemFactory *ifactory;
        const gchar *subject_format = NULL;
        const gchar *body_format = NULL;
+       gchar *mailto_from = NULL;
+       PrefsAccount *mailto_account = NULL;
+       MsgInfo* dummyinfo = NULL;
 
-       if (item && item->prefs && item->prefs->enable_default_account)
+       /* check if mailto defines a from */
+       if (mailto && *mailto != '\0') {
+               scan_mailto_url(mailto, &mailto_from, NULL, NULL, NULL, NULL, NULL, NULL);
+               /* mailto defines a from, check if we can get account prefs from it,
+                  if not, the account prefs will be guessed using other ways, but we'll keep
+                  the from anyway */
+               if (mailto_from)
+                       mailto_account = account_find_from_address(mailto_from, TRUE);
+               if (mailto_account)
+                       account = mailto_account;
+       }
+
+       /* if no account prefs set from mailto, set if from folder prefs (if any) */
+       if (!mailto_account && item && item->prefs && item->prefs->enable_default_account)
                account = account_find_from_id(item->prefs->default_account);
 
+       /* if no account prefs set, fallback to the current one */
        if (!account) account = cur_account;
        g_return_val_if_fail(account != NULL, NULL);
 
        compose = compose_create(account, item, COMPOSE_NEW, FALSE);
 
+       /* override from name if mailto asked for it */
+       if (mailto_from) {
+               gtk_entry_set_text(GTK_ENTRY(compose->from_name), mailto_from);
+               g_free(mailto_from);
+       } else
+               /* override from name according to folder properties */
+               if (item && item->prefs &&
+                       item->prefs->compose_with_format &&
+                       item->prefs->compose_override_from_format &&
+                       *item->prefs->compose_override_from_format != '\0') {
+
+                       gchar *tmp = NULL;
+                       gchar *buf = NULL;
+
+                       dummyinfo = compose_msginfo_new_from_compose(compose);
+
+                       /* decode \-escape sequences in the internal representation of the quote format */
+                       tmp = malloc(strlen(item->prefs->compose_override_from_format)+1);
+                       pref_get_unescaped_pref(tmp, item->prefs->compose_override_from_format);
+
+#ifdef USE_ASPELL
+                       quote_fmt_init(dummyinfo, NULL, NULL, FALSE, compose->account, FALSE,
+                                       compose->gtkaspell);
+#else
+                       quote_fmt_init(dummyinfo, NULL, NULL, FALSE, compose->account, FALSE);
+#endif
+                       quote_fmt_scan_string(tmp);
+                       quote_fmt_parse();
+
+                       buf = quote_fmt_get_buffer();
+                       if (buf == NULL)
+                               alertpanel_error(_("New message From format error."));
+                       else
+                               gtk_entry_set_text(GTK_ENTRY(compose->from_name), buf);
+                       quote_fmt_reset_vartable();
+
+                       g_free(tmp);
+               }
+
        ifactory = gtk_item_factory_from_widget(compose->menubar);
 
        compose->replyinfo = NULL;
@@ -1030,7 +1085,7 @@ Compose *compose_generic_new(PrefsAccount *account, const gchar *mailto, FolderI
 
        if (account->protocol != A_NNTP) {
                if (mailto && *mailto != '\0') {
-                       compose_entries_set(compose, mailto);
+                       compose_entries_set(compose, mailto, COMPOSE_TO);
 
                } else if (item && item->prefs->enable_default_to) {
                        compose_entry_append(compose, item->prefs->default_to, COMPOSE_TO);
@@ -1040,8 +1095,11 @@ Compose *compose_generic_new(PrefsAccount *account, const gchar *mailto, FolderI
                        menu_set_active(ifactory, "/Options/Request Return Receipt", TRUE);
                }
        } else {
-               if (mailto) {
-                       compose_entry_append(compose, mailto, COMPOSE_NEWSGROUPS);
+               if (mailto && *mailto != '\0') {
+                       if (!strchr(mailto, '@'))
+                               compose_entries_set(compose, mailto, COMPOSE_NEWSGROUPS);
+                       else
+                               compose_entries_set(compose, mailto, COMPOSE_TO);
                } else if (item && FOLDER_CLASS(item->folder) == news_get_class()) {
                        compose_entry_append(compose, item->path, COMPOSE_NEWSGROUPS);
                }
@@ -1065,7 +1123,6 @@ Compose *compose_generic_new(PrefsAccount *account, const gchar *mailto, FolderI
        }
 
        if (subject_format || body_format) {
-               MsgInfo* dummyinfo = NULL;
 
                if ( subject_format
                         && *subject_format != '\0' )
@@ -1074,7 +1131,8 @@ Compose *compose_generic_new(PrefsAccount *account, const gchar *mailto, FolderI
                        gchar *tmp = NULL;
                        gchar *buf = NULL;
 
-                       dummyinfo = compose_msginfo_new_from_compose(compose);
+                       if (!dummyinfo)
+                               dummyinfo = compose_msginfo_new_from_compose(compose);
 
                        /* decode \-escape sequences in the internal representation of the quote format */
                        tmp = malloc(strlen(subject_format)+1);
@@ -1082,10 +1140,10 @@ Compose *compose_generic_new(PrefsAccount *account, const gchar *mailto, FolderI
 
                        subject = gtk_editable_get_chars(GTK_EDITABLE(compose->subject_entry), 0, -1);
 #ifdef USE_ASPELL
-                       quote_fmt_init(dummyinfo, NULL, subject, FALSE, compose->account,
+                       quote_fmt_init(dummyinfo, NULL, subject, FALSE, compose->account, FALSE,
                                        compose->gtkaspell);
 #else
-                       quote_fmt_init(dummyinfo, NULL, subject, FALSE, compose->account);
+                       quote_fmt_init(dummyinfo, NULL, subject, FALSE, compose->account, FALSE);
 #endif
                        quote_fmt_scan_string(tmp);
                        quote_fmt_parse();
@@ -1095,6 +1153,7 @@ Compose *compose_generic_new(PrefsAccount *account, const gchar *mailto, FolderI
                                alertpanel_error(_("New message subject format error."));
                        else
                                gtk_entry_set_text(GTK_ENTRY(compose->subject_entry), buf);
+                       compose_attach_from_list(compose, quote_fmt_get_attachments_list(), FALSE);
                        quote_fmt_reset_vartable();
 
                        g_free(subject);
@@ -1109,7 +1168,7 @@ Compose *compose_generic_new(PrefsAccount *account, const gchar *mailto, FolderI
                        GtkTextIter start, end;
                        gchar *tmp = NULL;
 
-                       if ( dummyinfo == NULL )
+                       if (!dummyinfo)
                                dummyinfo = compose_msginfo_new_from_compose(compose);
 
                        text = GTK_TEXT_VIEW(compose->text);
@@ -1122,13 +1181,14 @@ Compose *compose_generic_new(PrefsAccount *account, const gchar *mailto, FolderI
                                          body_format,
                                          NULL, tmp, FALSE, TRUE,
                                                  _("New message body format error at line %d."));
+                       compose_attach_from_list(compose, quote_fmt_get_attachments_list(), FALSE);
                        quote_fmt_reset_vartable();
 
                        g_free(tmp);
                }
 
-               procmsg_msginfo_free( dummyinfo );
        }
+       procmsg_msginfo_free( dummyinfo );
 
        if (attach_files) {
                gint i;
@@ -1190,6 +1250,10 @@ static void compose_force_encryption(Compose *compose, PrefsAccount *account,
        if (privacy != NULL) {
                if (compose->privacy_system == NULL)
                        compose->privacy_system = g_strdup(privacy);
+               else if (*(compose->privacy_system) == '\0') {
+                       g_free(compose->privacy_system);
+                       compose->privacy_system = g_strdup(privacy);
+               }
                compose_update_privacy_system_menu_item(compose, FALSE);
                compose_use_encryption(compose, TRUE);
        }
@@ -1464,7 +1528,43 @@ static Compose *compose_generic_reply(MsgInfo *msginfo,
                g_free(folderidentifier);
        }
 
-       if (compose_parse_header(compose, msginfo) < 0) return NULL;
+       if (compose_parse_header(compose, msginfo) < 0) {
+               compose->updating = FALSE;
+               compose_destroy(compose);
+               return NULL;
+       }
+
+       /* override from name according to folder properties */
+       if (msginfo->folder && msginfo->folder->prefs &&
+               msginfo->folder->prefs->reply_with_format &&
+               msginfo->folder->prefs->reply_override_from_format &&
+               *msginfo->folder->prefs->reply_override_from_format != '\0') {
+
+               gchar *tmp = NULL;
+               gchar *buf = NULL;
+
+               /* decode \-escape sequences in the internal representation of the quote format */
+               tmp = malloc(strlen(msginfo->folder->prefs->reply_override_from_format)+1);
+               pref_get_unescaped_pref(tmp, msginfo->folder->prefs->reply_override_from_format);
+
+#ifdef USE_ASPELL
+               quote_fmt_init(compose->replyinfo, NULL, NULL, FALSE, compose->account, FALSE,
+                               compose->gtkaspell);
+#else
+               quote_fmt_init(compose->replyinfo, NULL, NULL, FALSE, compose->account, FALSE);
+#endif
+               quote_fmt_scan_string(tmp);
+               quote_fmt_parse();
+
+               buf = quote_fmt_get_buffer();
+               if (buf == NULL)
+                       alertpanel_error(_("Message reply From format error."));
+               else
+                       gtk_entry_set_text(GTK_ENTRY(compose->from_name), buf);
+               quote_fmt_reset_vartable();
+
+               g_free(tmp);
+       }
 
        textview = (GTK_TEXT_VIEW(compose->text));
        textbuf = gtk_text_view_get_buffer(textview);
@@ -1492,7 +1592,7 @@ static Compose *compose_generic_reply(MsgInfo *msginfo,
 
                } else {
                        qmark = prefs_common.quotemark;
-                       body_fmt = prefs_common.quotefmt;
+                       body_fmt = gettext(prefs_common.quotefmt);
                }
        }
 
@@ -1503,6 +1603,7 @@ static Compose *compose_generic_reply(MsgInfo *msginfo,
                compose_quote_fmt(compose, compose->replyinfo,
                                  body_fmt, qmark, body, FALSE, TRUE,
                                          _("Message reply format error at line %d."));
+               compose_attach_from_list(compose, quote_fmt_get_attachments_list(), FALSE);
                quote_fmt_reset_vartable();
        }
 
@@ -1589,6 +1690,45 @@ Compose *compose_forward(PrefsAccount *account, MsgInfo *msginfo,
                g_free(buf2);
        }
 
+       /* override from name according to folder properties */
+       if (msginfo->folder && msginfo->folder->prefs &&
+               msginfo->folder->prefs->forward_with_format &&
+               msginfo->folder->prefs->forward_override_from_format &&
+               *msginfo->folder->prefs->forward_override_from_format != '\0') {
+
+               gchar *tmp = NULL;
+               gchar *buf = NULL;
+               MsgInfo *full_msginfo = NULL;
+
+               if (!as_attach)
+                       full_msginfo = procmsg_msginfo_get_full_info(msginfo);
+               if (!full_msginfo)
+                       full_msginfo = procmsg_msginfo_copy(msginfo);
+
+               /* decode \-escape sequences in the internal representation of the quote format */
+               tmp = malloc(strlen(msginfo->folder->prefs->forward_override_from_format)+1);
+               pref_get_unescaped_pref(tmp, msginfo->folder->prefs->forward_override_from_format);
+
+#ifdef USE_ASPELL
+               quote_fmt_init(full_msginfo, NULL, NULL, FALSE, compose->account, FALSE,
+                               compose->gtkaspell);
+#else
+               quote_fmt_init(full_msginfo, NULL, NULL, FALSE, compose->account, FALSE);
+#endif
+               quote_fmt_scan_string(tmp);
+               quote_fmt_parse();
+
+               buf = quote_fmt_get_buffer();
+               if (buf == NULL)
+                       alertpanel_error(_("Message forward From format error."));
+               else
+                       gtk_entry_set_text(GTK_ENTRY(compose->from_name), buf);
+               quote_fmt_reset_vartable();
+
+               g_free(tmp);
+               procmsg_msginfo_free(full_msginfo);
+       }
+
        textview = GTK_TEXT_VIEW(compose->text);
        textbuf = gtk_text_view_get_buffer(textview);
        compose_create_tags(textview, compose);
@@ -1607,7 +1747,7 @@ Compose *compose_forward(PrefsAccount *account, MsgInfo *msginfo,
                g_free(msgfile);
        } else {
                const gchar *qmark = NULL;
-               const gchar *body_fmt = prefs_common.fw_quotefmt;
+               const gchar *body_fmt = gettext(prefs_common.fw_quotefmt);
                MsgInfo *full_msginfo;
 
                full_msginfo = procmsg_msginfo_get_full_info(msginfo);
@@ -1628,7 +1768,7 @@ Compose *compose_forward(PrefsAccount *account, MsgInfo *msginfo,
 
                } else {
                        qmark = prefs_common.fw_quotemark;
-                       body_fmt = prefs_common.fw_quotefmt;
+                       body_fmt = gettext(prefs_common.fw_quotefmt);
                }
 
                /* empty quotemark is not allowed */
@@ -1638,6 +1778,7 @@ Compose *compose_forward(PrefsAccount *account, MsgInfo *msginfo,
                compose_quote_fmt(compose, full_msginfo,
                                  body_fmt, qmark, body, FALSE, TRUE,
                                          _("Message forward format error at line %d."));
+               compose_attach_from_list(compose, quote_fmt_get_attachments_list(), FALSE);
                quote_fmt_reset_vartable();
                compose_attach_parts(compose, msginfo);
 
@@ -1726,6 +1867,42 @@ static Compose *compose_forward_multiple(PrefsAccount *account, GSList *msginfo_
 
        compose->updating = TRUE;
 
+       /* override from name according to folder properties */
+       if (msginfo_list->data) {
+               MsgInfo *msginfo = msginfo_list->data;
+
+               if (msginfo->folder && msginfo->folder->prefs &&
+                       msginfo->folder->prefs->forward_with_format &&
+                       msginfo->folder->prefs->forward_override_from_format &&
+                       *msginfo->folder->prefs->forward_override_from_format != '\0') {
+
+                       gchar *tmp = NULL;
+                       gchar *buf = NULL;
+
+                       /* decode \-escape sequences in the internal representation of the quote format */
+                       tmp = malloc(strlen(msginfo->folder->prefs->forward_override_from_format)+1);
+                       pref_get_unescaped_pref(tmp, msginfo->folder->prefs->forward_override_from_format);
+
+#ifdef USE_ASPELL
+                       quote_fmt_init(msginfo, NULL, NULL, FALSE, compose->account, FALSE,
+                                       compose->gtkaspell);
+#else
+                       quote_fmt_init(msginfo, NULL, NULL, FALSE, compose->account, FALSE);
+#endif
+                       quote_fmt_scan_string(tmp);
+                       quote_fmt_parse();
+
+                       buf = quote_fmt_get_buffer();
+                       if (buf == NULL)
+                               alertpanel_error(_("Message forward From format error."));
+                       else
+                               gtk_entry_set_text(GTK_ENTRY(compose->from_name), buf);
+                       quote_fmt_reset_vartable();
+
+                       g_free(tmp);
+               }
+       }
+
        textview = GTK_TEXT_VIEW(compose->text);
        textbuf = gtk_text_view_get_buffer(textview);
        compose_create_tags(textview, compose);
@@ -1919,7 +2096,7 @@ Compose *compose_reedit(MsgInfo *msginfo, gboolean batch)
                }
                if (!account && !procheader_get_header_from_msginfo(msginfo, queueheader_buf, 
                                                                sizeof(queueheader_buf), "S:")) {
-                       account = account_find_from_address(queueheader_buf);
+                       account = account_find_from_address(queueheader_buf, FALSE);
                }
                if (!procheader_get_header_from_msginfo(msginfo, queueheader_buf, 
                                             sizeof(queueheader_buf), "X-Claws-Sign:")) {
@@ -1986,7 +2163,7 @@ Compose *compose_reedit(MsgInfo *msginfo, gboolean batch)
                        gchar from[BUFFSIZE];
                if (!procheader_get_header_from_msginfo(msginfo, from, sizeof(from), "FROM:")) {
                        extract_address(from);
-                       account = account_find_from_address(from);
+                       account = account_find_from_address(from, FALSE);
                 }
        }
         if (!account) {
@@ -2368,22 +2545,26 @@ void compose_toolbar_cb(gint action, gpointer data)
        }
 }
 
-static void compose_entries_set(Compose *compose, const gchar *mailto)
+static void compose_entries_set(Compose *compose, const gchar *mailto, ComposeEntryType to_type)
 {
        gchar *to = NULL;
        gchar *cc = NULL;
+       gchar *bcc = NULL;
        gchar *subject = NULL;
        gchar *body = NULL;
        gchar *temp = NULL;
        gsize  len = 0;
-       gchar *attach = NULL;
-       
-       scan_mailto_url(mailto, &to, &cc, NULL, &subject, &body, &attach);
+       gchar **attach = NULL;
+
+       /* get mailto parts but skip from */
+       scan_mailto_url(mailto, NULL, &to, &cc, &bcc, &subject, &body, &attach);
 
        if (to)
-               compose_entry_append(compose, to, COMPOSE_TO);
+               compose_entry_append(compose, to, to_type);
        if (cc)
                compose_entry_append(compose, cc, COMPOSE_CC);
+       if (bcc)
+               compose_entry_append(compose, bcc, COMPOSE_BCC);
        if (subject) {
                if (!g_utf8_validate (subject, -1, NULL)) {
                        temp = g_locale_to_utf8 (subject, -1, NULL, &len, NULL);
@@ -2420,21 +2601,38 @@ static void compose_entries_set(Compose *compose, const gchar *mailto)
        }
 
        if (attach) {
-               gchar *utf8_filename = conv_filename_to_utf8(attach);
-               if (utf8_filename) {
-                       if (compose_attach_append(compose, attach, utf8_filename, NULL)) {
-                               alertpanel_notice(_("The file '%s' has been attached."), attach);
-                       } 
-                       g_free(utf8_filename);
-               } else {
-                       alertpanel_error(_("Couldn't attach a file (charset conversion failed)."));
+               gint i = 0, att = 0;
+               gchar *warn_files = NULL;
+               while (attach[i] != NULL) {
+                       gchar *utf8_filename = conv_filename_to_utf8(attach[i]);
+                       if (utf8_filename) {
+                               if (compose_attach_append(compose, attach[i], utf8_filename, NULL)) {
+                                       gchar *tmp = g_strdup_printf("%s%s\n",
+                                                       warn_files?warn_files:"",
+                                                       utf8_filename);
+                                       g_free(warn_files);
+                                       warn_files = tmp;
+                                       att++;
+                               }
+                               g_free(utf8_filename);
+                       } else {
+                               alertpanel_error(_("Couldn't attach a file (charset conversion failed)."));
+                       }
+                       i++;
+               }
+               if (warn_files) {
+                       alertpanel_notice(ngettext(
+                       "The following file has been attached: \n%s",
+                       "The following files have been attached: \n%s", att), warn_files);
+                       g_free(warn_files);
                }
        }
        g_free(to);
        g_free(cc);
+       g_free(bcc);
        g_free(subject);
        g_free(body);
-       g_free(attach);
+       g_strfreev(attach);
 }
 
 static gint compose_parse_header(Compose *compose, MsgInfo *msginfo)
@@ -2519,7 +2717,7 @@ static gint compose_parse_header(Compose *compose, MsgInfo *msginfo)
                extract_address(hentry[H_LIST_POST].body);
                if (hentry[H_LIST_POST].body[0] != '\0') {
                        scan_mailto_url(hentry[H_LIST_POST].body,
-                                       &to, NULL, NULL, NULL, NULL, NULL);
+                                       NULL, &to, NULL, NULL, NULL, NULL, NULL);
                        if (to) {
                                g_free(compose->ml_post);
                                compose->ml_post = to;
@@ -2653,10 +2851,10 @@ static gchar *compose_quote_fmt(Compose *compose, MsgInfo *msginfo,
 
        if (qmark != NULL) {
 #ifdef USE_ASPELL
-               quote_fmt_init(msginfo, NULL, NULL, FALSE, compose->account,
+               quote_fmt_init(msginfo, NULL, NULL, FALSE, compose->account, FALSE,
                                compose->gtkaspell);
 #else
-               quote_fmt_init(msginfo, NULL, NULL, FALSE, compose->account);
+               quote_fmt_init(msginfo, NULL, NULL, FALSE, compose->account, FALSE);
 #endif
                quote_fmt_scan_string(qmark);
                quote_fmt_parse();
@@ -2675,10 +2873,10 @@ static gchar *compose_quote_fmt(Compose *compose, MsgInfo *msginfo,
                                trimmed_body++;
 
 #ifdef USE_ASPELL
-               quote_fmt_init(msginfo, quote_str, trimmed_body, FALSE, compose->account,
+               quote_fmt_init(msginfo, quote_str, trimmed_body, FALSE, compose->account, FALSE,
                                compose->gtkaspell);
 #else
-               quote_fmt_init(msginfo, quote_str, trimmed_body, FALSE, compose->account);
+               quote_fmt_init(msginfo, quote_str, trimmed_body, FALSE, compose->account, FALSE);
 #endif
                if (need_unescape) {
                        gchar *tmp = NULL;
@@ -2725,10 +2923,10 @@ static gchar *compose_quote_fmt(Compose *compose, MsgInfo *msginfo,
        }
 
        cursor_pos = quote_fmt_get_cursor_pos();
+       if (cursor_pos == -1)
+               cursor_pos = gtk_text_iter_get_offset(&iter);
        compose->set_cursor_pos = cursor_pos;
-       if (cursor_pos == -1) {
-               cursor_pos = 0;
-       }
+
        gtk_text_buffer_get_start_iter(buffer, &iter);
        gtk_text_buffer_get_iter_at_offset(buffer, &iter, cursor_pos);
        gtk_text_buffer_place_cursor(buffer, &iter);
@@ -2864,7 +3062,7 @@ static void compose_reply_set_entry(Compose *compose, MsgInfo *msginfo,
                        Xstrdup_a(tmp1, msginfo->from, return);
                        extract_address(tmp1);
                        if (to_all || to_sender ||
-                           !account_find_from_address(tmp1))
+                           !account_find_from_address(tmp1, FALSE))
                                compose_entry_append(compose,
                                 (compose->replyto && !to_sender)
                                          ? compose->replyto :
@@ -2874,9 +3072,15 @@ static void compose_reply_set_entry(Compose *compose, MsgInfo *msginfo,
                                if (!folder_has_parent_of_type(msginfo->folder, F_QUEUE) &&
                                    !folder_has_parent_of_type(msginfo->folder, F_OUTBOX) &&
                                    !folder_has_parent_of_type(msginfo->folder, F_DRAFT)) {
-                                       compose_entry_append(compose,
-                                                 msginfo->from ? msginfo->from : "",
-                                                 COMPOSE_TO);
+                                       if (compose->replyto) {
+                                               compose_entry_append(compose,
+                                                       compose->replyto,
+                                                       COMPOSE_TO);
+                                       } else {
+                                               compose_entry_append(compose,
+                                                         msginfo->from ? msginfo->from : "",
+                                                         COMPOSE_TO);
+                                       }
                                } else {
                                        /* replying to own mail, use original recp */
                                        compose_entry_append(compose,
@@ -3029,7 +3233,7 @@ static void compose_insert_sig(Compose *compose, gboolean replace)
        GtkTextBuffer *buffer = gtk_text_view_get_buffer(text);
        GtkTextMark *mark;
        GtkTextIter iter, iter_end;
-       gint cur_pos;
+       gint cur_pos, ins_pos;
        gboolean prev_autowrap;
        gboolean found = FALSE;
        gboolean exists = FALSE;
@@ -3045,6 +3249,7 @@ static void compose_insert_sig(Compose *compose, gboolean replace)
        mark = gtk_text_buffer_get_insert(buffer);
        gtk_text_buffer_get_iter_at_mark(buffer, &iter, mark);
        cur_pos = gtk_text_iter_get_offset (&iter);
+       ins_pos = cur_pos;
 
        gtk_text_buffer_get_end_iter(buffer, &iter);
 
@@ -3063,7 +3268,7 @@ static void compose_insert_sig(Compose *compose, gboolean replace)
 
                if (found) {
                        /* include previous \n\n */
-                       gtk_text_iter_backward_chars(&first_iter, 2);
+                       gtk_text_iter_backward_chars(&first_iter, 1);
                        start_iter = first_iter;
                        end_iter = first_iter;
                        /* skip re-start */
@@ -3087,20 +3292,26 @@ static void compose_insert_sig(Compose *compose, gboolean replace)
                g_free(compose->sig_str);
                compose->sig_str = NULL;
        } else {
+               if (compose->sig_inserted == FALSE)
+                       gtk_text_buffer_insert(buffer, &iter, "\n", -1);
+               compose->sig_inserted = TRUE;
+
+               cur_pos = gtk_text_iter_get_offset(&iter);
                gtk_text_buffer_insert(buffer, &iter, compose->sig_str, -1);
                /* remove \n\n */
                gtk_text_buffer_get_iter_at_offset(buffer, &iter, cur_pos);
-               gtk_text_iter_forward_chars(&iter, 2);
+               gtk_text_iter_forward_chars(&iter, 1);
                gtk_text_buffer_get_end_iter(buffer, &iter_end);
                gtk_text_buffer_apply_tag_by_name(buffer,"signature",&iter, &iter_end);
 
                if (cur_pos > gtk_text_buffer_get_char_count (buffer))
                        cur_pos = gtk_text_buffer_get_char_count (buffer);
        }
+
        /* put the cursor where it should be 
-        * either where the quote_fmt says, either before the signature */
+        * either where the quote_fmt says, either where it was */
        if (compose->set_cursor_pos < 0)
-               gtk_text_buffer_get_iter_at_offset(buffer, &iter, cur_pos);
+               gtk_text_buffer_get_iter_at_offset(buffer, &iter, ins_pos);
        else
                gtk_text_buffer_get_iter_at_offset(buffer, &iter, 
                        compose->set_cursor_pos);
@@ -3145,11 +3356,11 @@ static gchar *compose_get_signature_str(Compose *compose)
        }
 
        if (compose->account->sig_sep) {
-               sig_str = g_strconcat("\n\n", compose->account->sig_sep, "\n", sig_body,
+               sig_str = g_strconcat("\n", compose->account->sig_sep, "\n", sig_body,
                                      NULL);
                g_free(sig_body);
        } else
-               sig_str = g_strconcat("\n\n", sig_body, NULL);
+               sig_str = g_strconcat("\n", sig_body, NULL);
 
        if (sig_str) {
                if (g_utf8_validate(sig_str, -1, NULL) == TRUE)
@@ -3341,8 +3552,8 @@ static gboolean compose_attach_append(Compose *compose, const gchar *file,
                ainfo->content_type = g_strdup("application/octet-stream");
        }
 
-       ainfo->size = size;
-       size_text = to_human_readable(size);
+       ainfo->size = (goffset)size;
+       size_text = to_human_readable((goffset)size);
 
        store = GTK_LIST_STORE(gtk_tree_view_get_model
                        (GTK_TREE_VIEW(compose->attach_clist)));
@@ -3357,6 +3568,7 @@ static gboolean compose_attach_append(Compose *compose, const gchar *file,
                           -1);
        
        g_auto_pointer_free(auto_ainfo);
+       compose_attach_update_label(compose);
        return TRUE;
 }
 
@@ -3727,9 +3939,9 @@ static gboolean compose_join_next_line(Compose *compose,
        gboolean keep_cursor = FALSE;
 
        if (!gtk_text_iter_forward_line(&iter_) ||
-           gtk_text_iter_ends_line(&iter_))
+           gtk_text_iter_ends_line(&iter_)) {
                return FALSE;
-
+       }
        next_quote_str = compose_get_quote_str(buffer, &iter_, &quote_len);
 
        if ((quote_str || next_quote_str) &&
@@ -3742,18 +3954,20 @@ static gboolean compose_join_next_line(Compose *compose,
        end = iter_;
        if (quote_len > 0) {
                gtk_text_iter_forward_chars(&end, quote_len);
-               if (gtk_text_iter_ends_line(&end))
+               if (gtk_text_iter_ends_line(&end)) {
                        return FALSE;
+               }
        }
 
        /* don't join itemized lines */
-       if (compose_is_itemized(buffer, &end))
+       if (compose_is_itemized(buffer, &end)) {
                return FALSE;
+       }
 
        /* don't join signature separator */
-       if (compose_is_sig_separator(compose, buffer, &iter_))
+       if (compose_is_sig_separator(compose, buffer, &iter_)) {
                return FALSE;
-
+       }
        /* delete quote str */
        if (quote_len > 0)
                gtk_text_buffer_delete(buffer, &iter_, &end);
@@ -4145,7 +4359,7 @@ colorize:
                                removed = TRUE;
                        }
                }
-               if (uri_start > 0 && uri_stop > 0) {
+               if (uri_start >= 0 && uri_stop > 0) {
                        GtkTextIter uri_start_iter, uri_end_iter, back;
                        gtk_text_buffer_get_iter_at_offset(
                                buffer, &uri_start_iter, uri_start);
@@ -4216,7 +4430,7 @@ static void compose_set_title(Compose *compose)
        subject = gtk_editable_get_chars(
                        GTK_EDITABLE(compose->subject_entry), 0, -1);
 
-#ifndef MAEMO
+#ifndef GENERIC_UMPC
        if (subject && strlen(subject))
                str = g_strdup_printf(_("%s - Compose message%s"),
                                      subject, edited); 
@@ -4395,8 +4609,8 @@ gboolean compose_check_for_valid_recipient(Compose *compose) {
                gchar *entry;
                header = gtk_editable_get_chars(GTK_EDITABLE(GTK_BIN(((ComposeHeaderEntry *)list->data)->combo)->child), 0, -1);
                entry = gtk_editable_get_chars(GTK_EDITABLE(((ComposeHeaderEntry *)list->data)->entry), 0, -1);
-
                g_strstrip(entry);
+               g_strstrip(header);
                if (entry[0] != '\0') {
                        for (strptr = recipient_headers_mail; *strptr != NULL; strptr++) {
                                if (!strcmp(header, prefs_common_translated_header_name(*strptr))) {
@@ -4429,6 +4643,7 @@ static gboolean compose_check_for_set_recipients(Compose *compose)
                        entry = gtk_editable_get_chars(GTK_EDITABLE(((ComposeHeaderEntry *)list->data)->entry), 0, -1);
                        header = gtk_editable_get_chars(GTK_EDITABLE(GTK_BIN(((ComposeHeaderEntry *)list->data)->combo)->child), 0, -1);
                        g_strstrip(entry);
+                       g_strstrip(header);
                        if (strcmp(entry, compose->account->auto_cc)
                        ||  strcmp(header, prefs_common_translated_header_name("Cc:"))) {
                                found_other = TRUE;
@@ -4460,6 +4675,7 @@ static gboolean compose_check_for_set_recipients(Compose *compose)
                        entry = gtk_editable_get_chars(GTK_EDITABLE(((ComposeHeaderEntry *)list->data)->entry), 0, -1);
                        header = gtk_editable_get_chars(GTK_EDITABLE(GTK_BIN(((ComposeHeaderEntry *)list->data)->combo)->child), 0, -1);
                        g_strstrip(entry);
+                       g_strstrip(header);
                        if (strcmp(entry, compose->account->auto_bcc)
                        ||  strcmp(header, prefs_common_translated_header_name("Bcc:"))) {
                                found_other = TRUE;
@@ -4512,8 +4728,9 @@ static gboolean compose_check_entries(Compose *compose, gboolean check_everythin
                                button_label = _("+_Send");
                        else
                                button_label = _("+_Queue");
-                       message = g_strdup_printf(_("Subject is empty. %s it anyway?"),
-                                       compose->sending?_("Send"):_("Queue"));
+                       message = g_strdup_printf(_("Subject is empty. %s"),
+                                       compose->sending?_("Send it anyway?"):
+                                       _("Queue it anyway?"));
 
                        aval = alertpanel(compose->sending?_("Send"):_("Send later"), message,
                                          GTK_STOCK_CANCEL, button_label, NULL);
@@ -4582,7 +4799,7 @@ gint compose_send(Compose *compose)
                goto bail;
        }
 
-       tmsgid = g_strdup(compose->msgid);
+       tmsgid = compose->msgid ? g_strdup(compose->msgid) : NULL;
        if (discard_window) {
                compose->sending = FALSE;
                compose_close(compose);
@@ -4608,7 +4825,7 @@ gint compose_send(Compose *compose)
                g_free(msgpath);
        } else {
                val = procmsg_send_message_queue(msgpath, &errstr, folder, msgnum, &queued_removed);
-               g_unlink(msgpath);
+               claws_unlink(msgpath);
                g_free(msgpath);
        }
        if (!discard_window) {
@@ -4815,9 +5032,14 @@ static gint compose_redirect_write_headers(Compose *compose, FILE *fp)
        } else {
                g_snprintf(buf, sizeof(buf), "%s", "");
        }
-       generate_msgid(buf, sizeof(buf));
-       err |= (fprintf(fp, "Resent-Message-ID: <%s>\n", buf) < 0);
-       compose->msgid = g_strdup(buf);
+
+       if (compose->account->gen_msgid) {
+               generate_msgid(buf, sizeof(buf));
+               err |= (fprintf(fp, "Resent-Message-ID: <%s>\n", buf) < 0);
+               compose->msgid = g_strdup(buf);
+       } else {
+               compose->msgid = NULL;
+       }
 
        if (compose_redirect_write_headers_from_headerlist(compose, fp))
                return -1;
@@ -4923,9 +5145,10 @@ static gint compose_write_to_file(Compose *compose, FILE *fp, gint action, gbool
        gchar *chars;
        gchar *buf;
        const gchar *out_codeset;
-       EncodingType encoding;
+       EncodingType encoding = ENC_UNKNOWN;
        MimeInfo *mimemsg, *mimetext;
        gint line;
+       const gchar *src_codeset = CS_INTERNAL;
 
        if (action == COMPOSE_WRITE_FOR_SEND)
                attach_parts = TRUE;
@@ -4944,49 +5167,48 @@ static gint compose_write_to_file(Compose *compose, FILE *fp, gint action, gbool
        gtk_text_buffer_get_start_iter(buffer, &start);
        gtk_text_buffer_get_end_iter(buffer, &end);
        chars = gtk_text_buffer_get_text(buffer, &start, &end, FALSE);
-       if (is_ascii_str(chars)) {
-               buf = chars;
-               chars = NULL;
+
+       out_codeset = conv_get_charset_str(compose->out_encoding);
+
+       if (!out_codeset && is_ascii_str(chars)) {
+               out_codeset = CS_US_ASCII;
+       } else if (prefs_common.outgoing_fallback_to_ascii &&
+                  is_ascii_str(chars)) {
                out_codeset = CS_US_ASCII;
                encoding = ENC_7BIT;
-       } else {
-               const gchar *src_codeset = CS_INTERNAL;
+       }
 
-               out_codeset = conv_get_charset_str(compose->out_encoding);
+       if (!out_codeset) {
+               gchar *test_conv_global_out = NULL;
+               gchar *test_conv_reply = NULL;
 
-               if (!out_codeset) {
-                       gchar *test_conv_global_out = NULL;
-                       gchar *test_conv_reply = NULL;
+               /* automatic mode. be automatic. */
+               codeconv_set_strict(TRUE);
 
-                       /* automatic mode. be automatic. */
-                       codeconv_set_strict(TRUE);
-                       
-                       out_codeset = conv_get_outgoing_charset_str();
-                       if (out_codeset) {
-                               debug_print("trying to convert to %s\n", out_codeset);
-                               test_conv_global_out = conv_codeset_strdup(chars, src_codeset, out_codeset);
-                       }
-                       
-                       if (!test_conv_global_out && compose->orig_charset
-                       &&  strcmp(compose->orig_charset, CS_US_ASCII)) {
-                               out_codeset = compose->orig_charset;
-                               debug_print("failure; trying to convert to %s\n", out_codeset);
-                               test_conv_reply = conv_codeset_strdup(chars, src_codeset, out_codeset);
-                       }
-                       
-                       if (!test_conv_global_out && !test_conv_reply) {
-                               /* we're lost */
-                               out_codeset = CS_INTERNAL;
-                               debug_print("failure; finally using %s\n", out_codeset);
-                       }
-                       g_free(test_conv_global_out);
-                       g_free(test_conv_reply);
-                       codeconv_set_strict(FALSE);
+               out_codeset = conv_get_outgoing_charset_str();
+               if (out_codeset) {
+                       debug_print("trying to convert to %s\n", out_codeset);
+                       test_conv_global_out = conv_codeset_strdup(chars, src_codeset, out_codeset);
                }
 
-               if (!g_ascii_strcasecmp(out_codeset, CS_US_ASCII))
-                       out_codeset = CS_ISO_8859_1;
+               if (!test_conv_global_out && compose->orig_charset
+               &&  strcmp(compose->orig_charset, CS_US_ASCII)) {
+                       out_codeset = compose->orig_charset;
+                       debug_print("failure; trying to convert to %s\n", out_codeset);
+                       test_conv_reply = conv_codeset_strdup(chars, src_codeset, out_codeset);
+               }
 
+               if (!test_conv_global_out && !test_conv_reply) {
+                       /* we're lost */
+                       out_codeset = CS_INTERNAL;
+                       debug_print("failure; finally using %s\n", out_codeset);
+               }
+               g_free(test_conv_global_out);
+               g_free(test_conv_reply);
+               codeconv_set_strict(FALSE);
+       }
+
+       if (encoding == ENC_UNKNOWN) {
                if (prefs_common.encoding_method == CTE_BASE64)
                        encoding = ENC_BASE64;
                else if (prefs_common.encoding_method == CTE_QUOTED_PRINTABLE)
@@ -4995,40 +5217,40 @@ static gint compose_write_to_file(Compose *compose, FILE *fp, gint action, gbool
                        encoding = ENC_8BIT;
                else
                        encoding = procmime_get_encoding_for_charset(out_codeset);
+       }
 
-               debug_print("src encoding = %s, out encoding = %s, transfer encoding = %s\n",
-                           src_codeset, out_codeset, procmime_get_encoding_str(encoding));
-
-               if (action == COMPOSE_WRITE_FOR_SEND) {
-                       codeconv_set_strict(TRUE);
-                       buf = conv_codeset_strdup(chars, src_codeset, out_codeset);
-                       codeconv_set_strict(FALSE);
-
-                       if (!buf) {
-                               AlertValue aval;
-                               gchar *msg;
+       debug_print("src encoding = %s, out encoding = %s, transfer encoding = %s\n",
+                   src_codeset, out_codeset, procmime_get_encoding_str(encoding));
 
-                               msg = g_strdup_printf(_("Can't convert the character encoding of the message \n"
-                                                       "to the specified %s charset.\n"
-                                                       "Send it as %s?"), out_codeset, src_codeset);
-                               aval = alertpanel_full(_("Error"), msg, GTK_STOCK_CANCEL, _("+_Send"), NULL, FALSE,
-                                                     NULL, ALERT_ERROR, G_ALERTDEFAULT);
-                               g_free(msg);
+       if (action == COMPOSE_WRITE_FOR_SEND) {
+               codeconv_set_strict(TRUE);
+               buf = conv_codeset_strdup(chars, src_codeset, out_codeset);
+               codeconv_set_strict(FALSE);
 
-                               if (aval != G_ALERTALTERNATE) {
-                                       g_free(chars);
-                                       return -3;
-                               } else {
-                                       buf = chars;
-                                       out_codeset = src_codeset;
-                                       chars = NULL;
-                               }
+               if (!buf) {
+                       AlertValue aval;
+                       gchar *msg;
+
+                       msg = g_strdup_printf(_("Can't convert the character encoding of the message \n"
+                                               "to the specified %s charset.\n"
+                                               "Send it as %s?"), out_codeset, src_codeset);
+                       aval = alertpanel_full(_("Error"), msg, GTK_STOCK_CANCEL, _("+_Send"), NULL, FALSE,
+                                             NULL, ALERT_ERROR, G_ALERTDEFAULT);
+                       g_free(msg);
+
+                       if (aval != G_ALERTALTERNATE) {
+                               g_free(chars);
+                               return -3;
+                       } else {
+                               buf = chars;
+                               out_codeset = src_codeset;
+                               chars = NULL;
                        }
-               } else {
-                       buf = chars;
-                       out_codeset = src_codeset;
-                       chars = NULL;
                }
+       } else {
+               buf = chars;
+               out_codeset = src_codeset;
+               chars = NULL;
        }
        g_free(chars);
 
@@ -5159,7 +5381,7 @@ static gint compose_write_body_to_file(Compose *compose, const gchar *file)
                FILE_OP_ERROR(file, "fwrite");
                g_free(chars);
                fclose(fp);
-               g_unlink(file);
+               claws_unlink(file);
                return -1;
        }
 
@@ -5167,7 +5389,7 @@ static gint compose_write_body_to_file(Compose *compose, const gchar *file)
 
        if (fclose(fp) == EOF) {
                FILE_OP_ERROR(file, "fclose");
-               g_unlink(file);
+               claws_unlink(file);
                return -1;
        }
        return 0;
@@ -5370,7 +5592,7 @@ static gint compose_queue_sub(Compose *compose, gint *msgnum, FolderItem **item,
                        if (!compose_warn_encryption(compose)) {
                                lock = FALSE;
                                fclose(fp);
-                               g_unlink(tmp);
+                               claws_unlink(tmp);
                                g_free(tmp);
                                return -6;
                        }
@@ -5394,7 +5616,7 @@ static gint compose_queue_sub(Compose *compose, gint *msgnum, FolderItem **item,
                                 * key selection */
                                lock = FALSE;
                                fclose(fp);
-                               g_unlink(tmp);
+                               claws_unlink(tmp);
                                g_free(tmp);
                                return -5;
                        }
@@ -5438,7 +5660,7 @@ static gint compose_queue_sub(Compose *compose, gint *msgnum, FolderItem **item,
                if (compose_redirect_write_to_file(compose, fp) < 0) {
                        lock = FALSE;
                        fclose(fp);
-                       g_unlink(tmp);
+                       claws_unlink(tmp);
                        g_free(tmp);
                        return -2;
                }
@@ -5447,7 +5669,7 @@ static gint compose_queue_sub(Compose *compose, gint *msgnum, FolderItem **item,
                if ((result = compose_write_to_file(compose, fp, COMPOSE_WRITE_FOR_SEND, TRUE)) < 0) {
                        lock = FALSE;
                        fclose(fp);
-                       g_unlink(tmp);
+                       claws_unlink(tmp);
                        g_free(tmp);
                        return result - 1; /* -2 for a generic error, -3 for signing error, -4 for encoding */
                }
@@ -5455,14 +5677,14 @@ static gint compose_queue_sub(Compose *compose, gint *msgnum, FolderItem **item,
        if (err == TRUE) {
                g_warning("failed to write queue message\n");
                fclose(fp);
-               g_unlink(tmp);
+               claws_unlink(tmp);
                g_free(tmp);
                lock = FALSE;
                return -2;
        }
        if (fclose(fp) == EOF) {
                FILE_OP_ERROR(tmp, "fclose");
-               g_unlink(tmp);
+               claws_unlink(tmp);
                g_free(tmp);
                lock = FALSE;
                return -2;
@@ -5475,7 +5697,7 @@ static gint compose_queue_sub(Compose *compose, gint *msgnum, FolderItem **item,
        }
        if (!queue) {
                g_warning("can't find queue folder\n");
-               g_unlink(tmp);
+               claws_unlink(tmp);
                g_free(tmp);
                lock = FALSE;
                return -1;
@@ -5483,14 +5705,14 @@ static gint compose_queue_sub(Compose *compose, gint *msgnum, FolderItem **item,
        folder_item_scan(queue);
        if ((num = folder_item_add_msg(queue, tmp, NULL, FALSE)) < 0) {
                g_warning("can't queue the message\n");
-               g_unlink(tmp);
+               claws_unlink(tmp);
                g_free(tmp);
                lock = FALSE;
                return -1;
        }
        
        if (msgpath == NULL) {
-               g_unlink(tmp);
+               claws_unlink(tmp);
                g_free(tmp);
        } else
                *msgpath = tmp;
@@ -5738,9 +5960,14 @@ static gchar *compose_get_header(Compose *compose)
        } else {
                g_snprintf(buf, sizeof(buf), "%s", "");
        }
-       generate_msgid(buf, sizeof(buf));
-       g_string_append_printf(header, "Message-ID: <%s>\n", buf);
-       compose->msgid = g_strdup(buf);
+       
+       if (compose->account->gen_msgid) {
+               generate_msgid(buf, sizeof(buf));
+               g_string_append_printf(header, "Message-ID: <%s>\n", buf);
+               compose->msgid = g_strdup(buf);
+       } else {
+               compose->msgid = NULL;
+       }
 
        if (compose->remove_references == FALSE) {
                /* In-Reply-To */
@@ -5801,6 +6028,20 @@ static gchar *compose_get_header(Compose *compose)
                }
        }
 
+       /* Automatic Faces and X-Faces */
+       if (get_account_xface (buf, sizeof(buf), compose->account->account_name) == 0) {
+               g_string_append_printf(header, "X-Face: %s\n", buf);
+       }
+       else if (get_default_xface (buf, sizeof(buf)) == 0) {
+               g_string_append_printf(header, "X-Face: %s\n", buf);
+       }
+       if (get_account_face (buf, sizeof(buf), compose->account->account_name) == 0) {
+               g_string_append_printf(header, "Face: %s\n", buf);
+       }
+       else if (get_default_face (buf, sizeof(buf)) == 0) {
+               g_string_append_printf(header, "Face: %s\n", buf);
+       }
+
        /* PRIORITY */
        switch (compose->priority) {
                case PRIORITY_HIGHEST: g_string_append_printf(header, "Importance: high\n"
@@ -5847,9 +6088,10 @@ static gchar *compose_get_header(Compose *compose)
                gboolean standard_header = FALSE;
 
                headerentry = ((ComposeHeaderEntry *)list->data);
-               
+
                tmp = g_strdup(gtk_entry_get_text(GTK_ENTRY(GTK_BIN(headerentry->combo)->child)));
-               if (strchr(tmp, ' ') != NULL || strchr(tmp, '\r') != NULL || strchr(tmp, '\n') != NULL) {
+               g_strstrip(tmp);
+               if (*tmp == '\0' || strchr(tmp, ' ') != NULL || strchr(tmp, '\r') != NULL || strchr(tmp, '\n') != NULL) {
                        g_free(tmp);
                        continue;
                }
@@ -5963,7 +6205,7 @@ static void compose_add_to_addressbook_cb(GtkMenuItem *menuitem, gpointer user_d
        if (*address != '\0') {
                gchar *name = procheader_get_fromname(address);
                extract_address(address);
-               addressbook_add_contact(name, address, NULL);
+               addressbook_add_contact(name, address, NULL, NULL);
        }
        g_free(address);
 }
@@ -6326,7 +6568,7 @@ static void compose_savemsg_select_cb(GtkWidget *widget, Compose *compose)
        FolderItem *dest;
        gchar * path;
 
-       dest = foldersel_folder_sel(NULL, FOLDER_SEL_COPY, NULL);
+       dest = foldersel_folder_sel(NULL, FOLDER_SEL_COPY, NULL, FALSE);
        if (!dest) return;
 
        path = folder_item_get_identifier(dest);
@@ -6343,7 +6585,7 @@ static gboolean text_clicked(GtkWidget *text, GdkEventButton *event,
                                        Compose *compose)
 {
        gint prev_autowrap;
-       GtkTextBuffer *buffer;
+       GtkTextBuffer *buffer = GTK_TEXT_VIEW(text)->buffer;
 #if USE_ASPELL
        if (event->button == 3) {
                GtkTextIter iter;
@@ -6352,21 +6594,26 @@ static gboolean text_clicked(GtkWidget *text, GdkEventButton *event,
                gint x, y;
                /* move the cursor to allow GtkAspell to check the word
                 * under the mouse */
-               gtk_text_view_window_to_buffer_coords(GTK_TEXT_VIEW(text),
-                       GTK_TEXT_WINDOW_TEXT, event->x, event->y,
-                       &x, &y);
-               gtk_text_view_get_iter_at_location (GTK_TEXT_VIEW(text),
-                       &iter, x, y);
+               if (event->x && event->y) {
+                       gtk_text_view_window_to_buffer_coords(GTK_TEXT_VIEW(text),
+                               GTK_TEXT_WINDOW_TEXT, event->x, event->y,
+                               &x, &y);
+                       gtk_text_view_get_iter_at_location (GTK_TEXT_VIEW(text),
+                               &iter, x, y);
+               } else {
+                       GtkTextMark *mark = gtk_text_buffer_get_insert(buffer);
+                       gtk_text_buffer_get_iter_at_mark(buffer, &iter, mark);
+               }
                /* get selection */
                stuff_selected = gtk_text_buffer_get_selection_bounds(
-                               GTK_TEXT_VIEW(text)->buffer,
+                               buffer,
                                &sel_start, &sel_end);
 
-               gtk_text_buffer_place_cursor (GTK_TEXT_VIEW(text)->buffer, &iter);
+               gtk_text_buffer_place_cursor (buffer, &iter);
                /* reselect stuff */
                if (stuff_selected 
                && gtk_text_iter_in_range(&iter, &sel_start, &sel_end)) {
-                       gtk_text_buffer_select_range(GTK_TEXT_VIEW(text)->buffer,
+                       gtk_text_buffer_select_range(buffer,
                                &sel_start, &sel_end);
                }
                return FALSE; /* pass the event so that the right-click goes through */
@@ -6442,6 +6689,8 @@ static gboolean compose_popup_menu(GtkWidget *widget, gpointer data)
        
        event.button = 3;
        event.time = gtk_get_current_event_time();
+       event.x = 0;
+       event.y = 0;
 
        return text_clicked(compose->text, &event, compose);
 }
@@ -6535,7 +6784,7 @@ static Compose *compose_create(PrefsAccount *account,
        gtk_window_set_geometry_hints(GTK_WINDOW(window), NULL,
                                      &geometry, GDK_HINT_MIN_SIZE);
 
-#ifndef MAEMO  
+#ifndef GENERIC_UMPC   
        if (compose_force_window_origin)
                gtk_widget_set_uposition(window, prefs_common.compose_x, 
                                 prefs_common.compose_y);
@@ -7106,7 +7355,6 @@ static void compose_update_privacy_system_menu_item(Compose * compose, gboolean
 
        if (compose->privacy_system != NULL) {
                gchar *systemid;
-
                menuitem = gtk_item_factory_get_widget(ifactory, branch_path);
                g_return_if_fail(menuitem != NULL);
 
@@ -7417,6 +7665,7 @@ static void compose_template_apply(Compose *compose, Template *tmpl,
        /* process the other fields */
 
        compose_template_apply_fields(compose, tmpl);
+       compose_attach_from_list(compose, quote_fmt_get_attachments_list(), FALSE);
        quote_fmt_reset_vartable();
        compose_changed_cb(NULL, compose);
 }
@@ -7436,12 +7685,30 @@ static void compose_template_apply_fields(Compose *compose, Template *tmpl)
                msginfo = dummyinfo;
        }
 
+       if (tmpl->from && *tmpl->from != '\0') {
+#ifdef USE_ASPELL
+               quote_fmt_init(msginfo, NULL, NULL, FALSE, compose->account, FALSE,
+                               compose->gtkaspell);
+#else
+               quote_fmt_init(msginfo, NULL, NULL, FALSE, compose->account, FALSE);
+#endif
+               quote_fmt_scan_string(tmpl->from);
+               quote_fmt_parse();
+
+               buf = quote_fmt_get_buffer();
+               if (buf == NULL) {
+                       alertpanel_error(_("Template From format error."));
+               } else {
+                       gtk_entry_set_text(GTK_ENTRY(compose->from_name), buf);
+               }
+       }
+
        if (tmpl->to && *tmpl->to != '\0') {
 #ifdef USE_ASPELL
-               quote_fmt_init(msginfo, NULL, NULL, FALSE, compose->account,
+               quote_fmt_init(msginfo, NULL, NULL, FALSE, compose->account, FALSE,
                                compose->gtkaspell);
 #else
-               quote_fmt_init(msginfo, NULL, NULL, FALSE, compose->account);
+               quote_fmt_init(msginfo, NULL, NULL, FALSE, compose->account, FALSE);
 #endif
                quote_fmt_scan_string(tmpl->to);
                quote_fmt_parse();
@@ -7456,10 +7723,10 @@ static void compose_template_apply_fields(Compose *compose, Template *tmpl)
 
        if (tmpl->cc && *tmpl->cc != '\0') {
 #ifdef USE_ASPELL
-               quote_fmt_init(msginfo, NULL, NULL, FALSE, compose->account,
+               quote_fmt_init(msginfo, NULL, NULL, FALSE, compose->account, FALSE,
                                compose->gtkaspell);
 #else
-               quote_fmt_init(msginfo, NULL, NULL, FALSE, compose->account);
+               quote_fmt_init(msginfo, NULL, NULL, FALSE, compose->account, FALSE);
 #endif
                quote_fmt_scan_string(tmpl->cc);
                quote_fmt_parse();
@@ -7474,10 +7741,10 @@ static void compose_template_apply_fields(Compose *compose, Template *tmpl)
 
        if (tmpl->bcc && *tmpl->bcc != '\0') {
 #ifdef USE_ASPELL
-               quote_fmt_init(msginfo, NULL, NULL, FALSE, compose->account,
+               quote_fmt_init(msginfo, NULL, NULL, FALSE, compose->account, FALSE,
                                compose->gtkaspell);
 #else
-               quote_fmt_init(msginfo, NULL, NULL, FALSE, compose->account);
+               quote_fmt_init(msginfo, NULL, NULL, FALSE, compose->account, FALSE);
 #endif
                quote_fmt_scan_string(tmpl->bcc);
                quote_fmt_parse();
@@ -7493,10 +7760,10 @@ static void compose_template_apply_fields(Compose *compose, Template *tmpl)
        /* process the subject */
        if (tmpl->subject && *tmpl->subject != '\0') {
 #ifdef USE_ASPELL
-               quote_fmt_init(msginfo, NULL, NULL, FALSE, compose->account,
+               quote_fmt_init(msginfo, NULL, NULL, FALSE, compose->account, FALSE,
                                compose->gtkaspell);
 #else
-               quote_fmt_init(msginfo, NULL, NULL, FALSE, compose->account);
+               quote_fmt_init(msginfo, NULL, NULL, FALSE, compose->account, FALSE);
 #endif
                quote_fmt_scan_string(tmpl->subject);
                quote_fmt_parse();
@@ -7788,7 +8055,7 @@ static void compose_attach_property(Compose *compose)
                        ainfo->file = file;
                }
                if (size)
-                       ainfo->size = size;
+                       ainfo->size = (goffset)size;
 
                /* update tree store */
                text = to_human_readable(ainfo->size);
@@ -8063,14 +8330,14 @@ static gint compose_exec_ext_editor_real(const gchar *file)
        if (setpgid(0, getppid()))
                perror("setpgid");
 
-       if (prefs_common.ext_editor_cmd &&
-           (p = strchr(prefs_common.ext_editor_cmd, '%')) &&
+       if (prefs_common_get_ext_editor_cmd() &&
+           (p = strchr(prefs_common_get_ext_editor_cmd(), '%')) &&
            *(p + 1) == 's' && !strchr(p + 2, '%')) {
-               g_snprintf(buf, sizeof(buf), prefs_common.ext_editor_cmd, file);
+               g_snprintf(buf, sizeof(buf), prefs_common_get_ext_editor_cmd(), file);
        } else {
-               if (prefs_common.ext_editor_cmd)
+               if (prefs_common_get_ext_editor_cmd())
                        g_warning("External editor command line is invalid: '%s'\n",
-                                 prefs_common.ext_editor_cmd);
+                                 prefs_common_get_ext_editor_cmd());
                g_snprintf(buf, sizeof(buf), DEFAULT_EDITOR_CMD, file);
        }
 
@@ -8154,11 +8421,11 @@ static gboolean compose_input_cb(GIOChannel *source, GIOCondition condition,
                compose_insert_file(compose, compose->exteditor_file);
                compose_changed_cb(NULL, compose);
 
-               if (g_unlink(compose->exteditor_file) < 0)
+               if (claws_unlink(compose->exteditor_file) < 0)
                        FILE_OP_ERROR(compose->exteditor_file, "unlink");
        } else if (buf[0] == '1') {     /* failed */
                g_warning("Couldn't exec external editor\n");
-               if (g_unlink(compose->exteditor_file) < 0)
+               if (claws_unlink(compose->exteditor_file) < 0)
                        FILE_OP_ERROR(compose->exteditor_file, "unlink");
        } else if (buf[0] == '2') {
                g_warning("Couldn't write to file\n");
@@ -8601,7 +8868,7 @@ gboolean compose_draft (gpointer data, guint action)
        }
        if (msgnum < 0) {
 warn_err:
-               g_unlink(tmp);
+               claws_unlink(tmp);
                g_free(tmp);
                if (action != COMPOSE_AUTO_SAVE) {
                        if (action != COMPOSE_DRAFT_FOR_EXIT)
@@ -8678,7 +8945,7 @@ warn_err:
                procmsg_msginfo_free(compose->targetinfo);
                compose->targetinfo = procmsg_msginfo_new();
                compose->targetinfo->msgnum = msgnum;
-               compose->targetinfo->size = s.st_size;
+               compose->targetinfo->size = (goffset)s.st_size;
                compose->targetinfo->mtime = s.st_mtime;
                compose->targetinfo->folder = draft;
                if (target_locked)
@@ -8702,7 +8969,7 @@ void compose_clear_exit_drafts(void)
        gchar *filepath = g_strconcat(get_rc_dir(), G_DIR_SEPARATOR_S,
                                      DRAFTED_AT_EXIT, NULL);
        if (is_file_exist(filepath))
-               g_unlink(filepath);
+               claws_unlink(filepath);
        
        g_free(filepath);
 }
@@ -8739,17 +9006,9 @@ static void compose_draft_cb(gpointer data, guint action, GtkWidget *widget)
        compose_draft(data, action);
 }
 
-static void compose_attach_cb(gpointer data, guint action, GtkWidget *widget)
+static void compose_attach_from_list(Compose *compose, GList *file_list, gboolean free_data)
 {
-       Compose *compose = (Compose *)data;
-       GList *file_list;
-
-       if (compose->redirect_filename != NULL)
-               return;
-
-       file_list = filesel_select_multiple_files_open(_("Select file"));
-
-       if (file_list) {
+       if (compose && file_list) {
                GList *tmp;
 
                for ( tmp = file_list; tmp; tmp = tmp->next) {
@@ -8757,13 +9016,29 @@ static void compose_attach_cb(gpointer data, guint action, GtkWidget *widget)
                        gchar *utf8_filename = conv_filename_to_utf8(file);
                        compose_attach_append(compose, file, utf8_filename, NULL);
                        compose_changed_cb(NULL, compose);
+                       if (free_data) {
                        g_free(file);
+                               tmp->data = NULL;
+                       }
                        g_free(utf8_filename);
                }
+       }
+}
+
+static void compose_attach_cb(gpointer data, guint action, GtkWidget *widget)
+{
+       Compose *compose = (Compose *)data;
+       GList *file_list;
+
+       if (compose->redirect_filename != NULL)
+               return;
+
+       file_list = filesel_select_multiple_files_open(_("Select file"));
+
+       if (file_list) {
+               compose_attach_from_list(compose, file_list, TRUE);
                g_list_free(file_list);
        }
-       
-       compose_attach_update_label(compose);           
 }
 
 static void compose_insert_file_cb(gpointer data, guint action,
@@ -8840,10 +9115,18 @@ static void compose_close_cb(gpointer data, guint action, GtkWidget *widget)
 #endif
 
        if (compose->modified) {
+               if (!g_mutex_trylock(compose->mutex)) {
+                       /* we don't want to lock the mutex once it's available,
+                        * because as the only other part of compose.c locking
+                        * it is compose_close - which means once unlocked,
+                        * the compose struct will be freed */
+                       debug_print("couldn't lock mutex, probably sending\n");
+                       return;
+               }
                val = alertpanel(_("Discard message"),
                                 _("This message has been modified. Discard it?"),
                                 _("_Discard"), _("_Save to Drafts"), GTK_STOCK_CANCEL);
-
+               g_mutex_unlock(compose->mutex);
                switch (val) {
                case G_ALERTDEFAULT:
                        if (prefs_common.autosave)
@@ -8994,7 +9277,8 @@ static void entry_paste_clipboard(Compose *compose, GtkWidget *entry,
                }
        } else if (GTK_IS_EDITABLE(entry))
                gtk_editable_paste_clipboard (GTK_EDITABLE(entry));
-       
+
+       compose->modified = TRUE;
 }
 
 static void entry_allsel(GtkWidget *entry)
@@ -9019,7 +9303,7 @@ static void entry_allsel(GtkWidget *entry)
 static void compose_cut_cb(Compose *compose)
 {
        if (compose->focused_editable 
-#ifndef MAEMO
+#ifndef GENERIC_UMPC
            && GTK_WIDGET_HAS_FOCUS(compose->focused_editable)
 #endif
            )
@@ -9029,7 +9313,7 @@ static void compose_cut_cb(Compose *compose)
 static void compose_copy_cb(Compose *compose)
 {
        if (compose->focused_editable 
-#ifndef MAEMO
+#ifndef GENERIC_UMPC
            && GTK_WIDGET_HAS_FOCUS(compose->focused_editable)
 #endif
            )
@@ -9053,7 +9337,7 @@ static void compose_paste_as_quote_cb(Compose *compose)
 {
        gint wrap_quote = prefs_common.linewrap_quote;
        if (compose->focused_editable 
-#ifndef MAEMO
+#ifndef GENERIC_UMPC
            && GTK_WIDGET_HAS_FOCUS(compose->focused_editable)
 #endif
            ) {
@@ -9081,7 +9365,7 @@ static void compose_paste_no_wrap_cb(Compose *compose)
        GtkTextBuffer *buffer;
        BLOCK_WRAP();
        if (compose->focused_editable 
-#ifndef MAEMO
+#ifndef GENERIC_UMPC
            && GTK_WIDGET_HAS_FOCUS(compose->focused_editable)
 #endif
            )
@@ -9096,7 +9380,7 @@ static void compose_paste_wrap_cb(Compose *compose)
        GtkTextBuffer *buffer;
        BLOCK_WRAP();
        if (compose->focused_editable 
-#ifndef MAEMO
+#ifndef GENERIC_UMPC
            && GTK_WIDGET_HAS_FOCUS(compose->focused_editable)
 #endif
            )
@@ -9108,7 +9392,7 @@ static void compose_paste_wrap_cb(Compose *compose)
 static void compose_allsel_cb(Compose *compose)
 {
        if (compose->focused_editable 
-#ifndef MAEMO
+#ifndef GENERIC_UMPC
            && GTK_WIDGET_HAS_FOCUS(compose->focused_editable)
 #endif
            )
@@ -9322,7 +9606,6 @@ static void textview_delete_line (GtkTextView *text)
        GtkTextBuffer *buffer;
        GtkTextMark *mark;
        GtkTextIter ins, start_iter, end_iter;
-       gboolean found;
 
        g_return_if_fail(GTK_IS_TEXT_VIEW(text));
 
@@ -9334,13 +9617,13 @@ static void textview_delete_line (GtkTextView *text)
        gtk_text_iter_set_line_offset(&start_iter, 0);
 
        end_iter = ins;
-       if (gtk_text_iter_ends_line(&end_iter))
-               found = gtk_text_iter_forward_char(&end_iter);
-       else
-               found = gtk_text_iter_forward_to_line_end(&end_iter);
-
-       if (found)
-               gtk_text_buffer_delete(buffer, &start_iter, &end_iter);
+       if (gtk_text_iter_ends_line(&end_iter)){
+               if (!gtk_text_iter_forward_char(&end_iter))
+                       gtk_text_iter_backward_char(&start_iter);
+       }
+       else 
+               gtk_text_iter_forward_to_line_end(&end_iter);
+       gtk_text_buffer_delete(buffer, &start_iter, &end_iter);
 }
 
 static void textview_delete_to_line_end (GtkTextView *text)
@@ -9348,7 +9631,6 @@ static void textview_delete_to_line_end (GtkTextView *text)
        GtkTextBuffer *buffer;
        GtkTextMark *mark;
        GtkTextIter ins, end_iter;
-       gboolean found;
 
        g_return_if_fail(GTK_IS_TEXT_VIEW(text));
 
@@ -9357,11 +9639,10 @@ static void textview_delete_to_line_end (GtkTextView *text)
        gtk_text_buffer_get_iter_at_mark(buffer, &ins, mark);
        end_iter = ins;
        if (gtk_text_iter_ends_line(&end_iter))
-               found = gtk_text_iter_forward_char(&end_iter);
+               gtk_text_iter_forward_char(&end_iter);
        else
-               found = gtk_text_iter_forward_to_line_end(&end_iter);
-       if (found)
-               gtk_text_buffer_delete(buffer, &ins, &end_iter);
+               gtk_text_iter_forward_to_line_end(&end_iter);
+       gtk_text_buffer_delete(buffer, &ins, &end_iter);
 }
 
 static void compose_advanced_action_cb(Compose *compose,
@@ -9384,7 +9665,6 @@ static void compose_advanced_action_cb(Compose *compose,
                {textview_delete_forward_word},
                {textview_delete_backward_word},
                {textview_delete_line},
-               {NULL}, /* gtk_stext_delete_line_n */
                {textview_delete_to_line_end}
        };
 
@@ -9435,7 +9715,7 @@ static void compose_grab_focus_cb(GtkWidget *widget, Compose *compose)
        if (GTK_IS_EDITABLE(widget) || GTK_IS_TEXT_VIEW(widget))
                compose->focused_editable = widget;
        
-#ifdef MAEMO
+#ifdef GENERIC_UMPC
        if (GTK_IS_TEXT_VIEW(widget) 
            && gtk_paned_get_child1(GTK_PANED(compose->paned)) != compose->edit_vbox) {
                gtk_widget_ref(compose->notebook);
@@ -9477,7 +9757,7 @@ static void compose_grab_focus_cb(GtkWidget *widget, Compose *compose)
 static void compose_changed_cb(GtkTextBuffer *textbuf, Compose *compose)
 {
        compose->modified = TRUE;
-#ifndef MAEMO
+#ifndef GENERIC_UMPC
        compose_set_title(compose);
 #endif
 }
@@ -9636,6 +9916,21 @@ static void compose_insert_drag_received_cb (GtkWidget           *widget,
        if (gdk_atom_name(data->type) && !strcmp(gdk_atom_name(data->type), "text/uri-list")) {
                AlertValue val = G_ALERTDEFAULT;
 
+               list = uri_list_extract_filenames((const gchar *)data->data);
+
+               if (list == NULL && strstr((gchar *)(data->data), "://")) {
+                       /* Assume a list of no files, and data has ://, is a remote link */
+                       gchar *tmpdata = g_strstrip(g_strdup((const gchar *)data->data));
+                       gchar *tmpfile = get_tmp_file();
+                       str_write_to_file(tmpdata, tmpfile);
+                       g_free(tmpdata);  
+                       compose_insert_file(compose, tmpfile);
+                       claws_unlink(tmpfile);
+                       g_free(tmpfile);
+                       gtk_drag_finish(drag_context, TRUE, FALSE, time);
+                       compose_beautify_paragraph(compose, NULL, TRUE);
+                       return;
+               }
                switch (prefs_common.compose_dnd_mode) {
                        case COMPOSE_DND_ASK:
                                val = alertpanel_full(_("Insert or attach?"),
@@ -9666,12 +9961,16 @@ static void compose_insert_drag_received_cb (GtkWidget          *widget,
 
                if (val == G_ALERTDEFAULT || val == G_ALERTCANCEL) {
                        gtk_drag_finish(drag_context, FALSE, FALSE, time);
+                       list_free_strings(list);
+                       g_list_free(list);
                        return;
                } else if (val == G_ALERTOTHER) {
                        compose_attach_drag_received_cb(widget, drag_context, x, y, data, info, time, user_data);
+                       list_free_strings(list);
+                       g_list_free(list);
                        return;
                } 
-               list = uri_list_extract_filenames((const gchar *)data->data);
+
                for (tmp = list; tmp != NULL; tmp = tmp->next) {
                        compose_insert_file(compose, (const gchar *)tmp->data);
                }
@@ -9686,7 +9985,7 @@ static void compose_insert_drag_received_cb (GtkWidget            *widget,
                gchar *tmpfile = get_tmp_file();
                str_write_to_file((const gchar *)data->data, tmpfile);
                compose_insert_file(compose, tmpfile);
-               g_unlink(tmpfile);
+               claws_unlink(tmpfile);
                g_free(tmpfile);
                gtk_drag_finish(drag_context, TRUE, FALSE, time);
 #endif
@@ -9859,9 +10158,30 @@ static void text_inserted(GtkTextBuffer *buffer, GtkTextIter *iter,
                || gtk_text_iter_starts_line(iter))
                        gtk_text_buffer_insert(buffer, iter, text, len);
                else {
-                       debug_print("insert nowrap \\n\n");
-                       gtk_text_buffer_insert_with_tags_by_name(buffer, 
-                               iter, text, len, "no_join", NULL);
+                       /* check if the preceding is just whitespace or quote */
+                       GtkTextIter start_line;
+                       gchar *tmp = NULL, *quote = NULL;
+                       gint quote_len = 0, is_normal = 0;
+                       start_line = *iter;
+                       gtk_text_iter_set_line_offset(&start_line, 0); 
+                       tmp = gtk_text_buffer_get_text(buffer, &start_line, iter, FALSE);
+                       g_strstrip(tmp);
+                       if (*tmp == '\0') {
+                               is_normal = 1;
+                       } else {
+                               quote = compose_get_quote_str(buffer, &start_line, &quote_len);
+                               if (quote)
+                                       is_normal = 1;
+                               g_free(quote);
+                       }
+                       g_free(tmp);
+                       
+                       if (is_normal) {
+                               gtk_text_buffer_insert(buffer, iter, text, len);
+                       } else {
+                               gtk_text_buffer_insert_with_tags_by_name(buffer, 
+                                       iter, text, len, "no_join", NULL);
+                       }
                }
        }
        
@@ -9950,7 +10270,7 @@ static PrefsAccount *compose_guess_forward_account_from_msginfo(MsgInfo *msginfo
                gchar *to;
                Xstrdup_a(to, msginfo->to, return NULL);
                extract_address(to);
-               account = account_find_from_address(to);
+               account = account_find_from_address(to, FALSE);
        }
 
        if (!account && prefs_common.forward_account_autosel) {
@@ -9959,7 +10279,7 @@ static PrefsAccount *compose_guess_forward_account_from_msginfo(MsgInfo *msginfo
                        (msginfo, cc,sizeof cc , "Cc:")) { 
                        gchar *buf = cc + strlen("Cc:");
                        extract_address(buf);
-                       account = account_find_from_address(buf);
+                       account = account_find_from_address(buf, FALSE);
                 }
        }
        
@@ -9969,7 +10289,7 @@ static PrefsAccount *compose_guess_forward_account_from_msginfo(MsgInfo *msginfo
                        (msginfo, deliveredto,sizeof deliveredto , "Delivered-To:")) { 
                        gchar *buf = deliveredto + strlen("Delivered-To:");
                        extract_address(buf);
-                       account = account_find_from_address(buf);
+                       account = account_find_from_address(buf, FALSE);
                 }
        }