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

(-)a/Koha/Library.pm (+23 lines)
Lines 143-154 sub smtp_server { Link Here
143
    return $self;
143
    return $self;
144
}
144
}
145
145
146
=head3 from_email_address
147
148
  my $from_email = Koha::Library->from_email_address;
149
150
Returns the official 'from' email address for the branch.
151
152
It may well be a 'noreply' or other inaccessible local domain 
153
address that is being used to satisfy spam protection filters.
154
155
=cut
156
157
sub from_email_address {
158
    my ($self) = @_;
159
160
    return
161
         $self->branchemail
162
      || C4::Context->preference('KohaAdminEmailAddress')
163
      || undef;
164
}
165
146
=head3 inbound_email_address
166
=head3 inbound_email_address
147
167
148
  my $to_email = Koha::Library->inbound_email_address;
168
  my $to_email = Koha::Library->inbound_email_address;
149
169
150
Returns an effective email address which should be accessible to librarians at the branch.
170
Returns an effective email address which should be accessible to librarians at the branch.
151
171
172
NOTE: This is the address to use for 'reply_to' or 'to' fields; It should not usually be 
173
used as the 'from' address for emails as it may lead to mail being caught by spam filters.
174
152
=cut
175
=cut
153
176
154
sub inbound_email_address {
177
sub inbound_email_address {
(-)a/Koha/Patron.pm (-2 / +2 lines)
Lines 1874-1880 sub queue_notice { Link Here
1874
    return unless exists $params->{message_name} xor $params->{message_transports}; # We only want one of these
1874
    return unless exists $params->{message_name} xor $params->{message_transports}; # We only want one of these
1875
1875
1876
    my $library = Koha::Libraries->find( $letter_params->{branchcode} );
1876
    my $library = Koha::Libraries->find( $letter_params->{branchcode} );
1877
    my $admin_email_address = $library->inbound_email_address;
1877
    my $from_email_address = $library->from_email_address;
1878
1878
1879
    my @message_transports;
1879
    my @message_transports;
1880
    my $letter_code;
1880
    my $letter_code;
Lines 1909-1915 sub queue_notice { Link Here
1909
        C4::Letters::EnqueueLetter({
1909
        C4::Letters::EnqueueLetter({
1910
            letter => $letter,
1910
            letter => $letter,
1911
            borrowernumber => $self->borrowernumber,
1911
            borrowernumber => $self->borrowernumber,
1912
            from_address   => $admin_email_address,
1912
            from_address   => $from_email_address,
1913
            message_transport_type => $mtt
1913
            message_transport_type => $mtt
1914
        }) unless $test_mode;
1914
        }) unless $test_mode;
1915
        push @{$return{sent}}, $mtt;
1915
        push @{$return{sent}}, $mtt;
(-)a/t/db_dependent/Koha/Libraries.t (-2 / +31 lines)
Lines 19-25 Link Here
19
19
20
use Modern::Perl;
20
use Modern::Perl;
21
21
22
use Test::More tests => 11;
22
use Test::More tests => 12;
23
23
24
use C4::Biblio;
24
use C4::Biblio;
25
use C4::Context;
25
use C4::Context;
Lines 119-124 subtest '->get_effective_marcorgcode' => sub { Link Here
119
    $schema->storage->txn_rollback;
119
    $schema->storage->txn_rollback;
120
};
120
};
121
121
122
subtest '->from_email_address' => sub {
123
124
    plan tests => 3;
125
126
    $schema->storage->txn_begin;
127
128
    my $library_1 = $builder->build_object(
129
        {
130
            class => 'Koha::Libraries',
131
            value => {
132
                branchemail   => 'from@mybranc.com',
133
            }
134
        }
135
    );
136
137
    t::lib::Mocks::mock_preference( 'KohaAdminEmailAddress', 'admin@mylibrary.com' );
138
139
    is( $library_1->from_email_address, $library_1->branchemail,
140
       'If defined, use branches branchemail address');
141
142
    $library_1->branchemail(undef)->store();
143
    is( $library_1->from_email_address, 'admin@mylibrary.com',
144
       'Fallback to KohaAdminEmailAddress email address when branchemail is undefined');
145
146
    t::lib::Mocks::mock_preference( 'KohaAdminEmailAddress', '' );
147
    is( $library_1->from_email_address, undef,
148
       'Return undef when branchemail and KohaAdminEmailAddress are both undefined');
149
    $schema->storage->txn_rollback;
150
};
151
122
subtest '->inbound_email_address' => sub {
152
subtest '->inbound_email_address' => sub {
123
153
124
    plan tests => 5;
154
    plan tests => 5;
125
- 

Return to bug 28581