Evergreen should allow for HTML formatted action trigger emails

Bug #1532236 reported by Blake GH
48
This bug affects 10 people
Affects Status Importance Assigned to Milestone
Evergreen
Fix Released
Wishlist
Unassigned

Bug Description

It would be great if you could formulate your own email headers for action triggers in the action trigger template. If you so desired. If you do not include the Content-Type in the email header, then Evergreen can go ahead and make one.

Revision history for this message
Blake GH (bmagic) wrote :

Here is an example of an email we would like to have sent in HTML if the mail client supports it. If not, it should show the plain text version.

[%- USE date -%]
[%- user = target.0.usr -%]
To: [%- params.recipient_email || user.email %]
From: [%- target.0.circ_lib.name %] <[% helpers.get_org_setting(target.0.circ_lib.id, 'org.bounced_emails') || lib.email || params.sender_email || default_sender %]>
MIME-Version: 1.0
Content-Type: multipart/alternative;boundary=separatehere
Subject: Overdue Notification

Dear [% user.first_given_name %] [% user.family_name %],

Did you forget? Currently the following items are overdue. Checked out items may be renewed one time if no other patron is requesting the item. Renew by phone at {removed} or online from the library's website: {removed}.

[% FOR circ IN target %]
    Title: [% circ.target_copy.call_number.record.simple_record.title %]
    Barcode: [% circ.target_copy.barcode %]
    Due: [% date.format(helpers.format_date(circ.due_date), '%Y-%m-%d') %]
    Item Cost: [% helpers.get_copy_price(circ.target_copy) %]
[% END %]

{removed}
p: {removed}
e: {removed}
Library Hours: Monday - Thursday: 9 a.m. - 7 p.m. | Friday - Saturday: 10 a.m. - 5 p.m. | Sunday 1 p.m. - 5 p.m. (Sept. - May)

Login in to http://{removed}/eg/opac/myopac/main?locg=2 to renew your items or place items on hold.

Please note: {removed} operates on the principle that our patrons can be trusted to return materials in a timely manner. Currently, fines are not charged for overdue materials. However, items are considered lost after 45 days overdue. Lost items are billed at the item's original cost plus a $10 non-refundable processing fee.
--separatehere
Content-Type: text/html;charset=utf-8

<p>Dear [% user.first_given_name %] [% user.family_name %],</p>
<p>
Did you forget? Currently the following items are overdue. Checked out items may be renewed one time if no other patron is requesting the item. Renew by phone at {removed} or online from the library's website: {removed}.
</p>
<pre>
[% FOR circ IN target %]
    Title: [% circ.target_copy.call_number.record.simple_record.title %]
    Barcode: [% circ.target_copy.barcode %]
    Due: [% date.format(helpers.format_date(circ.due_date), '%Y-%m-%d') %]
    Item Cost: [% helpers.get_copy_price(circ.target_copy) %]
[% END %]
</pre>

{removed}<br>
p: {removed}<br>
e: {removed}<br>
Library Hours: Monday - Thursday: 9 a.m. - 7 p.m. | Friday - Saturday: 10 a.m. - 5 p.m. | Sunday 1 p.m. - 5 p.m. (Sept. - May)<br>

<p>
Login in to <a href="http://{removed}/eg/opac/myopac/main?locg=2">My Account</a> to renew your items or place items on hold.
</p>
<p>
Please note: {removed} operates on the principle that our patrons can be trusted to return materials in a timely manner. <i>Currently, fines are not charged for overdue materials.</i> However, items are considered lost after 45 days overdue. Lost items are billed at the item's original cost plus a $10 non-refundable processing fee.</p>
--separatehere--

Changed in evergreen:
status: New → Confirmed
importance: Undecided → Wishlist
Revision history for this message
Blake GH (bmagic) wrote :
Revision history for this message
Blake GH (bmagic) wrote :

Warning: If you have templates that specify a Content-Type and you have been confused why it wasn't working. And forgot about it, your emails will start sending with that Content-Type - which might result in ill formatted messages depending on the state of the body of the message.

Kathy Lussier (klussier)
Changed in evergreen:
milestone: none → 2.next
tags: added: actiontrigger
Revision history for this message
Jason Stephenson (jstephenson) wrote :

Note that the proposed fix for bug 1801163 may very well break this branch. I have not tested the two together.

There is also the possibility that the resolution to bug 1466502 will also break this. I'm pretty sure that if Email::Stuffer is used, this branch will no longer work, and may not even be possible without drastic changes to the A/T templating system.

Revision history for this message
Blake GH (bmagic) wrote :

New branch for current master

https://git.evergreen-ils.org/?p=working/Evergreen.git;a=shortlog;h=refs/heads/user/blake/LP1532236_Evergreen_should_allow_for_HTML_formatted_action_trigger_emails_post_3_4

As mentioned here, these tweaks might not work now that we are using Email::MIME. Will test them together and report back.

Revision history for this message
Blake GH (bmagic) wrote :

It looks like Email::MIME is inheriting from Email::Simple.

use parent qw(Email::Simple);

There doesn't seem to be an overridden method for "header" in Email::MIME but there is one in Email::Simple which is what gets called when calling "header" and for "header_set" for that matter.

https://metacpan.org/pod/Email::Simple#header

In theory - those calls (without this patch) are still syntactically sound. And those calls (with this patch) are syntactically sound. Still testing.

Revision history for this message
Michele Morgan (mmorgan) wrote :

Blake, is this code ready for testing? That is, should it get a pullrequest tag?

Michele Morgan (mmorgan)
tags: added: pullrequest
Michele Morgan (mmorgan)
tags: added: needsreleasenote
removed: pullrequest
tags: added: pullrequest
Revision history for this message
Michele Morgan (mmorgan) wrote :

Some discussion at the Hackaway clarified that this patch will allow action triggers to send html formatted email if specified in the template rather than force sending as text (current behavior)

The thought was to NOT attempt creating an upgrade script to change existing action triggers, but allow sites the option to configure their own html email triggers if they choose. Release note could make that clear as well as provide an example.

Revision history for this message
Garry Collum (gcollum) wrote :

Tested using festivus.evergreen.org. Added two email addresses to a patron account, and sent a test email from that account. The emails I received in gmail and in outlook were both definitely formatted with html.

I have tested this code and consent to signing off on it with my name, Garry Collum and my email address, <email address hidden>

tags: added: signoff
tags: added: signedoff
removed: signoff
Revision history for this message
Jane Sandberg (sandbergja) wrote :

Thanks, Blake, for the 6 years of work on this! And thanks to Garry for the testing. I've pushed this to master for inclusion in 3.10, along with some brief release notes.

Changed in evergreen:
milestone: 3.next → 3.10-beta
status: Confirmed → Fix Committed
Changed in evergreen:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Duplicates of this bug

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.