View | Details | Raw Unified | Return to bug 22343
Collapse All | Expand All

(-)a/C4/Letters.pm (-54 / +120 lines)
Lines 20-32 package C4::Letters; Link Here
20
use Modern::Perl;
20
use Modern::Perl;
21
21
22
use MIME::Lite;
22
use MIME::Lite;
23
use Mail::Sendmail;
24
use Date::Calc qw( Add_Delta_Days );
23
use Date::Calc qw( Add_Delta_Days );
24
use Email::Sender::Simple qw(sendmail);
25
use Encode;
25
use Encode;
26
use Carp;
26
use Carp;
27
use Template;
27
use Template;
28
use Module::Load::Conditional qw(can_load);
28
use Module::Load::Conditional qw(can_load);
29
29
30
use Try::Tiny;
31
30
use C4::Members;
32
use C4::Members;
31
use C4::Log;
33
use C4::Log;
32
use C4::SMS;
34
use C4::SMS;
Lines 39-44 use Koha::Notice::Messages; Link Here
39
use Koha::Notice::Templates;
41
use Koha::Notice::Templates;
40
use Koha::DateUtils qw( format_sqldatetime dt_from_string );
42
use Koha::DateUtils qw( format_sqldatetime dt_from_string );
41
use Koha::Patrons;
43
use Koha::Patrons;
44
use Koha::SMTP::Servers;
42
use Koha::Subscriptions;
45
use Koha::Subscriptions;
43
46
44
use vars qw(@ISA @EXPORT @EXPORT_OK %EXPORT_TAGS);
47
use vars qw(@ISA @EXPORT @EXPORT_OK %EXPORT_TAGS);
Lines 338-364 sub SendAlerts { Link Here
338
            ) or return;
341
            ) or return;
339
342
340
            # ... then send mail
343
            # ... then send mail
341
            my $message = Koha::Email->new();
344
            my $mail = Koha::Email->create(
342
            my %mail = $message->create_message_headers(
343
                {
345
                {
344
                    to      => $email,
346
                    to      => $email,
345
                    from    => $library->branchemail,
347
                    from    => $library->branchemail,
346
                    replyto => $library->branchreplyto,
348
                    replyto => $library->branchreplyto,
347
                    sender  => $library->branchreturnpath,
349
                    sender  => $library->branchreturnpath,
348
                    subject => Encode::encode( "UTF-8", "" . $letter->{title} ),
350
                    subject => Encode::encode( "UTF-8", "" . $letter->{title} ),
349
                    message => $letter->{'is_html'}
350
                                ? _wrap_html( Encode::encode( "UTF-8", $letter->{'content'} ),
351
                                              Encode::encode( "UTF-8", "" . $letter->{'title'} ))
352
                                : Encode::encode( "UTF-8", "" . $letter->{'content'} ),
353
                    contenttype => $letter->{'is_html'}
354
                                    ? 'text/html; charset="utf-8"'
355
                                    : 'text/plain; charset="utf-8"',
356
                }
351
                }
357
            );
352
            );
358
            unless( Mail::Sendmail::sendmail(%mail) ) {
353
359
                carp $Mail::Sendmail::error;
354
            if ( $letter->{is_html} ) {
360
                return { error => $Mail::Sendmail::error };
355
                $mail->html_body(
356
                    _wrap_html(
357
                        Encode::encode( "UTF-8", $letter->{content} ),
358
                        Encode::encode( "UTF-8", "" . $letter->{title} )
359
                    )
360
                );
361
            }
361
            }
362
            else {
363
                $mail->text_body(
364
                    Encode::encode( "UTF-8", "" . $letter->{'content'} )
365
                );
366
            }
367
368
            try {
369
                my $smtp_server = Koha::SMTP::Servers->get_effective_server({ library => $library });
370
                Email::Sender::Simple::sendmail( $mail, { transport => $smtp_server->transport } );
371
            }
372
            catch {
373
                carp "$_";
374
                return { error => "$_" };
375
            };
362
        }
376
        }
363
    }
377
    }
364
    elsif ( $type eq 'claimacquisition' or $type eq 'claimissues' or $type eq 'orderacquisition' ) {
378
    elsif ( $type eq 'claimacquisition' or $type eq 'claimissues' or $type eq 'orderacquisition' ) {
Lines 477-484 sub SendAlerts { Link Here
477
491
478
        # ... then send mail
492
        # ... then send mail
479
        my $library = Koha::Libraries->find( $userenv->{branch} );
493
        my $library = Koha::Libraries->find( $userenv->{branch} );
480
        my $email = Koha::Email->new();
494
        my $mail = Koha::Email->create(
481
        my %mail = $email->create_message_headers(
482
            {
495
            {
483
                to => join( ',', @email ),
496
                to => join( ',', @email ),
484
                cc => join( ',', @cc ),
497
                cc => join( ',', @cc ),
Lines 487-514 sub SendAlerts { Link Here
487
                        C4::Context->preference("ClaimsBccCopy")
500
                        C4::Context->preference("ClaimsBccCopy")
488
                          && ( $type eq 'claimacquisition'
501
                          && ( $type eq 'claimacquisition'
489
                            || $type eq 'claimissues' )
502
                            || $type eq 'claimissues' )
490
                    ) ? ( bcc => $userenv->{emailaddress} )
503
                    )
504
                    ? ( bcc => $userenv->{emailaddress} )
491
                    : ()
505
                    : ()
492
                ),
506
                ),
493
                from => $library->branchemail
507
                from => $library->branchemail
494
                  || C4::Context->preference('KohaAdminEmailAddress'),
508
                  || C4::Context->preference('KohaAdminEmailAddress'),
495
                subject => Encode::encode( "UTF-8", "" . $letter->{title} ),
509
                subject => Encode::encode( "UTF-8", "" . $letter->{title} ),
496
                message => $letter->{'is_html'} ? _wrap_html(
497
                    Encode::encode( "UTF-8", $letter->{'content'} ),
498
                    Encode::encode( "UTF-8", "" . $letter->{'title'} )
499
                  )
500
                : Encode::encode( "UTF-8", "" . $letter->{'content'} ),
501
                contenttype => $letter->{'is_html'}
502
                ? 'text/html; charset="utf-8"'
503
                : 'text/plain; charset="utf-8"',
504
            }
510
            }
505
        );
511
        );
506
512
507
        unless ( Mail::Sendmail::sendmail(%mail) ) {
513
        if ( $letter->{is_html} ) {
508
            carp $Mail::Sendmail::error;
514
            $mail->html_body(
509
            return { error => $Mail::Sendmail::error };
515
                _wrap_html(
516
                    Encode::encode( "UTF-8", $letter->{'content'} ),
517
                    Encode::encode( "UTF-8", "" . $letter->{'title'} )
518
                )
519
            );
520
        }
521
        else {
522
            $mail->text_body(
523
                Encode::encode( "UTF-8", "" . $letter->{'content'} ) );
510
        }
524
        }
511
525
526
        try {
527
            my $smtp_server = Koha::SMTP::Servers->get_effective_server({ library => $library });
528
            Email::Sender::Simple::sendmail( $mail, { transport => $smtp_server->transport } );
529
        }
530
        catch {
531
            carp "$_";
532
            return { error => "$_" };
533
        };
534
512
        logaction(
535
        logaction(
513
            "ACQUISITION",
536
            "ACQUISITION",
514
            $action,
537
            $action,
Lines 523-549 sub SendAlerts { Link Here
523
    }
546
    }
524
   # send an "account details" notice to a newly created user
547
   # send an "account details" notice to a newly created user
525
    elsif ( $type eq 'members' ) {
548
    elsif ( $type eq 'members' ) {
526
        my $library = Koha::Libraries->find( $externalid->{branchcode} )->unblessed;
549
        my $library = Koha::Libraries->find( $externalid->{branchcode} );
527
        my $letter = GetPreparedLetter (
550
        my $letter = GetPreparedLetter (
528
            module => 'members',
551
            module => 'members',
529
            letter_code => $letter_code,
552
            letter_code => $letter_code,
530
            branchcode => $externalid->{'branchcode'},
553
            branchcode => $externalid->{'branchcode'},
531
            lang       => $externalid->{lang} || 'default',
554
            lang       => $externalid->{lang} || 'default',
532
            tables => {
555
            tables => {
533
                'branches'    => $library,
556
                'branches'    => $library->unblessed,
534
                'borrowers' => $externalid->{'borrowernumber'},
557
                'borrowers' => $externalid->{'borrowernumber'},
535
            },
558
            },
536
            substitute => { 'borrowers.password' => $externalid->{'password'} },
559
            substitute => { 'borrowers.password' => $externalid->{'password'} },
537
            want_librarian => 1,
560
            want_librarian => 1,
538
        ) or return;
561
        ) or return;
539
        return { error => "no_email" } unless $externalid->{'emailaddr'};
562
        return { error => "no_email" } unless $externalid->{'emailaddr'};
540
        my $email = Koha::Email->new();
563
        my $mail = Koha::Email->create(
541
        my %mail  = $email->create_message_headers(
542
            {
564
            {
543
                to      => $externalid->{'emailaddr'},
565
                to      => $externalid->{'emailaddr'},
544
                from    => $library->{branchemail},
566
                from    => $library->branchemail,
545
                replyto => $library->{branchreplyto},
567
                replyto => $library->branchreplyto,
546
                sender  => $library->{branchreturnpath},
568
                sender  => $library->branchreturnpath,
547
                subject => Encode::encode( "UTF-8", "" . $letter->{'title'} ),
569
                subject => Encode::encode( "UTF-8", "" . $letter->{'title'} ),
548
                message => $letter->{'is_html'}
570
                message => $letter->{'is_html'}
549
                            ? _wrap_html( Encode::encode( "UTF-8", $letter->{'content'} ),
571
                            ? _wrap_html( Encode::encode( "UTF-8", $letter->{'content'} ),
Lines 554-563 sub SendAlerts { Link Here
554
                                : 'text/plain; charset="utf-8"',
576
                                : 'text/plain; charset="utf-8"',
555
            }
577
            }
556
        );
578
        );
557
        unless( Mail::Sendmail::sendmail(%mail) ) {
579
        try {
558
            carp $Mail::Sendmail::error;
580
            my $smtp_server = Koha::SMTP::Servers->get_effective_server({ library => $library });
559
            return { error => $Mail::Sendmail::error };
581
            Email::Sender::Simple::sendmail( $mail, { transport => $smtp_server->transport } );
560
        }
582
        }
583
        catch {
584
            carp "$_";
585
            return { error => "$_" };
586
        };
561
    }
587
    }
562
588
563
    # If we come here, return an OK status
589
    # If we come here, return an OK status
Lines 1296-1312 sub _send_message_by_email { Link Here
1296
    my $content = encode('UTF-8', $message->{'content'});
1322
    my $content = encode('UTF-8', $message->{'content'});
1297
    my $content_type = $message->{'content_type'} || 'text/plain; charset="UTF-8"';
1323
    my $content_type = $message->{'content_type'} || 'text/plain; charset="UTF-8"';
1298
    my $is_html = $content_type =~ m/html/io;
1324
    my $is_html = $content_type =~ m/html/io;
1325
1299
    my $branch_email = undef;
1326
    my $branch_email = undef;
1300
    my $branch_replyto = undef;
1327
    my $branch_replyto = undef;
1301
    my $branch_returnpath = undef;
1328
    my $branch_returnpath = undef;
1329
    my $library;
1330
1302
    if ($patron) {
1331
    if ($patron) {
1303
        my $library = $patron->library;
1332
        $library           = $patron->library;
1304
        $branch_email      = $library->branchemail;
1333
        $branch_email      = $library->branchemail;
1305
        $branch_replyto    = $library->branchreplyto;
1334
        $branch_replyto    = $library->branchreplyto;
1306
        $branch_returnpath = $library->branchreturnpath;
1335
        $branch_returnpath = $library->branchreturnpath;
1307
    }
1336
    }
1308
    my $email = Koha::Email->new();
1337
1309
    my %sendmail_params = $email->create_message_headers(
1338
    my $email = Koha::Email->create(
1310
        {
1339
        {
1311
            to => $to_address,
1340
            to => $to_address,
1312
            (
1341
            (
Lines 1314-1342 sub _send_message_by_email { Link Here
1314
                ? ( bcc => C4::Context->preference('NoticeBcc') )
1343
                ? ( bcc => C4::Context->preference('NoticeBcc') )
1315
                : ()
1344
                : ()
1316
            ),
1345
            ),
1317
            from    => $message->{'from_address'} || $branch_email,
1346
            from    => $message->{'from_address'}  || $branch_email,
1318
            replyto => $message->{'reply_address'} || $branch_replyto,
1347
            replyto => $message->{'reply_address'} || $branch_replyto,
1319
            sender  => $branch_returnpath,
1348
            sender  => $branch_returnpath,
1320
            subject => $subject,
1349
            subject => $subject
1321
            message => $is_html ? _wrap_html( $content, $subject ) : $content,
1322
            contenttype => $content_type
1323
        }
1350
        }
1324
    );
1351
    );
1325
1352
1326
    $sendmail_params{'Auth'} = {user => $username, pass => $password, method => $method} if $username;
1353
    if ( $is_html ) {
1354
        $email->html_body(
1355
            _wrap_html( $content, $subject )
1356
        );
1357
    }
1358
    else {
1359
        $email->text_body( $content );
1360
    }
1361
1362
    my $smtp_server;
1363
    if ( $library ) {
1364
        $smtp_server = Koha::SMTP::Servers->get_effective_server({ library => $library });
1365
    }
1366
    else {
1367
        $smtp_server = Koha::SMTP::Servers->get_default;
1368
    }
1327
1369
1328
    _update_message_to_address($message->{'message_id'},$sendmail_params{To}) if !$message->{to_address} || $message->{to_address} ne $sendmail_params{To}; #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 create_message_headers
1370
    if ( $username ) {
1371
        $smtp_server->set(
1372
            {
1373
                sasl_username => $username,
1374
                sasl_password => $password,
1375
            }
1376
        );
1377
    }
1329
1378
1330
    if ( Mail::Sendmail::sendmail( %sendmail_params ) ) {
1379
# if initial message address was empty, coming here means that a to address was found and
1331
        _set_message_status( { message_id => $message->{'message_id'},
1380
# queue should be updated; same if to address was overriden by create_message_headers
1332
                status     => 'sent' } );
1381
    _update_message_to_address( $message->{'message_id'}, $email->email->header('To') )
1382
      if !$message->{to_address}
1383
      || $message->{to_address} ne $email->email->header('To');
1384
1385
    try {
1386
        Email::Sender::Simple::sendmail( $email, { transport => $smtp_server->transport } );
1387
1388
        _set_message_status(
1389
            {
1390
                message_id => $message->{'message_id'},
1391
                status     => 'sent'
1392
            }
1393
        );
1333
        return 1;
1394
        return 1;
1334
    } else {
1335
        _set_message_status( { message_id => $message->{'message_id'},
1336
                status     => 'failed' } );
1337
        carp $Mail::Sendmail::error;
1338
        return;
1339
    }
1395
    }
1396
    catch {
1397
        _set_message_status(
1398
            {
1399
                message_id => $message->{'message_id'},
1400
                status     => 'failed'
1401
            }
1402
        );
1403
        carp "$_";
1404
        return;
1405
    };
1340
}
1406
}
1341
1407
1342
sub _wrap_html {
1408
sub _wrap_html {
(-)a/t/db_dependent/Letters.t (-22 / +46 lines)
Lines 24-36 use Test::Warn; Link Here
24
24
25
use MARC::Record;
25
use MARC::Record;
26
26
27
my %mail;
27
my ( $email_object, $sendmail_params );
28
my $module = new Test::MockModule('Mail::Sendmail');
28
29
$module->mock(
29
my $email_sender_module = Test::MockModule->new('Email::Sender::Simple');
30
$email_sender_module->mock(
30
    'sendmail',
31
    'sendmail',
31
    sub {
32
    sub {
33
        ( $email_object, $sendmail_params ) = @_;
32
        warn "Fake sendmail";
34
        warn "Fake sendmail";
33
        %mail = @_;
34
    }
35
    }
35
);
36
);
36
37
Lines 444-451 warning_is { Link Here
444
    "Fake sendmail",
445
    "Fake sendmail",
445
    "SendAlerts is using the mocked sendmail routine (orderacquisition)";
446
    "SendAlerts is using the mocked sendmail routine (orderacquisition)";
446
is($err, 1, "Successfully sent order.");
447
is($err, 1, "Successfully sent order.");
447
is($mail{'To'}, 'testemail@mydomain.com', "mailto correct in sent order");
448
is($email_object->email->header('To'), 'testemail@mydomain.com', "mailto correct in sent order");
448
is($mail{'Message'}, 'my vendor|John Smith|Ordernumber ' . $ordernumber . ' (Silence in the library) (1 ordered)', 'Order notice text constructed successfully');
449
is($email_object->email->body, 'my vendor|John Smith|Ordernumber ' . $ordernumber . ' (Silence in the library) (1 ordered)', 'Order notice text constructed successfully');
449
450
450
$dbh->do(q{DELETE FROM letter WHERE code = 'TESTACQORDER';});
451
$dbh->do(q{DELETE FROM letter WHERE code = 'TESTACQORDER';});
451
warning_like {
452
warning_like {
Lines 462-469 warning_is { Link Here
462
    "SendAlerts is using the mocked sendmail routine";
463
    "SendAlerts is using the mocked sendmail routine";
463
464
464
is($err, 1, "Successfully sent claim");
465
is($err, 1, "Successfully sent claim");
465
is($mail{'To'}, 'testemail@mydomain.com', "mailto correct in sent claim");
466
is($email_object->email->header('To'), 'testemail@mydomain.com', "mailto correct in sent claim");
466
is($mail{'Message'}, 'my vendor|John Smith|Ordernumber ' . $ordernumber . ' (Silence in the library) (1 ordered)', 'Claim notice text constructed successfully');
467
is($email_object->email->body, 'my vendor|John Smith|Ordernumber ' . $ordernumber . ' (Silence in the library) (1 ordered)', 'Claim notice text constructed successfully');
467
}
468
}
468
469
469
{
470
{
Lines 496-509 my $borrowernumber = $patron->borrowernumber; Link Here
496
my $subscription = Koha::Subscriptions->find( $subscriptionid );
497
my $subscription = Koha::Subscriptions->find( $subscriptionid );
497
$subscription->add_subscriber( $patron );
498
$subscription->add_subscriber( $patron );
498
499
500
t::lib::Mocks::mock_userenv({ branch => $library->{branchcode} });
499
my $err2;
501
my $err2;
500
warning_is {
502
warning_is {
501
$err2 = SendAlerts( 'issue', $serial->{serialid}, 'RLIST' ) }
503
$err2 = SendAlerts( 'issue', $serial->{serialid}, 'RLIST' ) }
502
    "Fake sendmail",
504
    "Fake sendmail",
503
    "SendAlerts is using the mocked sendmail routine";
505
    "SendAlerts is using the mocked sendmail routine";
506
504
is($err2, 1, "Successfully sent serial notification");
507
is($err2, 1, "Successfully sent serial notification");
505
is($mail{'To'}, 'john.smith@test.de', "mailto correct in sent serial notification");
508
is($email_object->email->header('To'), 'john.smith@test.de', "mailto correct in sent serial notification");
506
is($mail{'Message'}, 'Silence in the library,'.$subscriptionid.',No. 0', 'Serial notification text constructed successfully');
509
is($email_object->email->body, 'Silence in the library,'.$subscriptionid.',No. 0', 'Serial notification text constructed successfully');
507
510
508
t::lib::Mocks::mock_preference( 'SendAllEmailsTo', 'robert.tables@mail.com' );
511
t::lib::Mocks::mock_preference( 'SendAllEmailsTo', 'robert.tables@mail.com' );
509
512
Lines 512-523 warning_is { Link Here
512
$err3 = SendAlerts( 'issue', $serial->{serialid}, 'RLIST' ) }
515
$err3 = SendAlerts( 'issue', $serial->{serialid}, 'RLIST' ) }
513
    "Fake sendmail",
516
    "Fake sendmail",
514
    "SendAlerts is using the mocked sendmail routine";
517
    "SendAlerts is using the mocked sendmail routine";
515
is($mail{'To'}, 'robert.tables@mail.com', "mailto address overwritten by SendAllMailsTo preference");
518
is($email_object->email->header('To'), 'robert.tables@mail.com', "mailto address overwritten by SendAllMailsTo preference");
516
}
519
}
517
t::lib::Mocks::mock_preference( 'SendAllEmailsTo', '' );
520
t::lib::Mocks::mock_preference( 'SendAllEmailsTo', '' );
518
521
519
subtest 'SendAlerts - claimissue' => sub {
522
subtest 'SendAlerts - claimissue' => sub {
520
    plan tests => 8;
523
    plan tests => 9;
521
524
522
    use C4::Serials;
525
    use C4::Serials;
523
526
Lines 585-593 subtest 'SendAlerts - claimissue' => sub { Link Here
585
        $err = SendAlerts( 'claimissues', \@serialids , 'TESTSERIALCLAIM' ) }
588
        $err = SendAlerts( 'claimissues', \@serialids , 'TESTSERIALCLAIM' ) }
586
        "Fake sendmail",
589
        "Fake sendmail",
587
        "SendAlerts is using the mocked sendmail routine (claimissues)";
590
        "SendAlerts is using the mocked sendmail routine (claimissues)";
588
    is($err, 1, "Successfully sent claim");
591
    is( $err, 1, "Successfully sent claim" );
589
    is($mail{'To'}, 'testemail@mydomain.com', "mailto correct in sent claim");
592
    is( $email_object->email->header('To'),
590
    is($mail{'Message'}, "$serialids[0]|2013-01-01|Silence in the library|xxxx-yyyy", 'Serial claim letter for 1 issue constructed successfully');
593
        'testemail@mydomain.com', "mailto correct in sent claim" );
594
    is(
595
        $email_object->email->body,
596
        "$serialids[0]|2013-01-01|Silence in the library|xxxx-yyyy",
597
        'Serial claim letter for 1 issue constructed successfully'
598
    );
591
    }
599
    }
592
600
593
    {
601
    {
Lines 597-604 subtest 'SendAlerts - claimissue' => sub { Link Here
597
    ($serials_count, @serials) = GetSerials($subscriptionid);
605
    ($serials_count, @serials) = GetSerials($subscriptionid);
598
    push @serialids, ($serials[1]->{serialid});
606
    push @serialids, ($serials[1]->{serialid});
599
607
600
    $err = SendAlerts( 'claimissues', \@serialids , 'TESTSERIALCLAIM' );
608
    warning_is { $err = SendAlerts( 'claimissues', \@serialids, 'TESTSERIALCLAIM' ); }
601
    is($mail{'Message'}, "$serialids[0]|2013-01-01|Silence in the library|xxxx-yyyy\n$serialids[1]|2013-01-01|Silence in the library|xxxx-yyyy", "Serial claim letter for 2 issues constructed successfully");
609
        "Fake sendmail",
610
        "SendAlerts is using the mocked sendmail routine (claimissues)";
611
612
    is(
613
        $email_object->email->body,
614
        "$serialids[0]|2013-01-01|Silence in the library|xxxx-yyyy"
615
          . $email_object->email->crlf
616
          . "$serialids[1]|2013-01-01|Silence in the library|xxxx-yyyy",
617
        "Serial claim letter for 2 issues constructed successfully"
618
    );
602
619
603
    $dbh->do(q{DELETE FROM letter WHERE code = 'TESTSERIALCLAIM';});
620
    $dbh->do(q{DELETE FROM letter WHERE code = 'TESTSERIALCLAIM';});
604
    warning_like {
621
    warning_like {
Lines 718-724 subtest 'TranslateNotices' => sub { Link Here
718
735
719
subtest 'SendQueuedMessages' => sub {
736
subtest 'SendQueuedMessages' => sub {
720
737
721
    plan tests => 6;
738
    plan tests => 9;
722
739
723
    t::lib::Mocks::mock_preference( 'SMSSendDriver', 'Email' );
740
    t::lib::Mocks::mock_preference( 'SMSSendDriver', 'Email' );
724
    t::lib::Mocks::mock_preference('EmailSMSSendDriverFromAddress', '');
741
    t::lib::Mocks::mock_preference('EmailSMSSendDriverFromAddress', '');
Lines 735-741 subtest 'SendQueuedMessages' => sub { Link Here
735
    my $sms_pro = $builder->build_object({ class => 'Koha::SMS::Providers', value => { domain => 'kidclamp.rocks' } });
752
    my $sms_pro = $builder->build_object({ class => 'Koha::SMS::Providers', value => { domain => 'kidclamp.rocks' } });
736
    $patron->set( { smsalertnumber => '5555555555', sms_provider_id => $sms_pro->id() } )->store;
753
    $patron->set( { smsalertnumber => '5555555555', sms_provider_id => $sms_pro->id() } )->store;
737
    $message_id = C4::Letters::EnqueueLetter($my_message); #using datas set around line 95 and forward
754
    $message_id = C4::Letters::EnqueueLetter($my_message); #using datas set around line 95 and forward
738
    C4::Letters::SendQueuedMessages();
755
756
    warning_is { C4::Letters::SendQueuedMessages(); }
757
        "Fake sendmail",
758
        "SendAlerts is using the mocked sendmail routine (claimissues)";
739
759
740
    my $message = $schema->resultset('MessageQueue')->search({
760
    my $message = $schema->resultset('MessageQueue')->search({
741
        borrowernumber => $borrowernumber,
761
        borrowernumber => $borrowernumber,
Lines 754-760 subtest 'SendQueuedMessages' => sub { Link Here
754
    t::lib::Mocks::mock_preference('EmailSMSSendDriverFromAddress', 'override@example.com');
774
    t::lib::Mocks::mock_preference('EmailSMSSendDriverFromAddress', 'override@example.com');
755
775
756
    $message_id = C4::Letters::EnqueueLetter($my_message);
776
    $message_id = C4::Letters::EnqueueLetter($my_message);
757
    C4::Letters::SendQueuedMessages();
777
    warning_is { C4::Letters::SendQueuedMessages(); }
778
        "Fake sendmail",
779
        "SendAlerts is using the mocked sendmail routine (claimissues)";
758
780
759
    $message = $schema->resultset('MessageQueue')->search({
781
    $message = $schema->resultset('MessageQueue')->search({
760
        borrowernumber => $borrowernumber,
782
        borrowernumber => $borrowernumber,
Lines 777-783 subtest 'SendQueuedMessages' => sub { Link Here
777
    });
799
    });
778
    is ( $number_attempted, 0, 'There were no password reset messages for SendQueuedMessages to attempt.' );
800
    is ( $number_attempted, 0, 'There were no password reset messages for SendQueuedMessages to attempt.' );
779
801
780
    C4::Letters::SendQueuedMessages();
802
    warning_is { C4::Letters::SendQueuedMessages(); }
803
        "Fake sendmail",
804
        "SendAlerts is using the mocked sendmail routine (claimissues)";
805
781
    my $sms_message_address = $schema->resultset('MessageQueue')->search({
806
    my $sms_message_address = $schema->resultset('MessageQueue')->search({
782
        borrowernumber => $borrowernumber,
807
        borrowernumber => $borrowernumber,
783
        status => 'sent'
808
        status => 'sent'
784
- 

Return to bug 22343