From d3e2de362503abaf442cb2df471444d185d48905 Mon Sep 17 00:00:00 2001 From: Colin Campbell Date: Mon, 8 Feb 2010 16:17:30 +0000 Subject: [PATCH] Bug 3810 Mail::Sendmail should not fail silently 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 Signed-off-by: Galen Charlton --- C4/Letters.pm | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/C4/Letters.pm b/C4/Letters.pm index 72f4f54d6d..002455f842 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; } } -- 2.39.5