From 4f9b0e870ad408ad426be8fb323e801facf26195 Mon Sep 17 00:00:00 2001 From: Colin Campbell Date: Tue, 15 Mar 2011 11:57:02 +0100 Subject: [PATCH] [SIGNED OFF] Bug 3810: Ensure all calls to Mail::Sendmail handled consistently Signed-off-by: Julian Maurice --- basket/sendbasket.pl | 3 ++- misc/cronjobs/notifyMailsOp.pl | 13 +++++++------ misc/cronjobs/runreport.pl | 5 +++-- misc/cronjobs/smsoverdues.pl | 5 ++--- opac/opac-sendbasket.pl | 3 ++- opac/opac-sendshelf.pl | 3 ++- virtualshelves/sendshelf.pl | 3 ++- 7 files changed, 20 insertions(+), 15 deletions(-) diff --git a/basket/sendbasket.pl b/basket/sendbasket.pl index 6efa6bc..107a737 100755 --- a/basket/sendbasket.pl +++ b/basket/sendbasket.pl @@ -20,6 +20,7 @@ use warnings; use CGI; use Encode qw(encode); +use Carp; use Mail::Sendmail; use MIME::QuotedPrint; @@ -164,7 +165,7 @@ END_OF_BODY } else { # do something if it doesnt work.... - warn "Error sending mail: $Mail::Sendmail::error \n"; + carp "Error sending mail: $Mail::Sendmail::error \n"; $template->param( error => 1 ); } $template->param( email_add => $email_add ); diff --git a/misc/cronjobs/notifyMailsOp.pl b/misc/cronjobs/notifyMailsOp.pl index 630b159..7c655c9 100755 --- a/misc/cronjobs/notifyMailsOp.pl +++ b/misc/cronjobs/notifyMailsOp.pl @@ -1,6 +1,7 @@ #!/usr/bin/perl use strict; #use warnings; FIXME - Bug 2505 +use Carp; BEGIN { # find Koha's Perl modules # test carefully before changing this @@ -201,12 +202,12 @@ foreach my $num (@getnofifys) { 'content-type' => 'text/html; charset="utf-8"', ); # if we don't have any content for the mail, we don't launch mail, but notify it in a file - if ($mailtext ne 'nonotifys') { - sendmail(%mail); - } - else { - print OUT $email ; - } + if ($mailtext ne 'nonotifys') { + sendmail(%mail) or carp $Mail::Sendmail::error; + } + else { + print OUT $email ; + } # now deal with the debarred mode # if ($debarred eq 1) { diff --git a/misc/cronjobs/runreport.pl b/misc/cronjobs/runreport.pl index 3187e92..d4f5567 100755 --- a/misc/cronjobs/runreport.pl +++ b/misc/cronjobs/runreport.pl @@ -28,6 +28,7 @@ use Pod::Usage; use Mail::Sendmail; use Text::CSV_XS; use CGI; +use Carp; use vars qw($VERSION); @@ -159,7 +160,7 @@ unless (scalar(@ARGV)) { foreach my $report (@ARGV) { my ($sql, $type) = get_saved_report($report); unless ($sql) { - warn "ERROR: No saved report $report found"; + carp "ERROR: No saved report $report found"; next; } $verbose and print "SQL: $sql\n\n"; @@ -188,7 +189,7 @@ foreach my $report (@ARGV) { Subject => $subject, Message => $message ); - sendmail(%mail) or warn "mail not sent"; + sendmail(%mail) or carp 'mail not sent:' . $Mail::Sendmail::error; } else { print $message; } diff --git a/misc/cronjobs/smsoverdues.pl b/misc/cronjobs/smsoverdues.pl index f4dda39..6415eb6 100755 --- a/misc/cronjobs/smsoverdues.pl +++ b/misc/cronjobs/smsoverdues.pl @@ -40,13 +40,13 @@ BEGIN { use C4::Context; use C4::Search; use C4::Circulation; -use C4::Circulation::Fines; use C4::Members; use C4::Dates qw/format_date/; use HTML::Template::Pro; use Mail::Sendmail; use Mail::RFC822::Address; use C4::SMS; +use Carp; use utf8; my ($res,$ua);##variables for SMS @@ -312,8 +312,7 @@ sub sendEmail { if (not(sendmail %mail)) { -warn $Mail::Sendmail::error; - warn "sendEmail to $to failed."; +carp "sendEmail to $to failed: " . $Mail::Sendmail::error; return 0; } diff --git a/opac/opac-sendbasket.pl b/opac/opac-sendbasket.pl index 6213965..0042c42 100755 --- a/opac/opac-sendbasket.pl +++ b/opac/opac-sendbasket.pl @@ -20,6 +20,7 @@ use warnings; use CGI; use Encode qw(encode); +use Carp; use Mail::Sendmail; use MIME::QuotedPrint; @@ -170,7 +171,7 @@ END_OF_BODY } else { # do something if it doesnt work.... - warn "Error sending mail: $Mail::Sendmail::error \n"; + carp "Error sending mail: $Mail::Sendmail::error \n"; $template->param( error => 1 ); } $template->param( email_add => $email_add ); diff --git a/opac/opac-sendshelf.pl b/opac/opac-sendshelf.pl index b535616..6a376c4 100755 --- a/opac/opac-sendshelf.pl +++ b/opac/opac-sendshelf.pl @@ -22,6 +22,7 @@ use warnings; use CGI; use Encode qw(encode); +use Carp; use Mail::Sendmail; use MIME::QuotedPrint; @@ -162,7 +163,7 @@ END_OF_BODY } else { # do something if it doesnt work.... - warn "Error sending mail: $Mail::Sendmail::error \n"; + carp "Error sending mail: $Mail::Sendmail::error \n"; $template->param( error => 1 ); } diff --git a/virtualshelves/sendshelf.pl b/virtualshelves/sendshelf.pl index cdaa641..d902398 100755 --- a/virtualshelves/sendshelf.pl +++ b/virtualshelves/sendshelf.pl @@ -22,6 +22,7 @@ use warnings; use CGI; use Encode qw(encode); +use Carp; use Mail::Sendmail; use MIME::QuotedPrint; @@ -157,7 +158,7 @@ END_OF_BODY } else { # do something if it doesnt work.... - warn "Error sending mail: $Mail::Sendmail::error \n"; + carp "Error sending mail: $Mail::Sendmail::error \n"; $template->param( error => 1 ); } -- 1.7.1