FAQ | This is a LIVE service | Changelog

Skip to content

Switch to using PHPMailer to send email

Dr Catherine Pitt requested to merge maths into master

The function for sending error messages with screenshots included fails on Chemistry's Ubuntu 22.04 instance of Hotwire. The error isn't in Hotwire itself, but rather the version of Exim in 22.04 refuses to send emails with lines longer than a certain limit, which Hotwire's emails exceed.

NB this isn't quite the same problem as when Debian introduced a line length limit into their autogenerated Exim configuration to achieve the same thing, https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=828801 , this one is built into Exim. Setting the macro mentioned in the Debian bug does not help on Ubuntu 22.04. More detail in the Exim bug:

https://bugs.exim.org/show_bug.cgi?id=1684

This change switches error_ajax.php to use PHPMailer which generates differently formatted email which Exim is happy to accept on 22.04. I tried some other solutions but this seemed cleanest, at the expense of carrying an extra dependency.

The From: address is set to the same as the recipient address because PHPMailer won't accept a bare CRSID as a valid address. The code calls htmlspecialcharacters() on the user-supplied message before putting it into the email, because of the warning not to use msgHTML() on user-supplied input.

Merge request reports