corrupt email images

Forum for questions and support relating to the 1.30.x releases only.
Locked
CascadianDuck
Posts: 6
Joined: Sun Nov 05, 2017 7:25 am

corrupt email images

Post 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?
Attachments
00026-capture.jpg
00026-capture.jpg (112.62 KiB) Viewed 35122 times
CascadianDuck
Posts: 6
Joined: Sun Nov 05, 2017 7:25 am

Re: corrupt email images

Post 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...
CascadianDuck
Posts: 6
Joined: Sun Nov 05, 2017 7:25 am

Re: corrupt email images

Post 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.
CascadianDuck
Posts: 6
Joined: Sun Nov 05, 2017 7:25 am

Re: corrupt email images

Post 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.
CascadianDuck
Posts: 6
Joined: Sun Nov 05, 2017 7:25 am

Re: corrupt email images

Post 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...
tagcart
Posts: 3
Joined: Sat Mar 23, 2019 4:22 am

Re: corrupt email images

Post by tagcart »

Hey there, I'm experiencing the exact same issue... Did you ever get this sorted out?Image
CascadianDuck
Posts: 6
Joined: Sun Nov 05, 2017 7:25 am

Re: corrupt email images

Post 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.
tagcart
Posts: 3
Joined: Sat Mar 23, 2019 4:22 am

Re: corrupt email images

Post by tagcart »

That would be awesome, any info you have would be much appreciated!
gmangum
Posts: 2
Joined: Tue Jun 16, 2020 3:31 pm

Re: corrupt email images

Post by gmangum »

Did anyone ever figure this out? I'm having the problem on 1.34.
dabriel
Posts: 1
Joined: Tue Nov 30, 2021 2:21 pm

Re: corrupt email images

Post 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;
Locked