[Koha-patches] [PATCH] Bug 3810 Mail::Sendmail should not fail silently
Colin Campbell
colin.campbell at ptfs-europe.com
Mon Feb 8 17:17:30 CET 2010
The return from Mail::Sendmail should always be checked
Output the error message if it fails so we have some
indication of where to start looking if it fails
---
C4/Letters.pm | 21 +++++++++------------
1 files changed, 9 insertions(+), 12 deletions(-)
diff --git a/C4/Letters.pm b/C4/Letters.pm
index 72f4f54..002455f 100644
--- a/C4/Letters.pm
+++ b/C4/Letters.pm
@@ -283,7 +283,7 @@ sub SendAlerts {
Message => "" . $innerletter->{content},
'Content-Type' => 'text/plain; charset="utf8"',
);
- sendmail(%mail);
+ sendmail(%mail) or carp $Mail::Sendmail::error;
# warn "sending to $mail{To} From $mail{From} subj $mail{Subject} Mess $mail{Message}";
}
@@ -344,7 +344,7 @@ sub SendAlerts {
Message => "" . $innerletter->{content},
'Content-Type' => 'text/plain; charset="utf8"',
);
- sendmail(%mail);
+ sendmail(%mail) or carp $Mail::Sendmail::error;
warn
"sending to $mail{To} From $mail{From} subj $mail{Subject} Mess $mail{Message}";
}
@@ -422,7 +422,7 @@ sub SendAlerts {
Message => $mail_msg,
'Content-Type' => 'text/plain; charset="utf8"',
);
- sendmail(%mail);
+ sendmail(%mail) or carp $Mail::Sendmail::error;
logaction(
"ACQUISITION",
"CLAIM ISSUE",
@@ -453,7 +453,7 @@ sub SendAlerts {
Message => $letter->{'content'},
'Content-Type' => 'text/plain; charset="utf8"',
);
- sendmail(%mail);
+ sendmail(%mail) or carp $Mail::Sendmail::error;
}
}
@@ -804,18 +804,15 @@ sub _send_message_by_email ($) {
$sendmail_params{ Bcc } = $bcc;
}
- my $success = sendmail( %sendmail_params );
- if ( $success ) {
- # warn "Sendmail OK. Log says: " . $Mail::Sendmail::log;
+ if ( sendmail( %sendmail_params ) ) {
_set_message_status( { message_id => $message->{'message_id'},
- status => 'sent' } );
- return $success;
+ status => 'sent' } );
+ return 1;
} else {
- # warn "Mail::Sendmail::error - " . $Mail::Sendmail::error;
- # warn "Mail::Sendmail::log - " . $Mail::Sendmail::log;
_set_message_status( { message_id => $message->{'message_id'},
- status => 'failed' } );
+ status => 'failed' } );
+ carp $Mail::Sendmail::error;
return;
}
}
--
1.6.6
More information about the Koha-patches
mailing list