Mailreport - broken images in email
I recently discovered the amazing mailreport package and just started playing with it. Great feature! I just have a few issues to report, I admit I tried to look at the source to see if I could fix these myself but I quickly found myself over my pay grade.
The problem is that in my mail clients (apple Mail.app on OSX 10.10 as well as iPhone built in mail client) the email reports with the RRD graphs come in with duplicate graphs as well as blue [?] placeholder images. I looked into this and found that with a couple of small tweaks to the HTML/MIME source in the email, the display bugs are corrected.
Here's how it looks currently:
I found that making 2 small changes fixes these display glitches:
(1) if the following header is added just below the MIME boundary of where the embedded images start
where cid-filename is the filename of the embedded RRD graph e.g.
(2) in the mail email header (top) change the Content-Type header:
Content-Type: multipart/mixed ```to
The other bug I found is that the "Hour of the day" for sending is in GMT - not the local time zone of the firewall (makes it kind of difficult to set) - so whatever time you really want the report, you have to manually make the timezone adjustment. Can anyone tell me if these changes are possible to implement myself or if the maintainer of the mailreport package would be able to roll them in? thank you so much
Those parts of the header are controlled by phpmailer (an outside library), might not be so easy to fix that part.
Ok– do you know if the code that's responsible for assembling the message source is a binary or is it just php code that can be hand edited on the firewall? If it's something I can hack away at I can take a crack at "fixing" this. It guess the bug should be reported to whoever maintains that library but I am not sure who that would be.
It's just PHP, shouldn't be hard to hack on if you know your way around it.
Ok here's what I tried (so far unsuccessful)
I googled a bit and found some evidence that this bug is caused in older versions of phpmailer, I checked and it seems this mailreport package includes a quite old 5.1 version. So I figured I would try installing a more recent (current 5.2.9) version. I checked and all it seems to require is php 5.3+ which we have (php -v tells me 5.3.28) so off I went!
here's the rough steps I went through:
I cloned a copy of the phpmailer code from Github and scp'd it onto the pfSense unit at /tmp
created a new directory at /etc/inc/phpmailer.old
moved the 3 files at /etc/inc/phpmailer into that dir for safekeeping
copied class.phpmailer.php, class.pop3.php and class.smtp.php from the new source into /etc/inc/phpmailer
chown'd the files to root:wheel and chmod'ed them 644 so they match the original files
restarted the webconfigurator (not sure if this is necessary?)
After that I tried to send myself a test report - and nothing came thru. No errors, nothing in the logs but the message simply wasn't sent. I notice there is an almost instant response after clicking the Send Now button, indicating that there was an error and the email wasn't generated but I am not sure where to check to see what that error might be. I checked all the log files that I know of and even tried clog /var/log/lighttpd.log but that is empty. Not sure where php would log errors to (if at all)
I looked at the source of the new files and I noticed one difference was that in the original files there is both an opening **as well as a final closing ?> but in the new files, the closing ?> was missing. So I tried adding that as well and it made no difference.
Can anyone help me out on this? I am stuck. :(
edit: ok I found the PHP logfile at /tmp/PHP_errors.log and it has the following error when I try to generate a report:
PHP Fatal error: Class 'SMTP' not found in /etc/inc/phpmailer/class.phpmailer.php on line 1196
I think this relates to the class.smtp.php module not being loaded, I am researching this here
have not found the answer yet but I am still trying :P**
;D Success! ;D
After a bunch of tinkering around (mostly due to my lack of knowledge of where the various config and log files are located) I was able to bootstrap the current 5.2.9 version of phpmailer and after one tiny modification to the mailreport code, the malformed email bug is now fixed!
TL;DR - Here are the steps I used to fix:
(from a Terminal)
git clone email@example.com:PHPMailer/PHPMailer.git
scp ./PHPMailer/*.php firstname.lastname@example.org:/tmp
(now ssh to pfsense host, choose option 8 to get to shell)
mv /etc/inc/phpmailer /etc/inc/phpmailer.old
mv /tmp/.php /etc/inc/phpmailer/
chown root:wheel /etc/inc/phpmailer/.php
:188 (go to line 188)
jimp: hopefully you can include the new version in an updated package?
Seems to work fine for me, I just pushed an update that includes the updated library. It will sync in 15 minutes or so. When you see version 2.3, update the package and try again.
Super news, thank you :D
I will test & confirm
edit: confirmed, looks good!
dgcom last edited by
I want to say thank you for this patch as well - this seems to have fixed images display in emails when viewed in Office 365… Something I never had time to look at myself...
Didn't want to start a new thread (sorry)
I found a bug in mailreport 2.3 related to editing items in the "Report Commands" section and have fixed it with a patch.
Hope this is the proper way to do things as I am new to it.
update: good news, my patch was accepted & merged, v2.3.1 is already available in package mgr. cheers guys :D