Plugin for sending mails on donor state transitions.
make install
Then copy the following snippet to giroapp.ini
and edit to your needs.
; Mailer smtp authentication string
mailer_smtp_string = "smtp://user:pass@host/"
; Default from header address
mailer_default_from_header = ""
; Default reply-to header address
mailer_default_reply_to_header = ""
; Directory where mail templates are stored
mailer_template_dir = "%base_dir%/mailer_templates"
; Directory where queued mails are stored
mailer_queue_dir = "%base_dir%/mailer_queue"
Templates are stored in the mailer_templates
dir postfixed with the donor
event or state name that should trigger message creation. For example:
foo_template.MANDATE_SENT
bar_template.REVOKED
baz_template.DONOR_POSTAL_ADDRESS_UPDATED
Templates are html formatted mustache templates with a YAML frontmatter. Supported frontmatter variables are (case insensitive):
Subject
From
(overrides mailer_default_from_header if set)Reply-To
orReplyTo
(overrides mailer_default_reply_to_header if set)Cc
(single address or array)Bcc
(single address or array)
A simple template may look like:
---
from: [email protected]
Reply-To: [email protected]
bcc: [email protected]
subject: Welcome as a donor
---
<p>Hi {{getDonor.getName}}, you are now a donor.</p>
Donors that does not have an email address are ignored when generating mails.
Renderings that return empty bodies are ignored when generating mails. Use this feature to make a mail conditional on some donor feature.
---
from: [email protected]
subject: Only sent if there is a commment in donor
---
{{# getDonor.getComment}}
There is a comment, so this mail will be generated..
{{/ getDonor.getComment}}
When listening to update events make sure to access the updated value directly
from the event object (use getNewPostalAddress
instead of getDonor.getPostalAddress
).
---
from: [email protected]
Subject: Address updated
---
<p>Hi {{getDonor.getName}}!</p>
<p>We have updated your address</p>
<pre>
{{getNewPostalAddress}}
</pre>
Plugin registers four giroapp commands.
To inspect the current mail queue
giroapp mailer:list
To send mails in queue
giroapp mailer:send
To clear the queue without sending mails
giroapp mailer:clear
To remove all mails to recipient without sending them
giroapp mailer:rm <recipient>