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
parent a9379e5813
commit c2472894be
1 changed files with 6 additions and 8 deletions

View File

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