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