Bugzilla – Attachment 165495 Details for
Bug 12802
Send notices using several email addresses
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 12802: Update notice_email_address method to return a list
Bug-12802-Update-noticeemailaddress-method-to-retu.patch (text/plain), 4.69 KB, created by
Martin Renvoize (ashimema)
on 2024-04-25 07:53:45 UTC
(
hide
)
Description:
Bug 12802: Update notice_email_address method to return a list
Filename:
MIME Type:
Creator:
Martin Renvoize (ashimema)
Created:
2024-04-25 07:53:45 UTC
Size:
4.69 KB
patch
obsolete
>From ae6f544abb8736c804cf4ad8083e6411b0cc3a20 Mon Sep 17 00:00:00 2001 >From: Martin Renvoize <martin.renvoize@ptfs-europe.com> >Date: Tue, 19 Dec 2023 17:09:17 +0000 >Subject: [PATCH] Bug 12802: Update notice_email_address method to return a > list > >This patch updates the notice_email_address method to return a comma >separated list of addresses as expected by Email::Sender if you wish to >send mail to multiple To addresses. > >To test: > >1. Install database update and restart services >2. Go to Koha Administration -> system preferences. Search for EmailFieldPrimary. Confirm the options show as checkboxes and you can select multiple. >3. Search for a patron. Put different email addresses in each of the possible email fields (i.e. primary email, secondary email, alternate email). >4. Make sure 'first valid' is checked in EmailFieldPrimary. >5. Go to your patron, click the More dropdown and send a welcome email. >6. In your terminal, go into the database to view the message queue. > >sudo koha-mysql instance >select * from message_queue\G > >7. Confirm your welcome email is visible, with ONLY the first valid email in > the to_address field. >8. Select other combinations of emails in EmailFieldPrimary. >9. Send another welcome email to the same patron, then run the message_queue > SQL query again. >10. Confirm your welcome email is visible and shows all selected addresses > concatenated by , in the to_address field. >11. Enable KTD to send email [1] (without email configured you will not > be able to confirm the delivery to multiple addresses). >12. Run misc/cronjobs/process_message_queue.pl to trigger sending the > queued notices from above. >13. Check that the addresses in the to_address all actually recieve the > notice. > >[1] To test sending emails using a Google account: > - Set up an App password for your Google Account > - Configure a new 'SMTP Server' under 'Administration > SMTP servers' > using the following settings where `User name` = your Google email > address and `Password` = your APP password, not your Google account > password): > > Host: smtp.gmail.com > Port: 587 > Timeout: 120 > SSL: STARTTLS > User name: GOOGLEACCOUNTUSER > Password: GOOGLEAPPPASSWORD > > - Set this server as default > >Sponsored-by: St Luke's Grammar School & Pymble Ladies' College >Signed-off-by: Brendan Gallagher <brendan@bywatersolutions.com> >Signed-off-by: Axelle Clarisse <axelle.clarisse@univ-amu.fr> >Signed-off-by: Mathieu Saby <mathsabypro@gmail.com> >Signed-off-by: Aleisha Amohia <aleisha@catalyst.net.nz> >Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com> >--- > Koha/Patron.pm | 15 +++++++++++---- > t/db_dependent/Koha/Patron.t | 5 ++++- > 2 files changed, 15 insertions(+), 5 deletions(-) > >diff --git a/Koha/Patron.pm b/Koha/Patron.pm >index e322dfdad39..e8874c597d4 100644 >--- a/Koha/Patron.pm >+++ b/Koha/Patron.pm >@@ -1619,12 +1619,19 @@ sub notice_email_address{ > my ( $self ) = @_; > > my $which_address = C4::Context->preference("EmailFieldPrimary"); >- # if syspref is set to 'first valid' (value == OFF), look up email address >- if ( $which_address eq 'OFF' ) { >- return $self->first_valid_email_address; >+ my @addresses; >+ for my $email_field ( split ",", $which_address ) { >+ >+ # if syspref is set to 'first valid' (value == OFF), look up email address >+ if ( $email_field eq 'OFF' ) { >+ return $self->first_valid_email_address; >+ } >+ >+ my $email_address = $self->$email_field; >+ push @addresses, $email_address if $email_address; > } > >- return $self->$which_address || ''; >+ return join(",",@addresses); > } > > =head3 first_valid_email_address >diff --git a/t/db_dependent/Koha/Patron.t b/t/db_dependent/Koha/Patron.t >index e07e90eaf82..583d61f292f 100755 >--- a/t/db_dependent/Koha/Patron.t >+++ b/t/db_dependent/Koha/Patron.t >@@ -1790,7 +1790,7 @@ subtest 'notify_library_of_registration()' => sub { > }; > > subtest 'notice_email_address' => sub { >- plan tests => 2; >+ plan tests => 3; > $schema->storage->txn_begin; > > my $patron = $builder->build_object({ class => 'Koha::Patrons' }); >@@ -1802,6 +1802,9 @@ subtest 'notice_email_address' => sub { > t::lib::Mocks::mock_preference( 'EmailFieldPrimary', 'emailpro' ); > is ($patron->notice_email_address, $patron->emailpro, "Koha::Patron->notice_email_address returns correct value when EmailFieldPrimary is emailpro"); > >+ t::lib::Mocks::mock_preference( 'EmailFieldPrimary', 'email,emailpro' ); >+ is ($patron->notice_email_address, $patron->email.",".$patron->emailpro, "Koha::Patron->notice_email_address returns correct value when EmailFieldPrimary is email|emailpro"); >+ > $patron->delete; > $schema->storage->txn_rollback; > }; >-- >2.44.0
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 12802
:
31058
|
31059
|
31132
|
31382
|
31383
|
31384
|
31833
|
33864
|
33865
|
33866
|
33867
|
35890
|
35891
|
35892
|
35893
|
35926
|
35927
|
35928
|
35929
|
35930
|
36055
|
36056
|
36057
|
36058
|
36059
|
39762
|
39770
|
40167
|
45476
|
45477
|
45478
|
45479
|
45480
|
45481
|
45482
|
57296
|
61878
|
61879
|
61880
|
61881
|
61882
|
61883
|
61884
|
66934
|
66935
|
66936
|
66937
|
66938
|
66939
|
66940
|
68002
|
68003
|
68004
|
68005
|
68006
|
68007
|
68008
|
68009
|
68010
|
68011
|
68012
|
68013
|
68375
|
68376
|
68377
|
68378
|
68379
|
68380
|
119016
|
149232
|
153540
|
154076
|
159780
|
159857
|
160051
|
160052
|
160090
|
160091
|
160092
|
160103
|
160104
|
160105
|
160106
|
165494
| 165495 |
165496
|
165497