Bugzilla – Attachment 31929 Details for
Bug 9530
Allow separate 'Reply To' and 'From' email address for notices
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
[PASSED QA] Bug 9530: Making changes to C4::Letters
PASSED-QA-Bug-9530-Making-changes-to-C4Letters.patch (text/plain), 6.59 KB, created by
Martin Renvoize (ashimema)
on 2014-09-30 06:31:42 UTC
(
hide
)
Description:
[PASSED QA] Bug 9530: Making changes to C4::Letters
Filename:
MIME Type:
Creator:
Martin Renvoize (ashimema)
Created:
2014-09-30 06:31:42 UTC
Size:
6.59 KB
patch
obsolete
>From 3defd65a0093d8154af0113beb6b0b149105ddd5 Mon Sep 17 00:00:00 2001 >From: Chris Cormack <chrisc@catalyst.net.nz> >Date: Tue, 12 Aug 2014 09:54:48 +1200 >Subject: [PATCH] [PASSED QA] Bug 9530: Making changes to C4::Letters > >So notices using it (circulation, holds etc) will now use the new behaviour > >To test: > >1/ Edit the new systempreferences (ReplytoDefault and ReturnpathDefault) >2/ Optionally edit the branch the mail will be sent from, adding email addresses >3/ Test some mails, a circulation alert, an acquisitions claim, or a newly created borrower alert >4/ Check that the mails have the correct From, Replyto and ReturnPath set > The rules are > If the values are set in the branch use that, else use the syspref > >Signed-off-by: Owen Leonard <oleonard@myacpl.org> >Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com> >--- > C4/Letters.pm | 79 ++++++++++++++++++++++++++++++++++++++------------------- > 1 file changed, 53 insertions(+), 26 deletions(-) > >diff --git a/C4/Letters.pm b/C4/Letters.pm >index 912294e..a97869c 100644 >--- a/C4/Letters.pm >+++ b/C4/Letters.pm >@@ -34,6 +34,7 @@ use Koha::DateUtils; > use Date::Calc qw( Add_Delta_Days ); > use Encode; > use Carp; >+use Koha::Email; > > use vars qw($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS); > >@@ -262,11 +263,10 @@ sub SendAlerts { > # find the list of borrowers to alert > my $alerts = getalert( '', 'issue', $externalid ); > foreach (@$alerts) { >- > my $borinfo = C4::Members::GetMember('borrowernumber' => $_->{'borrowernumber'}); > my $email = $borinfo->{email} or next; > >- # warn "sending issues..."; >+# warn "sending issues..."; > my $userenv = C4::Context->userenv; > my $branchdetails = GetBranchDetail($_->{'branchcode'}); > my $letter = GetPreparedLetter ( >@@ -283,13 +283,20 @@ sub SendAlerts { > ) or return; > > # ... then send mail >- my %mail = ( >- To => $email, >- From => $branchdetails->{'branchemail'} || C4::Context->preference("KohaAdminEmailAddress"), >- Subject => Encode::encode( "utf8", "" . $letter->{title} ), >- Message => Encode::encode( "utf8", "" . $letter->{content} ), >- 'Content-Type' => 'text/plain; charset="utf8"', >- ); >+ my $message = Koha::Email->new(); >+ my %mail = $message->create_message_headers( >+ { >+ to => $email, >+ from => $branchdetails->{'branchemail'}, >+ replyto => $branchdetails->{'branchreplyto'}, >+ sender => $branchdetails->{'branchreturnpath'}, >+ subject => Encode::encode( "utf8", "" . $letter->{title} ), >+ message => >+ Encode::encode( "utf8", "" . $letter->{content} ), >+ contenttype => 'text/plain; charset="utf8"', >+ >+ } >+ ); > sendmail(%mail) or carp $Mail::Sendmail::error; > } > } >@@ -368,6 +375,11 @@ sub SendAlerts { > Message => Encode::encode( "utf8", "" . $letter->{content} ), > 'Content-Type' => 'text/plain; charset="utf8"', > ); >+ $mail{'Reply-to'} = C4::Context->preference('ReplytoDefault') >+ if C4::Context->preference('ReplytoDefault'); >+ $mail{'Sender'} = C4::Context->preference('ReturnpathDefault') >+ if C4::Context->preference('ReturnpathDefault'); >+ > sendmail(%mail) or carp $Mail::Sendmail::error; > > logaction( >@@ -396,14 +408,18 @@ sub SendAlerts { > substitute => { 'borrowers.password' => $externalid->{'password'} }, > want_librarian => 1, > ) or return; >- > return { error => "no_email" } unless $externalid->{'emailaddr'}; >- my %mail = ( >- To => $externalid->{'emailaddr'}, >- From => $branchdetails->{'branchemail'} || C4::Context->preference("KohaAdminEmailAddress"), >- Subject => Encode::encode( "utf8", $letter->{'title'} ), >- Message => Encode::encode( "utf8", $letter->{'content'} ), >- 'Content-Type' => 'text/plain; charset="utf8"', >+ my $email = Koha::Email->new(); >+ my %mail = $email->create_message_headers( >+ { >+ to => $externalid->{'emailaddr'}, >+ from => $branchdetails->{'branchemail'}, >+ replyto => $branchdetails->{'branchreplyto'}, >+ sender => $branchdetails->{'branchreturnpath'}, >+ subject => Encode::encode( "utf8", "" . $letter->{'title'} ), >+ message => Encode::encode( "utf8", "" . $letter->{'content'} ), >+ contenttype => 'text/plain; charset="utf8"' >+ } > ); > sendmail(%mail) or carp $Mail::Sendmail::error; > } >@@ -969,17 +985,28 @@ sub _send_message_by_email { > my $content = encode('utf8', $message->{'content'}); > my $content_type = $message->{'content_type'} || 'text/plain; charset="UTF-8"'; > my $is_html = $content_type =~ m/html/io; >- >- my $branch_email = ( $member ) ? GetBranchDetail( $member->{'branchcode'} )->{'branchemail'} : undef; >- >- my %sendmail_params = ( >- To => $to_address, >- From => $message->{'from_address'} || $branch_email || C4::Context->preference('KohaAdminEmailAddress'), >- Subject => $subject, >- charset => 'utf8', >- Message => $is_html ? _wrap_html($content, $subject) : $content, >- 'content-type' => $content_type, >+ my $branch_email = undef; >+ my $branch_replyto = undef; >+ my $branch_returnpath = undef; >+ if ($member){ >+ my $branchdetail = GetBranchDetail( $member->{'branchcode'} ); >+ $branch_email = $branchdetail->{'branchemail'}; >+ $branch_replyto = $branchdetail->{'branchreplyto'}; >+ $branch_returnpath = $branchdetail->{'branchreturnpath'}; >+ } >+ my $email = Koha::Email->new(); >+ my %sendmail_params = $email->create_message_headers( >+ { >+ to => $to_address, >+ from => $message->{'from_address'} || $branch_email, >+ replyto => $branch_replyto, >+ sender => $branch_returnpath, >+ subject => $subject, >+ message => $is_html ? _wrap_html( $content, $subject ) : $content, >+ contenttype => $content_type >+ } > ); >+ > $sendmail_params{'Auth'} = {user => $username, pass => $password, method => $method} if $username; > if ( my $bcc = C4::Context->preference('OverdueNoticeBcc') ) { > $sendmail_params{ Bcc } = $bcc; >-- >1.7.10.4
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 9530
:
30717
|
30718
|
30719
|
30720
|
30721
|
30722
|
30723
|
30724
|
30725
|
30740
|
30741
|
30742
|
30743
|
30760
|
30761
|
30762
|
30763
|
31169
|
31196
|
31926
|
31927
|
31928
| 31929 |
31930
|
31931
|
31932
|
31933
|
31934
|
31935
|
32799