Bugzilla – Attachment 5870 Details for
Bug 6973
Allow reply-to on cart emails to go to the sender of the cart
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 6973 - this forces alerts to use the message queue
Bug-6973---this-forces-alerts-to-use-the-message-q.patch (text/plain), 7.50 KB, created by
Robin Sheat
on 2011-10-13 02:58:47 UTC
(
hide
)
Description:
Bug 6973 - this forces alerts to use the message queue
Filename:
MIME Type:
Creator:
Robin Sheat
Created:
2011-10-13 02:58:47 UTC
Size:
7.50 KB
patch
obsolete
>From f05dbac4d2e2694a7c082cd4d2f7c2882fd48b89 Mon Sep 17 00:00:00 2001 >From: Robin Sheat <robin@catalyst.net.nz> >Date: Thu, 13 Oct 2011 15:56:41 +1300 >Subject: [PATCH] Bug 6973 - this forces alerts to use the message queue > >Alerts, such as serials claims and routing lists messages and new >member details originally used sendmail directly. Now they go into the >message queue so that they can use centralised configuration. >--- > C4/Letters.pm | 90 ++++++++++++++++++++++++++++++++++---------------------- > 1 files changed, 55 insertions(+), 35 deletions(-) > >diff --git a/C4/Letters.pm b/C4/Letters.pm >index 0fccad4..63095f2 100644 >--- a/C4/Letters.pm >+++ b/C4/Letters.pm >@@ -279,20 +279,18 @@ sub SendAlerts { > my $innerletter = $letter; > my $borinfo = C4::Members::GetMember('borrowernumber' => $_->{'borrowernumber'}); > parseletter( $innerletter, 'borrowers', $_->{'borrowernumber'} ); >+ $innerletter->{'content-type'} = 'text/plain; charset="utf8"'; > > # ... then send mail >- if ( $borinfo->{email} ) { >- my %mail = ( >- To => $borinfo->{email}, >- From => $borinfo->{email}, >- Subject => "" . $innerletter->{title}, >- Message => "" . $innerletter->{content}, >- 'Content-Type' => 'text/plain; charset="utf8"', >- ); >- sendmail(%mail) or carp $Mail::Sendmail::error; >+ my %mail = ( >+ borrowernumber => $borinfo->{borrowernumber}, >+ message_transport_type => 'email', >+ letter => $innerletter, >+ no_local_bcc => 1, >+ ); >+ EnqueueLetter( \%mail ); > > # warn "sending to $mail{To} From $mail{From} subj $mail{Subject} Mess $mail{Message}"; >- } > } > } > elsif ( $type eq 'claimacquisition' ) { >@@ -335,24 +333,24 @@ sub SendAlerts { > } > $letter->{content} =~ s/<<[^>]*>>//g; > my $innerletter = $letter; >- >+ $innerletter->{'content-type'} = 'text/plain; charset="utf8"'; > # ... then send mail > if ( $databookseller->{bookselleremail} > || $databookseller->{contemail} ) > { > my %mail = ( >- To => $databookseller->{bookselleremail} >+ to_address => $databookseller->{bookselleremail} > . ( > $databookseller->{contemail} > ? "," . $databookseller->{contemail} > : "" > ), >- From => $userenv->{emailaddress}, >- Subject => "" . $innerletter->{title}, >- Message => "" . $innerletter->{content}, >- 'Content-Type' => 'text/plain; charset="utf8"', >+ from_address => $userenv->{emailaddress}, >+ message_transport_type => 'email', >+ letter => $innerletter, >+ no_local_bcc => 1, > ); >- sendmail(%mail) or carp $Mail::Sendmail::error; >+ EnqueueLetter( \%mail ); > } > if ( C4::Context->preference("LetterLog") ) { > logaction( >@@ -422,15 +420,19 @@ sub SendAlerts { > my $mail_msg = $innerletter->{content}; > $mail_msg ||= q{}; > $mail_subj ||= q{}; >- >+ my $letter = { >+ title => $mail_subj, >+ content => $mail_msg, >+ 'content-type' => 'text/plain; charset="utf8"', >+ }; > my %mail = ( >- To => $mail_to, >- From => $userenv->{emailaddress}, >- Subject => $mail_subj, >- Message => $mail_msg, >- 'Content-Type' => 'text/plain; charset="utf8"', >+ to_address => $mail_to, >+ from_address => $userenv->{emailaddress}, >+ message_transport_type => 'email', >+ letter => $letter, >+ no_local_bcc => 1, > ); >- sendmail(%mail) or carp $Mail::Sendmail::error; >+ EnqueueLetter( \%mail ); > logaction( > "ACQUISITION", > "CLAIM ISSUE", >@@ -443,7 +445,7 @@ sub SendAlerts { > . $innerletter->{content} > ) if C4::Context->preference("LetterLog"); > } >- } >+ } > # send an "account details" notice to a newly created user > elsif ( $type eq 'members' ) { > # must parse the password special, before it's hashed. >@@ -453,14 +455,15 @@ sub SendAlerts { > parseletter( $letter, 'branches', $externalid->{'branchcode'} ); > > my $branchdetails = GetBranchDetail($externalid->{'branchcode'}); >+ $letter->{'content-type'} = 'text/plain; charset="utf8"'; >+ > my %mail = ( >- To => $externalid->{'emailaddr'}, >- From => $branchdetails->{'branchemail'} || C4::Context->preference("KohaAdminEmailAddress"), >- Subject => $letter->{'title'}, >- Message => $letter->{'content'}, >- 'Content-Type' => 'text/plain; charset="utf8"', >+ to_address => $externalid->{'emailaddr'}, >+ message_transport_type => 'email', >+ letter => $letter, >+ no_local_bcc => 1, > ); >- sendmail(%mail) or carp $Mail::Sendmail::error; >+ EnqueueLetter( \%mail ); > } > } > >@@ -633,13 +636,30 @@ sub EnqueueLetter ($) { > # If we have any attachments we should encode then into the body. > if ( $params->{'attachments'} ) { > $params->{'letter'} = _add_attachments( >- { letter => $params->{'letter'}, >+ { >+ letter => $params->{'letter'}, > attachments => $params->{'attachments'}, > message => MIME::Lite->new( Type => 'multipart/mixed' ), > } > ); > } > >+ # If we aren't given a from address, we first go for the user's >+ # branch (which may be the librarians, but that's OK) email, if that doesn't >+ # work, we go for the koha admin address. >+ if ( !$params->{'from_address'} ) { >+ my $userenv = C4::Context->userenv; >+ my $branch = $userenv->{branch}; >+ my $branch_detail = GetBranchDetail($branch); >+ my $branch_email = $branch_detail->{branchemail}; >+ $params->{from_address} = $branch_email >+ || C4::Context->preference('KohaAdminEmailAddress'); >+ } >+ >+ # Set a reply-to if there isn't one already. >+ $params->{'reply_to_address'} = $params->{from_address} >+ if !$params->{reply_to_address}; >+ > my $dbh = C4::Context->dbh(); > my $statement = << 'ENDSQL'; > INSERT INTO message_queue >@@ -652,9 +672,9 @@ ENDSQL > > my $sth = $dbh->prepare($statement); > my $result = $sth->execute( >- $params->{'borrowernumber'}, # borrowernumber >- $params->{'letter'}->{'title'}, # subject >- $params->{'letter'}->{'content'}, # content >+ $params->{'borrowernumber'}, # borrowernumber >+ $params->{'letter'}->{'title'}, # subject >+ $params->{'letter'}->{'content'}, # content > $params->{'letter'}->{'metadata'} || '', # metadata > $params->{'letter'}->{'code'} || '', # letter_code > $params->{'letter'}->{'content-type'}, # content_type >-- >1.7.4.1
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 6973
:
5710
|
5711
|
5724
|
5728
|
5729
| 5870