catalyst / moodle-mod_facetoface

Facetoface Module for Moodle 2.0 and above
https://moodle.org/plugins/view/mod_facetoface
GNU General Public License v3.0
6 stars 52 forks source link

Cancellation emails incorrectly send plaintext as html, leading to email clients incorrectly formatting them #139

Open matthewhilton opened 9 months ago

matthewhilton commented 9 months ago

Imagine you have the cancellation email text set as the following:

Hello
Your booking has been cancelled
Thank you

If you were to cancel this booking, the user would get two emails (which is a different issue, see https://github.com/catalyst/moodle-mod_facetoface/issues/60)

The email without the .ics attachment will show normally, i.e. what is above. However, the email with the .ics attachment would be joined into a single line, e.g.:

Hello Your booking has been cancelled Thank you

This looks to be because when sending cancellation emails, when sending the .ics email here:

https://github.com/catalyst/moodle-mod_facetoface/blob/10d6966c09620d76749bf3ca0f4a6245923808bb/lib.php#L2260-L2261

Both the $messagehtml and $messagetext are set as plaintext (no html), i.e.:

Hello
Your booking has been cancelled
Thank you

Which leads to email clients interpreting this message as html, but since there are no line breaks, etc... it joins it all into a single one line string.

This does not seem to happen with confirmation messages, because they use a html editor and probably format the text into both html and plaintext properly, instead of the cancellation messages which just use the normal plain textarea editor.

matthewhilton commented 3 months ago

This seems to not just be limited to cancellation emails, have seen it happen as well to confirmation emails.

matthewhilton commented 3 months ago

May also be related to https://github.com/catalyst/moodle-mod_facetoface/issues/146 - I think the details field is an editor in the form, but under the hood is using html_to_text https://github.com/catalyst/moodle-mod_facetoface/blob/a0cc8a56aece5465cabe43ecaa4ce0a805f09603/lib.php#L804