Moodle

PHPMailer ignores special characters

Details

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

Issue Links

Activity

Hide
Andreas Grupp added a comment -

Actually the variant with only a dot in the username

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

does not crash with the Freenet-Mail-Exchanger. But the version with [ ]

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

is doing this in a reproducable way. The error message that comes back looks like this:

<...@freenet.de>: host mx.freenet.de[195.4.92.212] said: 550
Syntax error in header (in reply to end of DATA command)
...
From: Hans Mustermann [AdAcc] <mustermann@gmx.de>

Regards, Andreas

Show
Andreas Grupp added a comment - Actually the variant with only a dot in the username From: Hans J. Mustermann <mustermann@gmx.de> does not crash with the Freenet-Mail-Exchanger. But the version with [ ] From: Hans Mustermann [AdAcc] <mustermann@gmx.de> is doing this in a reproducable way. The error message that comes back looks like this: <...@freenet.de>: host mx.freenet.de[195.4.92.212] said: 550 Syntax error in header (in reply to end of DATA command) ... From: Hans Mustermann [AdAcc] <mustermann@gmx.de> Regards, Andreas
Hide
Petr Škoda (skodak) added a comment -

Found the bug, the problem was in our moodle modification, fixing it just now

Show
Petr Škoda (skodak) added a comment - Found the bug, the problem was in our moodle modification, fixing it just now
Hide
Petr Škoda (skodak) added a comment -

fixed in cvs, thanks for the report!!

Show
Petr Škoda (skodak) added a comment - fixed in cvs, thanks for the report!!

People

Vote (0)
Watch (0)

Dates

  • Created:
    Updated:
    Resolved: