diff --git a/messagecomposer/autotests/replystrategytest.cpp b/messagecomposer/autotests/replystrategytest.cpp --- a/messagecomposer/autotests/replystrategytest.cpp +++ b/messagecomposer/autotests/replystrategytest.cpp @@ -191,6 +191,10 @@ << defaultAddress << only(friend1Address) << only(friend2Address) << nobody << nobody << QString() << (int)ReplySmart << defaultAddress << only(friend1Address) << nobody; + QTest::newRow("ReplySmart, from default identity with Reply-To to someone") + << defaultAddress << only(friend1Address) << only(friend2Address) + << only(replyAddress) << nobody << QString() + << (int)ReplySmart << defaultAddress << only(friend1Address) << nobody; // If the original message was from one of the user's identities to another // identity (i.e., between two of the user's mail accounts), a smart reply @@ -200,13 +204,17 @@ << nobody << nobody << QString() << (int)ReplySmart << nondefaultAddress << only(defaultAddress) << nobody; - // Smart replies prefer the Mail-Followup-To address to Reply-To or List-Post. + // If the original message appears to be from a mailing list, smart replies + // go to the Mail-Followup-To, Reply-To, or List-Post addresses, in that + // order of preference. QTest::newRow("ReplySmart, from list with Mail-Followup-To") << friend1Address << only(defaultAddress) << only(friend2Address) << only(replyAddress) << only(followupAddress) << listAddress << (int)ReplySmart << defaultAddress << only(followupAddress) << nobody; - - // In the absence of Mail-Followup-To, smart replies prefer List-Post to From. + QTest::newRow("ReplySmart, from list with Reply-To") + << friend1Address << only(defaultAddress) << only(friend2Address) + << only(replyAddress) << nobody << listAddress + << (int)ReplySmart << defaultAddress << only(replyAddress) << nobody; QTest::newRow("ReplySmart, from list with List-Post") << friend1Address << only(nondefaultAddress) << only(friend2Address) << nobody << nobody << listAddress diff --git a/messagecomposer/src/helper/messagefactoryng.cpp b/messagecomposer/src/helper/messagefactoryng.cpp --- a/messagecomposer/src/helper/messagefactoryng.cpp +++ b/messagecomposer/src/helper/messagefactoryng.cpp @@ -147,14 +147,12 @@ { if (auto hdr = m_origMsg->headerByType("Mail-Followup-To")) { toList << KMime::Types::Mailbox::listFrom7BitString(hdr->as7BitString(false)); - } else if (!replyToList.isEmpty()) { - toList = replyToList; - // use the ReplyAll template only when it's a reply to a mailing list - if (m_mailingListAddresses.isEmpty()) { - replyAll = false; - } } else if (!m_mailingListAddresses.isEmpty()) { - toList = (KMime::Types::Mailbox::List() << m_mailingListAddresses.at(0)); + if (replyToList.isEmpty()) { + toList = (KMime::Types::Mailbox::List() << m_mailingListAddresses.at(0)); + } else { + toList = replyToList; + } } else { // Doesn't seem to be a mailing list. auto originalFromList = m_origMsg->from()->mailboxes(); @@ -169,7 +167,11 @@ toList = originalToList; } else { // "Normal" case: reply to sender. - toList = originalFromList; + if (replyToList.isEmpty()) { + toList = originalFromList; + } else { + toList = replyToList; + } } replyAll = false;