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

PHPMailer ignores special characters

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 1.9
    • Fix Version/s: 1.8.4, 1.9, 2.0
    • Component/s: Forum, Other
    • Labels:
      None
    • Affected Branches:
      MOODLE_19_STABLE
    • Fixed Branches:
      MOODLE_18_STABLE, MOODLE_19_STABLE, MOODLE_20_STABLE

      Description

      Some users have characters in their first- and lastnames of their Moodle-Account that are marked as "special characters" in RFC2822. These characters are:

      ( ) < > [ ] : ; @ \ , .

      Example: If someone has used "Mustermann [AdAcc]" as last name in Moodle (just to show up that this account has a special meaning) or their is a middlename with a DOT like "Hans J. Mustermann" the PHPmailer in Moodle generates a "From:"-Header in the mail of a forum that looks like this:

      From: Hans Mustermann [AdAcc] <mustermann@gmx.de>
      From: Hans J. Mustermann <mustermann@gmx.de>

      But since [, ] or the dot are special characters they must be quoted to be conform to RFC2822. The correct header lines would be:

      From: "Hans Mustermann [AdAcc]" <mustermann@gmx.de>
      From: "Hans J. Mustermann" <mustermann@gmx.de>

      With some providers (for example Freenet in Germany) this leads to a mail delivery problem because the Freenet-Mail-Exchanger refuses these headers and replies with a 550 error.

      A quick and dirty hack (I am not a PHP programmer) is editing /lib/phpmailer/class.phpmailer.php. Changing the last line from

      $from = array();
      $from[0][0] = trim($this->From);
      $from[0][1] = $this->FromName;

      to

      $from = array();
      $from[0][0] = trim($this->From);
      $from[0][1] = '"' . $this->FromName . '"';

      is a quick solution. But perhaps someone can find a better way to do this.

      Regards, Andreas

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                skodak Petr Skoda
                Reporter:
                grupp Andreas Grupp
                Tester:
                Nobody
                Participants:
                Component watchers:
                Andrew Nicols, Mathew May, Michael Hawkins, Shamim Rezaie, Simey Lameze, Adrian Greeve, Mihail Geshoski, Peter Dias
              • Votes:
                0 Vote for this issue
                Watchers:
                0 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:
                  Fix Release Date:
                  11/Jan/08