From 73a8781b8463557a0ddabe7b1beb0507a4d2beca Mon Sep 17 00:00:00 2001 From: Paul Date: Thu, 27 Mar 2014 16:16:32 +0000 Subject: [PATCH] when using Redirect, use the redirecting account's address in the SMTP MAIL FROM --- src/procheader.c | 8 ++++++++ src/procmsg.c | 7 +++++++ src/procmsg.h | 2 ++ src/send_message.c | 9 ++++++--- 4 files changed, 23 insertions(+), 3 deletions(-) diff --git a/src/procheader.c b/src/procheader.c index 4b7ff05ff..40f026083 100644 --- a/src/procheader.c +++ b/src/procheader.c @@ -401,6 +401,7 @@ enum H_LIST_HELP = 26, H_LIST_ARCHIVE = 27, H_LIST_OWNER = 28, + H_RESENT_FROM = 29, }; static HeaderEntry hentry_full[] = {{"Date:", NULL, FALSE}, @@ -432,6 +433,7 @@ static HeaderEntry hentry_full[] = {{"Date:", NULL, FALSE}, {"List-Help:", NULL, TRUE}, {"List-Archive:", NULL, TRUE}, {"List-Owner:", NULL, TRUE}, + {"Resent-From:", NULL, TRUE}, {NULL, NULL, FALSE}}; static HeaderEntry hentry_short[] = {{"Date:", NULL, FALSE}, @@ -745,6 +747,12 @@ static MsgInfo *parse_stream(void *data, gboolean isstring, MsgFlags flags, if (msginfo->extradata->list_owner) break; msginfo->extradata->list_owner = g_strdup(hp); break; + case H_RESENT_FROM: + if (!msginfo->extradata) + msginfo->extradata = g_new0(MsgInfoExtraData, 1); + if (msginfo->extradata->resent_from) break; + msginfo->extradata->resent_from = g_strdup(hp); + break; /* end list infos */ default: break; diff --git a/src/procmsg.c b/src/procmsg.c index 767fe64ab..cc10712c9 100644 --- a/src/procmsg.c +++ b/src/procmsg.c @@ -1352,6 +1352,7 @@ MsgInfo *procmsg_msginfo_copy(MsgInfo *msginfo) MEMBDUP(extradata->list_help); MEMBDUP(extradata->list_archive); MEMBDUP(extradata->list_owner); + MEMBDUP(extradata->resent_from); } refs = msginfo->references; @@ -1417,6 +1418,9 @@ MsgInfo *procmsg_msginfo_get_full_info_from_file(MsgInfo *msginfo, const gchar * if (!msginfo->extradata->account_login && full_msginfo->extradata->account_login) msginfo->extradata->account_login = g_strdup (full_msginfo->extradata->account_login); + if (!msginfo->extradata->resent_from && full_msginfo->extradata->resent_from) + msginfo->extradata->resent_from = g_strdup + (full_msginfo->extradata->resent_from); } procmsg_msginfo_free(full_msginfo); @@ -1490,6 +1494,7 @@ void procmsg_msginfo_free(MsgInfo *msginfo) g_free(msginfo->extradata->partial_recv); g_free(msginfo->extradata->account_server); g_free(msginfo->extradata->account_login); + g_free(msginfo->extradata->resent_from); g_free(msginfo->extradata); } slist_free_strings_full(msginfo->references); @@ -1555,6 +1560,8 @@ guint procmsg_msginfo_memusage(MsgInfo *msginfo) memusage += strlen(msginfo->extradata->account_server); if (msginfo->extradata->account_login) memusage += strlen(msginfo->extradata->account_login); + if (msginfo->extradata->resent_from) + memusage += strlen(msginfo->extradata->resent_from); if (msginfo->extradata->list_post) memusage += strlen(msginfo->extradata->list_post); diff --git a/src/procmsg.h b/src/procmsg.h index 52b04c065..23ebe85f3 100644 --- a/src/procmsg.h +++ b/src/procmsg.h @@ -244,6 +244,8 @@ struct _MsgInfoExtraData gchar *dispositionnotificationto; gchar *returnreceiptto; + gchar *resent_from; + /* used only for partially received messages */ gchar *partial_recv; gchar *account_server; diff --git a/src/send_message.c b/src/send_message.c index 3cf820410..d51994d06 100644 --- a/src/send_message.c +++ b/src/send_message.c @@ -231,10 +231,13 @@ gint send_message_smtp_full(PrefsAccount *ac_prefs, GSList *to_list, FILE *fp, g * because it's editable. */ fp_pos = ftell(fp); - tmp_msginfo = procheader_parse_stream(fp, flags, FALSE, FALSE); + tmp_msginfo = procheader_parse_stream(fp, flags, TRUE, FALSE); fseek(fp, fp_pos, SEEK_SET); - - if (tmp_msginfo && tmp_msginfo->from) { + + if (tmp_msginfo && tmp_msginfo->extradata && tmp_msginfo->extradata->resent_from) { + strncpy2(spec_from, tmp_msginfo->extradata->resent_from, BUFFSIZE-1); + extract_address(spec_from); + } else if (tmp_msginfo && tmp_msginfo->from) { strncpy2(spec_from, tmp_msginfo->from, BUFFSIZE-1); extract_address(spec_from); } else {