Lines 40-45
use Koha::Auth::TwoFactorAuth;
Link Here
|
40 |
use Koha::Patrons; |
40 |
use Koha::Patrons; |
41 |
use Koha::SMTP::Servers; |
41 |
use Koha::SMTP::Servers; |
42 |
use Koha::Subscriptions; |
42 |
use Koha::Subscriptions; |
|
|
43 |
use Data::Dumper; |
43 |
|
44 |
|
44 |
use constant SERIALIZED_EMAIL_CONTENT_TYPE => 'message/rfc822'; |
45 |
use constant SERIALIZED_EMAIL_CONTENT_TYPE => 'message/rfc822'; |
45 |
|
46 |
|
Lines 1319-1330
sub _send_message_by_email {
Link Here
|
1319 |
my $message = shift or return; |
1320 |
my $message = shift or return; |
1320 |
my ( $username, $password, $method, $smtp_transports ) = @_; |
1321 |
my ( $username, $password, $method, $smtp_transports ) = @_; |
1321 |
|
1322 |
|
1322 |
my $patron; |
1323 |
my $patron = Koha::Patrons->find( $message->{borrowernumber} ); |
1323 |
my $to_address = $message->{'to_address'}; |
1324 |
my $to_address = $message->{'to_address'}; |
1324 |
my $use_garantor = C4::Context->preference('RedirectGuaranteeEmail'); |
1325 |
my $cc_address; |
1325 |
if($use_garantor eq 'yes' || !$to_address) { |
1326 |
my @guarantor_address; |
1326 |
$patron = Koha::Patrons->find( $message->{borrowernumber} ); |
1327 |
my $count_guarantor_address; |
1327 |
unless ($patron or $to_address) { |
1328 |
if (C4::Context->preference('RedirectGuaranteeEmail') eq 'yes' && $patron) { |
|
|
1329 |
#Get guanrantor adresses |
1330 |
my $guarantor_relationships = $patron->guarantor_relationships; |
1331 |
my @guarantors = $guarantor_relationships->guarantors->as_list; |
1332 |
foreach my $guarantor (@guarantors) { |
1333 |
my $address = $guarantor->notice_email_address; |
1334 |
push( @guarantor_address, $address ) if $address; |
1335 |
} |
1336 |
$count_guarantor_address = scalar @guarantor_address; |
1337 |
} |
1338 |
unless ($to_address) { |
1339 |
if (!$patron && !$count_guarantor_address) { |
1328 |
warn "FAIL: No 'to_address' and INVALID borrowernumber ($message->{borrowernumber})"; |
1340 |
warn "FAIL: No 'to_address' and INVALID borrowernumber ($message->{borrowernumber})"; |
1329 |
_set_message_status( |
1341 |
_set_message_status( |
1330 |
{ |
1342 |
{ |
Lines 1338-1344
sub _send_message_by_email {
Link Here
|
1338 |
if ($patron) { |
1350 |
if ($patron) { |
1339 |
$to_address = $patron->notice_email_address; |
1351 |
$to_address = $patron->notice_email_address; |
1340 |
} |
1352 |
} |
1341 |
unless ($to_address) { |
1353 |
if (!$to_address && !$count_guarantor_address) { |
1342 |
# warn "FAIL: No 'to_address' and no email for " . ($member->{surname} ||'') . ", borrowernumber ($message->{borrowernumber})"; |
1354 |
# warn "FAIL: No 'to_address' and no email for " . ($member->{surname} ||'') . ", borrowernumber ($message->{borrowernumber})"; |
1343 |
# warning too verbose for this more common case? |
1355 |
# warning too verbose for this more common case? |
1344 |
_set_message_status( |
1356 |
_set_message_status( |
Lines 1350-1357
sub _send_message_by_email {
Link Here
|
1350 |
); |
1362 |
); |
1351 |
return; |
1363 |
return; |
1352 |
} |
1364 |
} |
|
|
1365 |
if (!$to_address && $count_guarantor_address) { |
1366 |
$to_address = shift @guarantor_address; |
1367 |
} |
1353 |
} |
1368 |
} |
1354 |
|
1369 |
|
|
|
1370 |
$cc_address = join( ',', @guarantor_address ); |
1355 |
# Skip this message if we exceed domain limits in this run |
1371 |
# Skip this message if we exceed domain limits in this run |
1356 |
if( Koha::Notice::Util->exceeds_limit({ to => $to_address, limits => $domain_limits }) ) { |
1372 |
if( Koha::Notice::Util->exceeds_limit({ to => $to_address, limits => $domain_limits }) ) { |
1357 |
# Save the to_address if you delay the message so that we dont need to look it up again |
1373 |
# Save the to_address if you delay the message so that we dont need to look it up again |
Lines 1406-1411
sub _send_message_by_email {
Link Here
|
1406 |
? ( bcc => C4::Context->preference('NoticeBcc') ) |
1422 |
? ( bcc => C4::Context->preference('NoticeBcc') ) |
1407 |
: () |
1423 |
: () |
1408 |
), |
1424 |
), |
|
|
1425 |
( |
1426 |
$cc_address |
1427 |
? ( cc => $cc_address ) |
1428 |
: () |
1429 |
), |
1409 |
from => $from_address, |
1430 |
from => $from_address, |
1410 |
reply_to => $message->{'reply_address'} || $branch_replyto, |
1431 |
reply_to => $message->{'reply_address'} || $branch_replyto, |
1411 |
sender => $branch_returnpath, |
1432 |
sender => $branch_returnpath, |