Fix html emails when using ZM_NEW_MAIL_MODULES. Improve debugging and reduce Info logging

This commit is contained in:
Isaac Connor 2021-09-10 13:47:32 -04:00 committed by Isaac Connor
parent b75cc07028
commit 5475b44852
1 changed files with 6 additions and 8 deletions

View File

@ -843,7 +843,7 @@ sub sendEmail {
return 0;
}
Info('Creating notification email');
Debug('Creating notification email');
my $subject = substituteTags($$filter{EmailSubject}, $filter, $Event);
return 0 if !$subject;
@ -851,7 +851,7 @@ sub sendEmail {
my $body = substituteTags($$filter{EmailBody}, $filter, $Event, \@attachments);
return 0 if !$body;
Info("Sending notification email '$subject'");
Debug("Sending notification email '$subject'");
eval {
if ( $Config{ZM_NEW_MAIL_MODULES} ) {
@ -864,7 +864,7 @@ sub sendEmail {
);
### Add the text message part
$mail->attach (
Type => 'TEXT',
Type => (($body=~/<html/)?'text/html':'text/plain'),
Data => $body
);
### Add the attachments
@ -886,9 +886,7 @@ sub sendEmail {
if ( $Config{ZM_SSMTP_MAIL} ) {
my $ssmtp_location = $Config{ZM_SSMTP_PATH};
if ( !$ssmtp_location ) {
if ( logDebugging() ) {
Debug("which ssmtp: $ssmtp_location - set ssmtp path in options to suppress this message");
}
Debug("which ssmtp: $ssmtp_location - set ssmtp path in options to suppress this message");
$ssmtp_location = qx('which ssmtp');
}
if ( !$ssmtp_location ) {
@ -916,7 +914,7 @@ sub sendEmail {
foreach my $attachment ( @attachments ) {
my $size = -s $attachment->{path};
$total_size += $size;
Info("Attaching '$attachment->{path}' which is $size bytes");
Debug("Attaching '$attachment->{path}' which is $size bytes");
$mail->attach(
Path => $attachment->{path},
@ -934,7 +932,7 @@ sub sendEmail {
Error("Unable to send email: $@");
return 0;
} else {
Info('Notification email sent');
Info("Notification email sent to $$filter{EmailTo}");
}
my $sql = 'UPDATE `Events` SET `Emailed` = 1 WHERE `Id` = ?';
my $sth = $dbh->prepare_cached($sql)