Page 1 of 1
corrupt email images
Posted: Sun Nov 05, 2017 7:29 am
by CascadianDuck
Hi,
I've installed ZM 1.30.4 on my FreeNAS box. It works great except that when it sends email notifications the attached images are corrupted. It only shows a small portion of the image and the rest is gray. I'm using SSMTP. I've confirmed SSMTP works fine and have used a command similar to the following to attach an image from ZM:
echo -e "to:
receiver@domain.tld\nsubject: subject\n"| (cat - && uuencode /path/to/attachment attachment.name) | ssmtp
sender@gmail.com
An example image is attached.
I'm guessing this is an issue somewhere in ZM or in Perl?
Re: corrupt email images
Posted: Sun Nov 05, 2017 3:58 pm
by CascadianDuck
Note that the source files that ZM tries to attach, like zoneminder/events/1/17/11/04/21/11/56/00026-capture.jpg, is perfectly fine and I'm able to attach it to an email with SSMTP when directly calling SSMTP on the command line. But when ZM tries to do the attaching, the problem above happens...
Re: corrupt email images
Posted: Mon Dec 04, 2017 8:49 am
by CascadianDuck
For debugging purposes I edited zmfilter.pl and added a line:
$mail->send_by_testfile();
Just before the line:
if ( $Config{ZM_SSMTP_MAIL} ) {
to see what MIME::Lite had created, and it was already corrupted at that point. So something inside MIME::Lite is messing up. Need to keep digging.
Edit: scratch that, the file was fine. I was able to extract a good image from the test file.
Re: corrupt email images
Posted: Tue Dec 05, 2017 6:08 am
by CascadianDuck
Ugh. Somehow text from the email body is getting inserted into the base64 encoded section of the mail for the attachment. This causes the base64 encoding to become corrupted and the only portion of the image that shows is the portion before the base64 encoding is broken.
And somehow this is happening inside of perl or ssmtp during sending.
Re: corrupt email images
Posted: Mon Dec 11, 2017 10:42 pm
by CascadianDuck
So strange. For some reason it works better by opening a pipe to the ssmtp command, and "printing" mail->as_string to the file handle. It doesn't get corrupted as often, but still happens in some cases...
Re: corrupt email images
Posted: Sat Mar 23, 2019 4:24 am
by tagcart
Hey there, I'm experiencing the exact same issue... Did you ever get this sorted out?

Re: corrupt email images
Posted: Thu Mar 28, 2019 4:40 am
by CascadianDuck
It's been a while since I worked on this, I need to dig a bit to see what I ended up changing.
Re: corrupt email images
Posted: Fri Mar 29, 2019 7:46 pm
by tagcart
That would be awesome, any info you have would be much appreciated!
Re: corrupt email images
Posted: Tue Jun 16, 2020 3:46 pm
by gmangum
Did anyone ever figure this out? I'm having the problem on 1.34.
Re: corrupt email images
Posted: Tue Dec 07, 2021 1:25 pm
by dabriel
I had the same issue on v1.36.5. Solution outlined by @CascadianDuck works well for me.
Replace line 896 of zmfilter.pl (the MIME::Lite send mail function) with these lines to pipe the email as a string to your configured sendmail application. You'll also need to have 'NEW_MAIL_MODULES' and 'SSMTP_MAIL' enabled.
Code: Select all
#$mail->send('sendmail', $ssmtp_location, $$filter{EmailTo});
open(my $sendmail_pipe, '|-', $ssmtp_location, $$filter{EmailTo});
print $sendmail_pipe $mail->as_string;