nope because I got it working :D:D
For some reason, when the script is set to multipart/alternative ... the images will refuse to load. On multipart/mixed it works (and adds the plain text part as an attachment... which I can live with).
Anyway, the end result is (I believe this is a direct copy from the first post in this thread, however just for clarity):
zmfilter.pl:
sub sendEmail
{
my $filter = shift;
my $event = shift;
if ( !ZM_FROM_EMAIL )
{
warn( "No 'from' email address defined, not sending email" );
return( 0 );
}
if ( !ZM_EMAIL_ADDRESS )
{
warn( "No email address defined, not sending email" );
return( 0 );
}
Info( "Creating notification email\n" );
my $subject = substituteTags( ZM_EMAIL_SUBJECT, $filter, $event );
return( 0 ) if ( !$subject );
my @attachments;
my $body = substituteTags( ZM_EMAIL_BODY, $filter, $event, \@attachments );
return( 0 ) if ( !$body );
Info( "Sending notification email '$subject'\n" );
eval
{
if ( ZM_NEW_MAIL_MODULES )
{
### Create the multipart container
my $mail = MIME::Lite->new (
From => ZM_FROM_EMAIL,
To => ZM_EMAIL_ADDRESS,
Subject => $subject,
Type => "multipart/mixed"
);
### Create an image tag for each attachment
my $attachment_count = 0;
my $img_tags = "";
foreach my $attachment ( @attachments )
{
$attachment_count++;
$img_tags .= qq {<img src="cid:inline_image$attachment_count"><br>};
}
### Add an html message part
$mail->attach (
Type => "text/html",
Data => qq {<body>$img_tags<br>$body</body>}
);
### Add the text message part
$mail->attach (
Type => "TEXT",
Data => $body
);
### Add the attachments
### Add the counter to create an image Id
### Note that is must be declared "my" or else it will
### be considered global and cause the entire zmfilter.pl to fail
$attachment_count = 0;
foreach my $attachment ( @attachments )
{
Info( "Attaching '$attachment->{path}\n" );
$mail->attach(
Path => $attachment->{path},
Type => $attachment->{type},
Id => ('inline_image' . ++$attachment_count),
Disposition => "attachment"
);
}
### Send the Message
MIME::Lite->send( "smtp", ZM_EMAIL_HOST, Timeout=>60 );
$mail->send();
}
else
{
my $mail = MIME::Entity->build(
From => ZM_FROM_EMAIL,
To => ZM_EMAIL_ADDRESS,
Subject => $subject,
Type => (($body=~/<html>/)?'text/html':'text/plain'),
Data => $body
);
foreach my $attachment ( @attachments )
{
Info( "Attaching '$attachment->{path}\n" );
$mail->attach(
Path => $attachment->{path},
Type => $attachment->{type},
Encoding => "base64"
);
}
$mail->smtpsend( Host => ZM_EMAIL_HOST, MailFrom => ZM_FROM_EMAIL );
}
};
if ( $@ )
{
warn( "Can't send email: $@" );
return( 0 );
}
else
{
Info( "Notification email sent\n" );
}
my $sql = "update Events set Emailed = 1 where Id = ?";
my $sth = $dbh->prepare_cached( $sql ) or Fatal( "Can't prepare '$sql': ".$dbh->errstr() );
my $res = $sth->execute( $event->{Id} ) or Fatal( "Can't execute '$sql': ".$sth->errstr() );
return( 1 );
}
And, the ZM_EMAIL_BODY:
%EI1%
%EIM%
<b>WARNING!</b><br><br>
An alarm has been detected on your installation of ZoneMinder.<br><br>
The alarm occurred at <b>%MN%</b> at %ET%.<br><br>
The cause was %EC%, with a maximum event score of %ESM%.<br><br>
Currently, there are %MET% total events logged at %MN%.<br><br>
This alarm was matched by the %FN% filter and can be viewed at<br>
<br>
<A href="%EPS%">
http://yourdomain.com/zm</A>
NB: I have ZM_NEW_MAIL_MODULES selected