Lines 40-46
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; |
|
|
44 |
|
43 |
|
45 |
use constant SERIALIZED_EMAIL_CONTENT_TYPE => 'message/rfc822'; |
44 |
use constant SERIALIZED_EMAIL_CONTENT_TYPE => 'message/rfc822'; |
46 |
|
45 |
|
Lines 1324-1330
sub _send_message_by_email {
Link Here
|
1324 |
my @guarantor_address; |
1323 |
my @guarantor_address; |
1325 |
my $count_guarantor_address; |
1324 |
my $count_guarantor_address; |
1326 |
if (C4::Context->preference('RedirectGuaranteeEmail') eq 'yes' && $patron) { |
1325 |
if (C4::Context->preference('RedirectGuaranteeEmail') eq 'yes' && $patron) { |
1327 |
#Get guanrantor adresses |
1326 |
#Get guanrantor addresses |
1328 |
my $guarantor_relationships = $patron->guarantor_relationships; |
1327 |
my $guarantor_relationships = $patron->guarantor_relationships; |
1329 |
my @guarantors = $guarantor_relationships->guarantors->as_list; |
1328 |
my @guarantors = $guarantor_relationships->guarantors->as_list; |
1330 |
foreach my $guarantor (@guarantors) { |
1329 |
foreach my $guarantor (@guarantors) { |
Lines 1334-1340
sub _send_message_by_email {
Link Here
|
1334 |
$count_guarantor_address = scalar @guarantor_address; |
1333 |
$count_guarantor_address = scalar @guarantor_address; |
1335 |
} |
1334 |
} |
1336 |
unless ($to_address) { |
1335 |
unless ($to_address) { |
1337 |
if (!$patron && !$count_guarantor_address) { |
1336 |
if (!$patron) { |
1338 |
warn "FAIL: No 'to_address' and INVALID borrowernumber ($message->{borrowernumber})"; |
1337 |
warn "FAIL: No 'to_address' and INVALID borrowernumber ($message->{borrowernumber})"; |
1339 |
_set_message_status( |
1338 |
_set_message_status( |
1340 |
{ |
1339 |
{ |
Lines 1349-1356
sub _send_message_by_email {
Link Here
|
1349 |
$to_address = $patron->notice_email_address; |
1348 |
$to_address = $patron->notice_email_address; |
1350 |
} |
1349 |
} |
1351 |
if (!$to_address && !$count_guarantor_address) { |
1350 |
if (!$to_address && !$count_guarantor_address) { |
1352 |
# warn "FAIL: No 'to_address' and no email for " . ($member->{surname} ||'') . ", borrowernumber ($message->{borrowernumber})"; |
1351 |
warn "FAIL: No 'to_address', email address or guantors email address for borrowernumber ($message->{borrowernumber})"; |
1353 |
# warning too verbose for this more common case? |
|
|
1354 |
_set_message_status( |
1352 |
_set_message_status( |
1355 |
{ |
1353 |
{ |
1356 |
message_id => $message->{'message_id'}, |
1354 |
message_id => $message->{'message_id'}, |
Lines 1360-1366
sub _send_message_by_email {
Link Here
|
1360 |
); |
1358 |
); |
1361 |
return; |
1359 |
return; |
1362 |
} |
1360 |
} |
1363 |
if (!$to_address && $count_guarantor_address) { |
1361 |
if ( !$to_address && $count_guarantor_address ) { |
1364 |
$to_address = shift @guarantor_address; |
1362 |
$to_address = shift @guarantor_address; |
1365 |
} |
1363 |
} |
1366 |
} |
1364 |
} |
Lines 1494-1502
sub _send_message_by_email {
Link Here
|
1494 |
$smtp_transports->{ $smtp_server->id // 'default' } ||= $smtp_server->transport; |
1492 |
$smtp_transports->{ $smtp_server->id // 'default' } ||= $smtp_server->transport; |
1495 |
my $smtp_transport = $smtp_transports->{ $smtp_server->id // 'default' }; |
1493 |
my $smtp_transport = $smtp_transports->{ $smtp_server->id // 'default' }; |
1496 |
|
1494 |
|
1497 |
_update_message_from_address($message->{'message_id'},$email->email->header('From') ) |
1495 |
_update_message_from_address( $message->{'message_id'}, $email->email->header('From') ) |
1498 |
if !$message->{from_address} |
1496 |
if !$message->{from_address} |
1499 |
|| $message->{from_address} ne $email->email->header('From'); |
1497 |
|| $message->{from_address} ne $email->email->header('From'); |
1500 |
|
1498 |
|
1501 |
try { |
1499 |
try { |
1502 |
$email->send_or_die({ transport => $smtp_transport }); |
1500 |
$email->send_or_die({ transport => $smtp_transport }); |