Bugzilla – Attachment 125250 Details for
Bug 28996
SendAlerts crashes on a bad email 'To'
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 28996: Catch error in mail creation
Bug-28996-Catch-error-in-mail-creation.patch (text/plain), 7.28 KB, created by
Didier Gautheron
on 2021-09-24 14:08:10 UTC
(
hide
)
Description:
Bug 28996: Catch error in mail creation
Filename:
MIME Type:
Creator:
Didier Gautheron
Created:
2021-09-24 14:08:10 UTC
Size:
7.28 KB
patch
obsolete
>From 207b8b6538de39f1e0fa279be88b5ae89012c7ff Mon Sep 17 00:00:00 2001 >From: Didier Gautheron <didier.gautheron@biblibre.com> >Date: Fri, 24 Sep 2021 14:07:45 +0200 >Subject: [PATCH] Bug 28996: Catch error in mail creation > >--- > C4/Letters.pm | 166 +++++++++++++++++++++++++------------------------- > 1 file changed, 83 insertions(+), 83 deletions(-) > >diff --git a/C4/Letters.pm b/C4/Letters.pm >index 87b82624c6..9194bc8caf 100644 >--- a/C4/Letters.pm >+++ b/C4/Letters.pm >@@ -324,24 +324,24 @@ sub SendAlerts { > ) or return; > > # FIXME: This 'default' behaviour should be moved to Koha::Email >- my $mail = Koha::Email->create( >- { >- to => $email, >- from => $library->branchemail, >- reply_to => $library->branchreplyto, >- sender => $library->branchreturnpath, >- subject => "" . $letter->{title}, >- } >- ); >+ my $success = try { >+ my $mail = Koha::Email->create( >+ { >+ to => $email, >+ from => $library->branchemail, >+ reply_to => $library->branchreplyto, >+ sender => $library->branchreturnpath, >+ subject => "" . $letter->{title}, >+ } >+ ); > >- if ( $letter->{is_html} ) { >- $mail->html_body( _wrap_html( $letter->{content}, "" . $letter->{title} ) ); >- } >- else { >- $mail->text_body( $letter->{content} ); >- } >+ if ( $letter->{is_html} ) { >+ $mail->html_body( _wrap_html( $letter->{content}, "" . $letter->{title} ) ); >+ } >+ else { >+ $mail->text_body( $letter->{content} ); >+ } > >- my $success = try { > $mail->send_or_die({ transport => $library->smtp_server->transport }); > } > catch { >@@ -475,33 +475,33 @@ sub SendAlerts { > > # ... then send mail > my $library = Koha::Libraries->find( $userenv->{branch} ); >- my $mail = Koha::Email->create( >- { >- to => join( ',', @email ), >- cc => join( ',', @cc ), >- ( >+ my $success = try { >+ my $mail = Koha::Email->create( >+ { >+ to => join( ',', @email ), >+ cc => join( ',', @cc ), > ( >- C4::Context->preference("ClaimsBccCopy") >- && ( $type eq 'claimacquisition' >- || $type eq 'claimissues' ) >- ) >- ? ( bcc => $userenv->{emailaddress} ) >- : () >- ), >- from => $library->branchemail >- || C4::Context->preference('KohaAdminEmailAddress'), >- subject => "" . $letter->{title}, >- } >- ); >+ ( >+ C4::Context->preference("ClaimsBccCopy") >+ && ( $type eq 'claimacquisition' >+ || $type eq 'claimissues' ) >+ ) >+ ? ( bcc => $userenv->{emailaddress} ) >+ : () >+ ), >+ from => $library->branchemail >+ || C4::Context->preference('KohaAdminEmailAddress'), >+ subject => "" . $letter->{title}, >+ } >+ ); > >- if ( $letter->{is_html} ) { >- $mail->html_body( _wrap_html( $letter->{content}, "" . $letter->{title} ) ); >- } >- else { >- $mail->text_body( "" . $letter->{content} ); >- } >+ if ( $letter->{is_html} ) { >+ $mail->html_body( _wrap_html( $letter->{content}, "" . $letter->{title} ) ); >+ } >+ else { >+ $mail->text_body( "" . $letter->{content} ); >+ } > >- my $success = try { > $mail->send_or_die({ transport => $library->smtp_server->transport }); > } > catch { >@@ -1389,54 +1389,54 @@ sub _send_message_by_email { > ); > return; > }; >- my $email = Koha::Email->create( >- { >- to => $to_address, >- ( >- C4::Context->preference('NoticeBcc') >- ? ( bcc => C4::Context->preference('NoticeBcc') ) >- : () >- ), >- from => $from_address, >- reply_to => $message->{'reply_address'} || $branch_replyto, >- sender => $branch_returnpath, >- subject => "" . $message->{subject} >- } >- ); >- >- if ( $is_html ) { >- $email->html_body( >- _wrap_html( $content, $subject ) >- ); >- } >- else { >- $email->text_body( $content ); >- } >- >- my $smtp_server; >- if ( $library ) { >- $smtp_server = $library->smtp_server; >- } >- else { >- $smtp_server = Koha::SMTP::Servers->get_default; >- } >- >- if ( $username ) { >- $smtp_server->set( >+ try { >+ my $email = Koha::Email->create( > { >- sasl_username => $username, >- sasl_password => $password, >+ to => $to_address, >+ ( >+ C4::Context->preference('NoticeBcc') >+ ? ( bcc => C4::Context->preference('NoticeBcc') ) >+ : () >+ ), >+ from => $from_address, >+ reply_to => $message->{'reply_address'} || $branch_replyto, >+ sender => $branch_returnpath, >+ subject => "" . $message->{subject} > } > ); >- } > >-# if initial message address was empty, coming here means that a to address was found and >-# queue should be updated; same if to address was overriden by Koha::Email->create >- _update_message_to_address( $message->{'message_id'}, $email->email->header('To') ) >- if !$message->{to_address} >- || $message->{to_address} ne $email->email->header('To'); >+ if ( $is_html ) { >+ $email->html_body( >+ _wrap_html( $content, $subject ) >+ ); >+ } >+ else { >+ $email->text_body( $content ); >+ } >+ >+ my $smtp_server; >+ if ( $library ) { >+ $smtp_server = $library->smtp_server; >+ } >+ else { >+ $smtp_server = Koha::SMTP::Servers->get_default; >+ } >+ >+ if ( $username ) { >+ $smtp_server->set( >+ { >+ sasl_username => $username, >+ sasl_password => $password, >+ } >+ ); >+ } >+ >+ # if initial message address was empty, coming here means that a to address was found and >+ # queue should be updated; same if to address was overriden by Koha::Email->create >+ _update_message_to_address( $message->{'message_id'}, $email->email->header('To') ) >+ if !$message->{to_address} >+ || $message->{to_address} ne $email->email->header('To'); > >- try { > $email->send_or_die({ transport => $smtp_server->transport }); > > _set_message_status( >-- >2.20.1
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 28996
:
125238
| 125250