Uploaded image for project: 'Moodle'
  1. Moodle
  2. MDL-29814

Blank email body when sending a message

    Details

    • Type: Bug
    • Status: Closed
    • Priority: 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

      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.

        Gliffy Diagrams

          Attachments

            Activity

            Hide
            phillimj 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
            phillimj 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
            zoredache 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
            zoredache 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
            andyjdavis 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
            andyjdavis 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
            andyjdavis Andrew Davis added a comment -

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

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

            Code looks good to me

            Show
            phalacee Jason Fowler added a comment - Code looks good to me
            Hide
            super3d 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
            super3d 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
            andyjdavis 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
            andyjdavis 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
            andyjdavis 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
            andyjdavis 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
            phalacee Jason Fowler added a comment -

            code looks good to me

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

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

            Show
            nebgor Aparup Banerjee added a comment - Thanks, this has been integrated and is up for testing.
            Hide
            stronk7 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
            stronk7 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
            stronk7 Eloy Lafuente (stronk7) added a comment -

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

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

            \o/

            Show
            nebgor Aparup Banerjee added a comment - \o/
            Hide
            stronk7 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
            stronk7 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:
                  Fix Release Date:
                  28/Nov/11