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

PHPMailer ignores special characters

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Major Major
    • 1.8.4, 1.9, 2.0
    • 1.9
    • Forum, Other
    • None
    • MOODLE_19_STABLE
    • MOODLE_18_STABLE, MOODLE_19_STABLE, MOODLE_20_STABLE

      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

            skodak Petr Skoda
            grupp Andreas Grupp
            Nobody Nobody (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:

                Error rendering 'clockify-timesheets-time-tracking-reports:timer-sidebar'. Please contact your Jira administrators.