Moodle
  1. Moodle
  2. MDL-29814

Blank email body when sending a message

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: 2.0.5, 2.1.2, 2.2
    • Fix Version/s: 2.0.6, 2.1.3
    • Component/s: Messages
    • Labels:
      None
    • Testing Instructions:
      Hide

      You'll need two users. message sender and message recipient. This is easier if sender is an admin.

      check the following profile settings:
      sender : My profile settings => Edit profile => When editing text => Use HTML editor
      recipient : My profile settings => Edit profile => Email format => Plain text format

      Log in as recipient and check their messaging preferences. Make sure that personal messages go to email when both logged in and out.

      Log in as sender. Go to bulk user actions in site admin.
      Home ► Site administration ► Users ► Accounts ► Bulk user actions

      Select the recipient and send them a message. when sending it the html editor should appear for you.

      check that the email arrives and contains your message.

      Show
      You'll need two users. message sender and message recipient. This is easier if sender is an admin. check the following profile settings: sender : My profile settings => Edit profile => When editing text => Use HTML editor recipient : My profile settings => Edit profile => Email format => Plain text format Log in as recipient and check their messaging preferences. Make sure that personal messages go to email when both logged in and out. Log in as sender. Go to bulk user actions in site admin. Home ► Site administration ► Users ► Accounts ► Bulk user actions Select the recipient and send them a message. when sending it the html editor should appear for you. check that the email arrives and contains your message.
    • Affected Branches:
      MOODLE_20_STABLE, MOODLE_21_STABLE, MOODLE_22_STABLE
    • Fixed Branches:
      MOODLE_20_STABLE, MOODLE_21_STABLE
    • Pull Master Branch:
      MDL-29814_blank_emails2
    • Rank:
      19340

      Description

      sender : My profile settings => Edit profile => When editing text => Use HTML editor
      recipient : My profile settings => Edit profile => Email format => Plain text format
      email body is blank on above conditions.

        Activity

        Hide
        Michael Phillips added a comment -

        Similar problem:

        Running 2.1.1

        When sending message with "Pretty HTML" settings, some users receive an email copy with no body, but can view the attachment of the message. This is true in our web-based email system that does not read/allow HTML-formatting for security reasons. It works perfectly in my local client, Thunderbird, though (that is, the body is visible in Thunderbird).

        However, if I change my profile setting to "plain text" - the body is blank and there is no attachment. This is true in both our web-based email client and Thunderbird.

        To be as concise at the previous post:

        Sender : My profile settings => Email format: Pretty HTML format
        Recipient : web-based client (no HTML) RESULT - blank email body; must view attachment
        Recipient : local client (Thunderbird, HTML-friendly) RESULT - works fine; body visible

        Sender : My profile settings => Email format: Plain text format
        Recipient : web-based client (no HTML) RESULT - blank email body; no attachment
        Recipient : local client (Thunderbird, HTML-friendly) RESULT - blank email body; no attachment

        Faculty rely on this to communicate with students, naturally. I'm hoping there is a simple fix for this.

        Show
        Michael Phillips added a comment - Similar problem: Running 2.1.1 When sending message with "Pretty HTML" settings, some users receive an email copy with no body, but can view the attachment of the message. This is true in our web-based email system that does not read/allow HTML-formatting for security reasons. It works perfectly in my local client, Thunderbird, though (that is, the body is visible in Thunderbird). However, if I change my profile setting to "plain text" - the body is blank and there is no attachment. This is true in both our web-based email client and Thunderbird. To be as concise at the previous post: Sender : My profile settings => Email format: Pretty HTML format Recipient : web-based client (no HTML) RESULT - blank email body; must view attachment Recipient : local client (Thunderbird, HTML-friendly) RESULT - works fine; body visible Sender : My profile settings => Email format: Plain text format Recipient : web-based client (no HTML) RESULT - blank email body; no attachment Recipient : local client (Thunderbird, HTML-friendly) RESULT - blank email body; no attachment Faculty rely on this to communicate with students, naturally. I'm hoping there is a simple fix for this.
        Hide
        Chris Francy added a comment -

        I believe I am seeing the same issue on 'Moodle 2.1.2+ (Build: 20111102)'

        It seems that if you are sending a message to someone, and the HTML editor is used, then the a plain text version of the message is blank. The plain-text part of the message sent to a user with Pretty HTML enabled is also empty.

        Raw message sent to a user with 'Email format' set to 'Pretty HTML format' http://pastebin.com/Tj26n1Hk

        Raw message sent to a user with 'Email format' set to 'Plain text format'
        http://pastebin.com/rL7WuDMs

        Show
        Chris Francy added a comment - I believe I am seeing the same issue on 'Moodle 2.1.2+ (Build: 20111102)' It seems that if you are sending a message to someone, and the HTML editor is used, then the a plain text version of the message is blank. The plain-text part of the message sent to a user with Pretty HTML enabled is also empty. Raw message sent to a user with 'Email format' set to 'Pretty HTML format' http://pastebin.com/Tj26n1Hk Raw message sent to a user with 'Email format' set to 'Plain text format' http://pastebin.com/rL7WuDMs
        Hide
        Andrew Davis added a comment -

        I believe I have a solution for this. The messaging code only stores either a plain text message or a html message. The problem is that lib/moodlelib.php email_to_user(), if you've supplied html, assumes that there will also be a plain text version to fall back to.

        I've altered the email message processor so that it will generate a plain text version where html was supplied. It now supplies either only plain text or both plain text and html to email_to_user().

        Show
        Andrew Davis added a comment - I believe I have a solution for this. The messaging code only stores either a plain text message or a html message. The problem is that lib/moodlelib.php email_to_user(), if you've supplied html, assumes that there will also be a plain text version to fall back to. I've altered the email message processor so that it will generate a plain text version where html was supplied. It now supplies either only plain text or both plain text and html to email_to_user().
        Hide
        Andrew Davis added a comment -

        testing instructions added. Ill add versions for other branches after peer review.

        Show
        Andrew Davis added a comment - testing instructions added. Ill add versions for other branches after peer review.
        Hide
        Jason Fowler added a comment -

        Code looks good to me

        Show
        Jason Fowler added a comment - Code looks good to me
        Hide
        Claus A. Us. added a comment - - edited

        Just good the same problem.

        The cause is in message\lib.php in line 2013 following

        messagelib.php:2013
        if ($format == FORMAT_HTML) {
                $eventdata->fullmessage      = ''; ##### needs som changing like html_to_text($message)
                $eventdata->fullmessagehtml  = $message;
            } else {
                $eventdata->fullmessage      = $message;
                $eventdata->fullmessagehtml  = '';
            }
        

        Even if a message is in html format it musst have a fullmessage in plain text. html format is optional. (see lines 4590 function email_to_user in lib\moodlelib.php

        hope that helps.

        Show
        Claus A. Us. added a comment - - edited Just good the same problem. The cause is in message\lib.php in line 2013 following messagelib.php:2013 if ($format == FORMAT_HTML) { $eventdata->fullmessage = ''; ##### needs som changing like html_to_text($message) $eventdata->fullmessagehtml = $message; } else { $eventdata->fullmessage = $message; $eventdata->fullmessagehtml = ''; } Even if a message is in html format it musst have a fullmessage in plain text. html format is optional. (see lines 4590 function email_to_user in lib\moodlelib.php hope that helps.
        Hide
        Andrew Davis added a comment -

        Typically in Moodle we only store the original data. Any conversion that is required is done only when it is needed and the result is not stored. However, we don't usually have different columns for the various formats. After a bit of a discussion in developer chat it was decided to go with your solution Claus. When a html message is sent we'll do the conversion at the time the message is written rather than when the email is sent and will store both html and plain text versions.

        Show
        Andrew Davis added a comment - Typically in Moodle we only store the original data. Any conversion that is required is done only when it is needed and the result is not stored. However, we don't usually have different columns for the various formats. After a bit of a discussion in developer chat it was decided to go with your solution Claus. When a html message is sent we'll do the conversion at the time the message is written rather than when the email is sent and will store both html and plain text versions.
        Hide
        Andrew Davis added a comment -

        Ive created versions for the various branches. This is a substantially different fix from the original so will need to be re-peer-reviewed.

        Show
        Andrew Davis added a comment - Ive created versions for the various branches. This is a substantially different fix from the original so will need to be re-peer-reviewed.
        Hide
        Jason Fowler added a comment -

        code looks good to me

        Show
        Jason Fowler added a comment - code looks good to me
        Hide
        Aparup Banerjee added a comment -

        Thanks, this has been integrated and is up for testing.

        Show
        Aparup Banerjee added a comment - Thanks, this has been integrated and is up for testing.
        Hide
        Eloy Lafuente (stronk7) added a comment - - edited

        tested under master, following the instructions, I created one html message:

        <p>this is one originally html <b>formatted</b> message</p>
        

        and the user received (plain-text):

        this is one originally html FORMATTED message
        

        So I guess that's the expected result. Going to test under 2.1 and 2.0...

        Show
        Eloy Lafuente (stronk7) added a comment - - edited tested under master, following the instructions, I created one html message: <p> this is one originally html <b>formatted</b> message</p> and the user received (plain-text): this is one originally html FORMATTED message So I guess that's the expected result. Going to test under 2.1 and 2.0...
        Hide
        Eloy Lafuente (stronk7) added a comment -

        Tested also against 20 and 21 stabled, got plain-text message. Passing!

        Show
        Eloy Lafuente (stronk7) added a comment - Tested also against 20 and 21 stabled, got plain-text message. Passing!
        Hide
        Aparup Banerjee added a comment -

        \o/

        Show
        Aparup Banerjee added a comment - \o/
        Hide
        Eloy Lafuente (stronk7) added a comment -

        Closing as fixed, many thanks for your effort!

        Note that the changes related to master (2.2beta) have been already sent upstream. But the stable ones will be part of next weeklies (Wed/Thu) as usual.

        Ciao

        Show
        Eloy Lafuente (stronk7) added a comment - Closing as fixed, many thanks for your effort! Note that the changes related to master (2.2beta) have been already sent upstream. But the stable ones will be part of next weeklies (Wed/Thu) as usual. Ciao

          People

          • Votes:
            2 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: