Steps to reproduce:
- subscribe to one or more forums
- create some posts (new threads and replies)
- read received mails in Thunderbird/Icedove 3
- "View" - "Sort by" - "Threaded"
Thunderbird chooses one mail as root node (apparently the oldest forum post that is not a reply) and arranges other mails as replies below this single mail. For mailboxes with a lot of (moodle-)mails Thunderbird needs unusual long time for reordering the list. Mails for posts that are starting a new thread (thus are no replies) contain header fields like: In-Reply-To: <moodlepost0@...> and References: <moodlepost0@...>. That means all mails of thread-initiating posts are referencing the same message ID (that doesn't exist).
- Thunderbird's thread view of messages should represent the thread structure of the forum.
- Mails for posts that start a new thread should not contain In-Reply-To or References headers since they are no replies or references.
- moodle/mod/forum/lib.php (at $userfrom->customheaders = ...) : only append In-Reply-To and References headers if the current post is a reply ($post->parent != 0)
Although the behaviour of Thunderbird does not seem very reasonable to me, it would probably be better not to mark non-replies as replies.