diff --git a/mailnews/compose/src/nsMsgCompose.cpp b/mailnews/compose/src/nsMsgCompose.cpp index 55a18b9e154..64232103273 100644 --- a/mailnews/compose/src/nsMsgCompose.cpp +++ b/mailnews/compose/src/nsMsgCompose.cpp @@ -2035,6 +2035,8 @@ NS_IMETHODIMP QuotingOutputStreamListener::OnStopRequest(nsIRequest *request, ns nsAutoString recipient; nsAutoString cc; nsAutoString replyTo; + nsAutoString mailReplyTo; + nsAutoString mailFollowupTo; nsAutoString newgroups; nsAutoString followUpTo; nsAutoString messageId; @@ -2063,10 +2065,23 @@ NS_IMETHODIMP QuotingOutputStreamListener::OnStopRequest(nsIRequest *request, ns mMimeConverter->DecodeMimeHeader(outCString, cc, charset); } - if (recipient.Length() > 0 && cc.Length() > 0) - recipient.AppendLiteral(", "); - recipient += cc; - compFields->SetCc(recipient); + mHeaders->ExtractHeader(HEADER_MAIL_FOLLOWUP_TO, PR_TRUE, getter_Copies(outCString)); + if (outCString) + { + mMimeConverter->DecodeMimeHeader(outCString, mailFollowupTo, charset); + } + + if (! mailFollowupTo.IsEmpty()) + { // handle Mail-Followup-To (http://cr.yp.to/proto/replyto.html) + compFields->SetTo(mailFollowupTo); + } + else + { // default behaviour for messages without Mail-Followup-To + if (recipient.Length() > 0 && cc.Length() > 0) + recipient.AppendLiteral(", "); + recipient += cc; + compFields->SetCc(recipient); + } needToRemoveDup = PR_TRUE; } @@ -2077,6 +2092,12 @@ NS_IMETHODIMP QuotingOutputStreamListener::OnStopRequest(nsIRequest *request, ns mMimeConverter->DecodeMimeHeader(outCString, replyTo, charset); } + mHeaders->ExtractHeader(HEADER_MAIL_REPLY_TO, PR_TRUE, getter_Copies(outCString)); + if (outCString) + { + mMimeConverter->DecodeMimeHeader(outCString, mailReplyTo, charset); + } + mHeaders->ExtractHeader(HEADER_NEWSGROUPS, PR_FALSE, getter_Copies(outCString)); if (outCString) { @@ -2101,10 +2122,18 @@ NS_IMETHODIMP QuotingOutputStreamListener::OnStopRequest(nsIRequest *request, ns mMimeConverter->DecodeMimeHeader(outCString, references, charset); } - if (! replyTo.IsEmpty()) + if (! ((type == nsIMsgCompType::ReplyAll) && ! mailFollowupTo.IsEmpty())) { - compFields->SetTo(replyTo); - needToRemoveDup = PR_TRUE; + if (! mailReplyTo.IsEmpty()) + { // handle Mail-Reply-To (http://cr.yp.to/proto/replyto.html) + compFields->SetTo(mailReplyTo); + needToRemoveDup = PR_TRUE; + } + else if (! replyTo.IsEmpty()) + { // default behaviour for messages without Mail-Reply-To + compFields->SetTo(replyTo); + needToRemoveDup = PR_TRUE; + } } if (! newgroups.IsEmpty()) diff --git a/mailnews/mime/public/nsMailHeaders.h b/mailnews/mime/public/nsMailHeaders.h index 0b889e6623a..9c494922b7a 100644 --- a/mailnews/mime/public/nsMailHeaders.h +++ b/mailnews/mime/public/nsMailHeaders.h @@ -65,6 +65,8 @@ #define HEADER_FROM "From" #define HEADER_STATUS "Status" #define HEADER_LINES "Lines" +#define HEADER_MAIL_FOLLOWUP_TO "Mail-Followup-To" +#define HEADER_MAIL_REPLY_TO "Mail-Reply-To" #define HEADER_MESSAGE_ID "Message-ID" #define HEADER_MIME_VERSION "MIME-Version" #define HEADER_NEWSGROUPS "Newsgroups"