Hi Mukarram,
Firstly my apologies for the delay in my reply. I had written a reply
yesterday morning, but inadvertently lost it, and I haven't had a chance to
re-write because of weekly integration.
So first things first, the replyto variable in the body is no longer used. It was originally used, but moved recently in MDL-48212. The replyto variable is passed to the message headers by way of the eventdata.
By passing this into the eventdata, it makes it's way to:
- lib/messagelib.php, where it is passed to:
- send_message and then to:
- \core\message\manager::send_message where it is passed to:
- anager::send_message_to_processors where it is passed to each message output processor, including:
- email where the variable is:
- picked up and then passed to:
- email_to_user: where it's eventually:
- added to the headers.
So with this information in mind, the first thing to check is whether the replyaddress variable is actually set. We can do this by adding some debugging to find out whether our $replyaddress variable was set by adding the following debugging just just after replyaddress is first set:
if ($userto->canpost[$discussion->id] && array_key_exists($post->id, $messageinboundhandlers)) {
$messageinboundgenerator->set_data($post->id, $messageinboundhandlers[$post->id]);
$replyaddress = $messageinboundgenerator->generate($userto->id);
}
mtrace("Setting the reply address for {$userto->id} / {$post->id} to {$replyaddress}");
var_dump($replyaddress);
$a = new stdClass();
If this reply address is not set, then we can add further debugging to
the point
at which the data key is generated:
// Save the Inbound Message datakey here to reduce DB queries later.
$messageinboundgenerator->set_data($pid);
$messageinboundhandlers[$pid] = $messageinboundgenerator->fetch_data_key();
mtrace("Setting the data key for post {$pid} to {$messageinboundgenerator[$pid]}");
// Caching subscribed users of each forum.
If this is not set, then we'll need to dig deeper into the data key generation to work out why it's not and which condition has not been met.
If both of these are set, then we'll need to take things through the
above logic all the way to where the headers are actually applied in
lib/moodlelib.php.
One place that things could be going wrong (though it is unlikely) is in the character
encoding phase of email_to_user.
If you could have a look at the above, it may help track things
down.
Cheers,
Andrew