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

(-)a/C4/Letters.pm (-9 / +12 lines)
Lines 480-497 sub SendAlerts { Link Here
480
480
481
        # ... then send mail
481
        # ... then send mail
482
        my $library = Koha::Libraries->find( $userenv->{branch} );
482
        my $library = Koha::Libraries->find( $userenv->{branch} );
483
        my %mail = (
483
        my $email = Koha::Email->new();
484
            To => join( ',', @email),
484
        my %mail = $email->create_message_headers(
485
            Cc             => join( ',', @cc),
485
            {
486
            From           => $library->branchemail || C4::Context->preference('KohaAdminEmailAddress'),
486
                to      => join( ',', @email),
487
            Subject        => Encode::encode( "UTF-8", "" . $letter->{title} ),
487
                cc      => join( ',', @cc),
488
            Message => $letter->{'is_html'}
488
                from    => $library->branchemail || C4::Context->preference('KohaAdminEmailAddress'),
489
                subject => Encode::encode( "UTF-8", "" . $letter->{title} ),
490
                message => $letter->{'is_html'}
489
                            ? _wrap_html( Encode::encode( "UTF-8", $letter->{'content'} ),
491
                            ? _wrap_html( Encode::encode( "UTF-8", $letter->{'content'} ),
490
                                          Encode::encode( "UTF-8", "" . $letter->{'title'} ))
492
                                          Encode::encode( "UTF-8", "" . $letter->{'title'} ))
491
                            : Encode::encode( "UTF-8", "" . $letter->{'content'} ),
493
                            : Encode::encode( "UTF-8", "" . $letter->{'content'} ),
492
            'Content-Type' => $letter->{'is_html'}
494
                contenttype => $letter->{'is_html'}
493
                                ? 'text/html; charset="utf-8"'
495
                                ? 'text/html; charset="utf-8"'
494
                                : 'text/plain; charset="utf-8"',
496
                                : 'text/plain; charset="utf-8"',
497
            }
495
        );
498
        );
496
499
497
        if ($type eq 'claimacquisition' || $type eq 'claimissues' ) {
500
        if ($type eq 'claimacquisition' || $type eq 'claimissues' ) {
Lines 500-506 sub SendAlerts { Link Here
500
            $mail{'Sender'} = C4::Context->preference('ReturnpathDefault')
503
            $mail{'Sender'} = C4::Context->preference('ReturnpathDefault')
501
              if C4::Context->preference('ReturnpathDefault');
504
              if C4::Context->preference('ReturnpathDefault');
502
            $mail{'Bcc'} = $userenv->{emailaddress}
505
            $mail{'Bcc'} = $userenv->{emailaddress}
503
              if C4::Context->preference("ClaimsBccCopy");
506
              if C4::Context->preference("ClaimsBccCopy") and not C4::Context->preference("SendAllEmailsTo");
504
        }
507
        }
505
508
506
        unless ( Mail::Sendmail::sendmail(%mail) ) {
509
        unless ( Mail::Sendmail::sendmail(%mail) ) {
Lines 1315-1321 sub _send_message_by_email { Link Here
1315
1318
1316
    $sendmail_params{'Auth'} = {user => $username, pass => $password, method => $method} if $username;
1319
    $sendmail_params{'Auth'} = {user => $username, pass => $password, method => $method} if $username;
1317
    if ( my $bcc = C4::Context->preference('NoticeBcc') ) {
1320
    if ( my $bcc = C4::Context->preference('NoticeBcc') ) {
1318
       $sendmail_params{ Bcc } = $bcc;
1321
       $sendmail_params{ Bcc } = C4::Context->preference("SendAllEmailsTo") || $bcc;
1319
    }
1322
    }
1320
1323
1321
    _update_message_to_address($message->{'message_id'},$to_address) unless $message->{to_address}; #if initial message address was empty, coming here means that a to address was found and queue should be updated
1324
    _update_message_to_address($message->{'message_id'},$to_address) unless $message->{to_address}; #if initial message address was empty, coming here means that a to address was found and queue should be updated
(-)a/Koha/Email.pm (+9 lines)
Lines 18-23 Link Here
18
package Koha::Email;
18
package Koha::Email;
19
19
20
use Modern::Perl;
20
use Modern::Perl;
21
use Email::Valid;
21
22
22
use base qw(Class::Accessor);
23
use base qw(Class::Accessor);
23
use C4::Context;
24
use C4::Context;
Lines 49-54 sub create_message_headers { Link Here
49
        From    => $params->{from},
50
        From    => $params->{from},
50
        charset => $params->{charset}
51
        charset => $params->{charset}
51
    );
52
    );
53
54
    if (C4::Context->preference('SendAllEmailsTo') && Email::Valid->address(C4::Context->preference('SendAllEmailsTo'))) {
55
        $mail{'To'} = C4::Context->preference('SendAllEmailsTo');
56
    }
57
    else {
58
        $mail{'Cc'} = $params->{cc};
59
    }
60
52
    if ( C4::Context->preference('ReplytoDefault') ) {
61
    if ( C4::Context->preference('ReplytoDefault') ) {
53
        $params->{replyto} ||= C4::Context->preference('ReplytoDefault');
62
        $params->{replyto} ||= C4::Context->preference('ReplytoDefault');
54
    }
63
    }
(-)a/installer/data/mysql/atomicupdate/Bug8000-SendAllEmailsTo.syspref.sql (+2 lines)
Line 0 Link Here
1
INSERT IGNORE INTO systempreferences (variable,value,options,explanation,type)
2
VALUES ('SendAllEmailsTo','',NULL,'All emails will be redirected to this email if it is not empty','free');
(-)a/installer/data/mysql/sysprefs.sql (-1 / +2 lines)
Lines 1-4 Link Here
1
INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, `type` ) VALUES
1
INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, `type('SendAllEmailsTo','',NULL,'All emails will be redirected to this email if it is not empty','free'),` ) VALUES
2
('AccountAutoReconcile','0',NULL,'If enabled, patron balances will get reconciled automatically on each transaction.','YesNo'),
2
('AccountAutoReconcile','0',NULL,'If enabled, patron balances will get reconciled automatically on each transaction.','YesNo'),
3
('AcqCreateItem','ordering','ordering|receiving|cataloguing','Define when the item is created : when ordering, when receiving, or in cataloguing module','Choice'),
3
('AcqCreateItem','ordering','ordering|receiving|cataloguing','Define when the item is created : when ordering, when receiving, or in cataloguing module','Choice'),
4
('AcqEnableFiles','0',NULL,'If enabled, allows librarians to upload and attach arbitrary files to invoice records.','YesNo'),
4
('AcqEnableFiles','0',NULL,'If enabled, allows librarians to upload and attach arbitrary files to invoice records.','YesNo'),
Lines 530-535 INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` Link Here
530
('SelfCheckoutByLogin','1',NULL,'Have patrons login into the web-based self checkout system with their username/password or their cardnumber','YesNo'),
530
('SelfCheckoutByLogin','1',NULL,'Have patrons login into the web-based self checkout system with their username/password or their cardnumber','YesNo'),
531
('SelfCheckReceiptPrompt','1','NULL','If ON, print receipt dialog pops up when self checkout is finished','YesNo'),
531
('SelfCheckReceiptPrompt','1','NULL','If ON, print receipt dialog pops up when self checkout is finished','YesNo'),
532
('SelfCheckTimeout','120','','Define the number of seconds before the Web-based Self Checkout times out a patron','Integer'),
532
('SelfCheckTimeout','120','','Define the number of seconds before the Web-based Self Checkout times out a patron','Integer'),
533
('SendAllEmailsTo','',NULL,'All emails will be redirected to this email if it is not empty','free'),
533
('SeparateHoldings','0',NULL,'Separate current branch holdings from other holdings','YesNo'),
534
('SeparateHoldings','0',NULL,'Separate current branch holdings from other holdings','YesNo'),
534
('SeparateHoldingsBranch','homebranch','homebranch|holdingbranch','Branch used to separate holdings','Choice'),
535
('SeparateHoldingsBranch','homebranch','homebranch|holdingbranch','Branch used to separate holdings','Choice'),
535
('SessionRestrictionByIP','1','Check for change in remote IP address for session security. Disable only when remote IP address changes frequently.','','YesNo'),
536
('SessionRestrictionByIP','1','Check for change in remote IP address for session security. Disable only when remote IP address changes frequently.','','YesNo'),
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/admin.pref (+5 lines)
Lines 16-21 Administration: Link Here
16
              class: email
16
              class: email
17
            - "If you leave this empty, the From address will be used (often defaulting to the admin address)."
17
            - "If you leave this empty, the From address will be used (often defaulting to the admin address)."
18
        -
18
        -
19
            - "Email to redirect all messages to: "
20
            - pref: SendAllEmailsTo
21
              class: email
22
            - "(Leave this field empty to send messages to their normal recipient)"
23
        -
19
            - "How much debugging information to show in the browser when an internal error occurs: "
24
            - "How much debugging information to show in the browser when an internal error occurs: "
20
            - pref: DebugLevel
25
            - pref: DebugLevel
21
              default: 0
26
              default: 0
(-)a/t/db_dependent/Letters.t (-1 / +11 lines)
Lines 233-238 is( $letter14206_c->{message_transport_type}, 'print', 'Bug 14206 - correct mtt Link Here
233
233
234
# GetPreparedLetter
234
# GetPreparedLetter
235
t::lib::Mocks::mock_preference('OPACBaseURL', 'http://thisisatest.com');
235
t::lib::Mocks::mock_preference('OPACBaseURL', 'http://thisisatest.com');
236
t::lib::Mocks::mock_preference( 'SendAllEmailsTo', '' );
236
237
237
my $sms_content = 'This is a SMS for an <<status>>';
238
my $sms_content = 'This is a SMS for an <<status>>';
238
$dbh->do( q|INSERT INTO letter(branchcode,module,code,name,is_html,title,content,message_transport_type) VALUES (?,'my module','my code','my name',1,'my title',?,'sms')|, undef, $library->{branchcode}, $sms_content );
239
$dbh->do( q|INSERT INTO letter(branchcode,module,code,name,is_html,title,content,message_transport_type) VALUES (?,'my module','my code','my name',1,'my title',?,'sms')|, undef, $library->{branchcode}, $sms_content );
Lines 497-503 $err2 = SendAlerts( 'issue', $serial->{serialid}, 'RLIST' ) } Link Here
497
is($err2, 1, "Successfully sent serial notification");
498
is($err2, 1, "Successfully sent serial notification");
498
is($mail{'To'}, 'john.smith@test.de', "mailto correct in sent serial notification");
499
is($mail{'To'}, 'john.smith@test.de', "mailto correct in sent serial notification");
499
is($mail{'Message'}, 'Silence in the library,'.$subscriptionid.',No. 0', 'Serial notification text constructed successfully');
500
is($mail{'Message'}, 'Silence in the library,'.$subscriptionid.',No. 0', 'Serial notification text constructed successfully');
501
502
t::lib::Mocks::mock_preference( 'SendAllEmailsTo', 'robert.tables@mail.com' );
503
504
my $err3;
505
warning_is {
506
$err3 = SendAlerts( 'issue', $serial->{serialid}, 'RLIST' ) }
507
    "Fake sendmail",
508
    "SendAlerts is using the mocked sendmail routine";
509
is($mail{'To'}, 'robert.tables@mail.com', "mailto address overwritten by SendAllMailsTo preference");
500
}
510
}
511
t::lib::Mocks::mock_preference( 'SendAllEmailsTo', '' );
501
512
502
subtest 'SendAlerts - claimissue' => sub {
513
subtest 'SendAlerts - claimissue' => sub {
503
    plan tests => 8;
514
    plan tests => 8;
504
- 

Return to bug 8000