When sending mail through and AJAX page, the error output breaks a returned JSON object.
The offending code seems to be in smtp.phpmailer.inc, lines 468 and 501:
echo t('Invalid address') . ': ' . $address;
Why is it outputting directly, rather than through drupal_set_message() or a similar method?
| Comment | File | Size | Author |
|---|---|---|---|
| #11 | log_errors-1292490-11.patch | 2.4 KB | wundo |
Comments
Comment #1
moonray commentedPretty much all echoed (printed) statements will cause problems.
Comment #2
fabianx commentedThe solution is to use:
That way phpmailer does not need to be changed and the module does no longer breaks on AJAX.
Setting to "needs work" as someone should make a patch out of above code snippet.
Comment #3
fabianx commentedChanging title to reflect that this will be a solution also for:
#1085668: Debug prints outside D7 admin overlay
Comment #4
jtsnow commentedI am having this problem as well. The README.txt file for this module states:
It looks like the PHPMailer library has already been patched to use t() for translatable strings, so it would seem that patching the library to log errors correctly shouldn't be a concern.
I've attached a patch that modifies smtp.phpmailer.inc to log errors to watchdog instead of printing them to stdout.
Comment #5
jtsnow commentedComment #6
mkolar commentedThanks for this, echo was ugly.
Comment #7
fabianx commentedComment #8
mkolar commentedHere is patch against latest 7.x-1.x branch with implementation of new logging select field from https://www.drupal.org/node/1937416.
Comment #9
mkolar commentedComment #10
fabianx commentedComment #11
wundo commentedUpdating the patch to reflect changes in #1937416-18: Watchdog logging verbose settings
Comment #12
wundo commentedThis will have to wait until someone has reviewed #1937416-18: Watchdog logging verbose settings
Comment #13
fabianx commentedStill RTBC, other patch is RTBC, too.
Comment #15
wundo commented