corrupt email images
-
- Posts: 6
- Joined: Sun Nov 05, 2017 7:25 am
corrupt email images
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?
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 (112.62 KiB) Viewed 53311 times
-
- Posts: 6
- Joined: Sun Nov 05, 2017 7:25 am
Re: corrupt email images
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...
-
- Posts: 6
- Joined: Sun Nov 05, 2017 7:25 am
Re: corrupt email images
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.
$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.
-
- Posts: 6
- Joined: Sun Nov 05, 2017 7:25 am
Re: corrupt email images
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.
And somehow this is happening inside of perl or ssmtp during sending.
-
- Posts: 6
- Joined: Sun Nov 05, 2017 7:25 am
Re: corrupt email images
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
Hey there, I'm experiencing the exact same issue... Did you ever get this sorted out?

-
- Posts: 6
- Joined: Sun Nov 05, 2017 7:25 am
Re: corrupt email images
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
That would be awesome, any info you have would be much appreciated!
Re: corrupt email images
Did anyone ever figure this out? I'm having the problem on 1.34.
Re: corrupt email images
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.
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;