You are here

README.txt in Previewable email templates 8.3

Same filename and directory in other branches
  1. 8.4 README.txt
  2. 8 README.txt
  3. 6 README.txt
  4. 7 README.txt
Previewable Email Templates (PET)
=================================

The Previewable Email Template (PET) module lets users create email templates,
with token substitution, which can be previewed before sending. The emails can
be sent to one or many email addresses in a flexible way, and the recipients
may or may not be Drupal account holders (users).

Individual email sends can be customized per email send without affecting the
template, which makes one-off customization a breeze.

PET puts all your email templates in one place which makes for easy editing by 
your users, who don't have to go into the bowels of Rules to edit an email.

Emails can also be sent programmatically by you the developer.

PET stores templates in a db table, not the variables table, so there is none
of the memory usage which goes with the latter.

PETs are based on the Entity API, which means export, import, clone, code-based
defaults, etc are supported.

PET supports the Rules module, so email actions can be triggered by any Rule.

PET supports the MimeMail module for HTML emails.

Required Modules
================

- Entity API

Optional Modules
================

- Rules
- MimeMail

Installation
============
* Copy the pet directory to the modules folder in your installation.
* Go to the Modules page (/admin/modules) and enable it.

Template Management
===================
Manage (import, add, edit, clone, delete, export) the templates for your 
site from the Structure page (/admin/structure/pets). Users must have 
"administer pet entities" permission for this.
 
* Title (required) - A descriptive title for the template. For reference by PET
  administrators. Doesn't appear anywhere in the email itself.
 
* Name (required) - Machine name for the template. This is used if you refer to
  your template from code.
 
* Subject (required) - The email subject. May contain tokens for substitution.
 
* Body (optional but obviously common) - The email body. Like Subject, may 
  contain tokens.
 
* From override (optional) - An alternative From address for emails originating
  from this template. If not provided the site default is used.
 
* CC default (optional) - One or more emails to be cc'd on every email sent
  using this template.

* BCC default (optional) - One or more emails to be blind cc'd on every email
  sent using this template.
 
* Recipient callback (optional) - The name of a function which is called to
  retrieve a list of email recipients, if the uid argument is 0 (not missing,
  but the number 0) for an interactive send. This is a function that you 
  provide. If there is a nid argument, the node is loaded and passed to this 
  function.

Using PET Templates
===================

Once you've created a PET template, you can fire it a) interactively, b) via
code you write, or c) via Rules.

Interactive PETs
================

To send a PET interactively a user must have "use previewable email 
templates" permission. The best way to get a feel for the UI when sending when
doing interactive sends is to create a template (/admin/structure/pets/add),
then click the link of the PET Label at (/admin/structure/pets). A form will
appear with the template data, and clicking the Preview button will show the
email as it will be sent, along with token substitutions if any and markup.

Clicking back allows edits to be made for this particular send, without 
changing the stored template itself. When happy with the preview, click Send 
email(s) to send the email.

You the developer can include a link with the path "/pet/MY_PET_NAME" anywhere
you like on your site to give your users interactive access to a template.

Interactive PETs With Substitutions
===================================

In this simple form of the path above, with no arguments provided, the user
will be required to enter one or more email addresses. User token substitutions
(if present in the template) will be made for every email that has a 
corresponding user in the site. Global token substitutions will also be made.

You can provide a default user in the To field by including uid=[uid] in the 
query, e.g. 

 /pet/MY_PET_NAME?uid=17
 
This will provide token substitution for user 17. Additional email recipients 
can also be added to the form.

To invoke a PET for a custom list of users, specify "recipient_callback=true"
in the query, for example 

 /pet/MY_PET_NAME?recipient_callback=true
 
If the PET is set up to support user token substitution then for each email 
with a corresponding drupal user the substitution will take place.

To invoke a PET with node substitution, add the node id to the arguments, e.g.

 /pet/MY_PET_NAME?uid=17&nid=244

Token substitution will be done on both user 17 and node 244. Recipient 
callback could be used as well, as in 

 /pet/MY_PET_NAME?recipient_callback=true&nid=244

For example, let's say you manage events in your site, and you wish to send an
email to all registrants reminding them of the event date. The event info is
stored in node 348 and you have a function called event_registrants($event)
which, given an event node returns an array of registrant emails. Finally, the
name of the PET template is "event_reminder". The following path would provide
an interactive way to do this send:

 /pet/event_reminder?recipient_callback=true&nid=348

Firing PET Emails From Code
===========================

PET emails can also be sent from code anywhere in your site. You can do this in
response to whatever situation you have, and you have full control over the 
output. The authors of this module fire PETs programmatically in response to 
e-commerce purchases, class signups, event reminders, membership expirations, and
many other triggering events.

There are two functions available to programmers. See function pet_send_mail() 
for sending emails to multiple recipients. See function pet_send_one_mail() for 
sending email to a single recipient. These function headers contain further 
documentation.

Additional tokens can be provided via hook_pet_substitutions_alter(). 

Triggering PET Emails From Rules
================================

If you have Rules enabled on your site (admin/config/workflow/rules) you will
see the Rules action "Send PET mail" provided by the PET module. In the action
you choose the PET template to fire, along with either a) a fixed set of email
address(es) or a recipient user provided by the Rules event. You may also
choose a node for token substitutions.

MimeMail Integration
====================

For those wanting to send HTML email, PET supports the MimeMail module. When 
MimeMail is enabled, you will see additional options in the template edit form,
including a plain text email body, and a checkbox for sending plain text only.

If you leave the plain text body empty, MimeMail will perform its usual
conversion of markup to plain text using core's drupal_html_to_text(). If you
provide a plain text version of the email, it will be included in the multipart
mime email.

MimeMail also works for programmatic and Rules triggered sends.

File

README.txt
View source
  1. Previewable Email Templates (PET)
  2. =================================
  3. The Previewable Email Template (PET) module lets users create email templates,
  4. with token substitution, which can be previewed before sending. The emails can
  5. be sent to one or many email addresses in a flexible way, and the recipients
  6. may or may not be Drupal account holders (users).
  7. Individual email sends can be customized per email send without affecting the
  8. template, which makes one-off customization a breeze.
  9. PET puts all your email templates in one place which makes for easy editing by
  10. your users, who don't have to go into the bowels of Rules to edit an email.
  11. Emails can also be sent programmatically by you the developer.
  12. PET stores templates in a db table, not the variables table, so there is none
  13. of the memory usage which goes with the latter.
  14. PETs are based on the Entity API, which means export, import, clone, code-based
  15. defaults, etc are supported.
  16. PET supports the Rules module, so email actions can be triggered by any Rule.
  17. PET supports the MimeMail module for HTML emails.
  18. Required Modules
  19. ================
  20. - Entity API
  21. Optional Modules
  22. ================
  23. - Rules
  24. - MimeMail
  25. Installation
  26. ============
  27. * Copy the pet directory to the modules folder in your installation.
  28. * Go to the Modules page (/admin/modules) and enable it.
  29. Template Management
  30. ===================
  31. Manage (import, add, edit, clone, delete, export) the templates for your
  32. site from the Structure page (/admin/structure/pets). Users must have
  33. "administer pet entities" permission for this.
  34. * Title (required) - A descriptive title for the template. For reference by PET
  35. administrators. Doesn't appear anywhere in the email itself.
  36. * Name (required) - Machine name for the template. This is used if you refer to
  37. your template from code.
  38. * Subject (required) - The email subject. May contain tokens for substitution.
  39. * Body (optional but obviously common) - The email body. Like Subject, may
  40. contain tokens.
  41. * From override (optional) - An alternative From address for emails originating
  42. from this template. If not provided the site default is used.
  43. * CC default (optional) - One or more emails to be cc'd on every email sent
  44. using this template.
  45. * BCC default (optional) - One or more emails to be blind cc'd on every email
  46. sent using this template.
  47. * Recipient callback (optional) - The name of a function which is called to
  48. retrieve a list of email recipients, if the uid argument is 0 (not missing,
  49. but the number 0) for an interactive send. This is a function that you
  50. provide. If there is a nid argument, the node is loaded and passed to this
  51. function.
  52. Using PET Templates
  53. ===================
  54. Once you've created a PET template, you can fire it a) interactively, b) via
  55. code you write, or c) via Rules.
  56. Interactive PETs
  57. ================
  58. To send a PET interactively a user must have "use previewable email
  59. templates" permission. The best way to get a feel for the UI when sending when
  60. doing interactive sends is to create a template (/admin/structure/pets/add),
  61. then click the link of the PET Label at (/admin/structure/pets). A form will
  62. appear with the template data, and clicking the Preview button will show the
  63. email as it will be sent, along with token substitutions if any and markup.
  64. Clicking back allows edits to be made for this particular send, without
  65. changing the stored template itself. When happy with the preview, click Send
  66. email(s) to send the email.
  67. You the developer can include a link with the path "/pet/MY_PET_NAME" anywhere
  68. you like on your site to give your users interactive access to a template.
  69. Interactive PETs With Substitutions
  70. ===================================
  71. In this simple form of the path above, with no arguments provided, the user
  72. will be required to enter one or more email addresses. User token substitutions
  73. (if present in the template) will be made for every email that has a
  74. corresponding user in the site. Global token substitutions will also be made.
  75. You can provide a default user in the To field by including uid=[uid] in the
  76. query, e.g.
  77. /pet/MY_PET_NAME?uid=17
  78. This will provide token substitution for user 17. Additional email recipients
  79. can also be added to the form.
  80. To invoke a PET for a custom list of users, specify "recipient_callback=true"
  81. in the query, for example
  82. /pet/MY_PET_NAME?recipient_callback=true
  83. If the PET is set up to support user token substitution then for each email
  84. with a corresponding drupal user the substitution will take place.
  85. To invoke a PET with node substitution, add the node id to the arguments, e.g.
  86. /pet/MY_PET_NAME?uid=17&nid=244
  87. Token substitution will be done on both user 17 and node 244. Recipient
  88. callback could be used as well, as in
  89. /pet/MY_PET_NAME?recipient_callback=true&nid=244
  90. For example, let's say you manage events in your site, and you wish to send an
  91. email to all registrants reminding them of the event date. The event info is
  92. stored in node 348 and you have a function called event_registrants($event)
  93. which, given an event node returns an array of registrant emails. Finally, the
  94. name of the PET template is "event_reminder". The following path would provide
  95. an interactive way to do this send:
  96. /pet/event_reminder?recipient_callback=true&nid=348
  97. Firing PET Emails From Code
  98. ===========================
  99. PET emails can also be sent from code anywhere in your site. You can do this in
  100. response to whatever situation you have, and you have full control over the
  101. output. The authors of this module fire PETs programmatically in response to
  102. e-commerce purchases, class signups, event reminders, membership expirations, and
  103. many other triggering events.
  104. There are two functions available to programmers. See function pet_send_mail()
  105. for sending emails to multiple recipients. See function pet_send_one_mail() for
  106. sending email to a single recipient. These function headers contain further
  107. documentation.
  108. Additional tokens can be provided via hook_pet_substitutions_alter().
  109. Triggering PET Emails From Rules
  110. ================================
  111. If you have Rules enabled on your site (admin/config/workflow/rules) you will
  112. see the Rules action "Send PET mail" provided by the PET module. In the action
  113. you choose the PET template to fire, along with either a) a fixed set of email
  114. address(es) or a recipient user provided by the Rules event. You may also
  115. choose a node for token substitutions.
  116. MimeMail Integration
  117. ====================
  118. For those wanting to send HTML email, PET supports the MimeMail module. When
  119. MimeMail is enabled, you will see additional options in the template edit form,
  120. including a plain text email body, and a checkbox for sending plain text only.
  121. If you leave the plain text body empty, MimeMail will perform its usual
  122. conversion of markup to plain text using core's drupal_html_to_text(). If you
  123. provide a plain text version of the email, it will be included in the multipart
  124. mime email.
  125. MimeMail also works for programmatic and Rules triggered sends.