-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
98 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -246,15 +246,79 @@ form: | |
# Their values may be referenced in email actions via '{{ form.value.FIELDNAME|e }}' | ||
process: | ||
- email: | ||
subject: "[Custom form] {{ form.value.name|e }}" | ||
email: | ||
subject: "[Custom form] {{ form.value.name|e }}" | ||
body: "{% include 'forms/data.txt.twig' %}" | ||
from: [email protected] | ||
from_name: 'Custom sender name' | ||
to: [email protected] | ||
to_name: 'Custom recipient name' | ||
content_type: 'text/plain' | ||
process_markdown: true | ||
``` | ||
|
||
## Multiple Emails | ||
|
||
You can send multiple emails by creating an array of emails under the `process: email:` option in the form: | ||
|
||
``` | ||
title: Custom form | ||
form: | ||
name: custom_form | ||
fields: | ||
# Any fields you'd like to add to the form: | ||
# Their values may be referenced in email actions via '{{ form.value.FIELDNAME|e }}' | ||
process: | ||
email: | ||
- | ||
subject: "[Custom Email 1] {{ form.value.name|e }}" | ||
body: "{% include 'forms/data.txt.twig' %}" | ||
from: [email protected] | ||
from_name: 'Custom sender name' | ||
to: [email protected] | ||
to_name: 'Custom recipient name' | ||
content_type: 'text/plain' | ||
process_markdown: true | ||
from: {mail: "[email protected]", name: "Site OWner"}' | ||
to: {mail: "[email protected]", name: "Recepient 1"} | ||
template: "email/base.html.twig" | ||
- | ||
subject: "[Custom Email 2] {{ form.value.name|e }}" | ||
body: "{% include 'forms/data.txt.twig' %}" | ||
from: {mail: "[email protected]", name: "Site OWner"}' | ||
to: {mail: "[email protected]", name: "Recepient 1"} | ||
template: "email/base.html.twig" | ||
``` | ||
|
||
## Templating Emails | ||
|
||
You can specify a Twig template for HTML rendering, else Grav will use the default one `email/base.html.twig` which is included in this plugin. You can also specify a custom template that extends the base, where you can customize the `{% block content %}` and `{% block footer %}`. For example: | ||
|
||
```twig | ||
{% extends 'email/base.html.twig' %} | ||
{% block content %} | ||
<p> | ||
Greetings {{ form.value.name|e }}, | ||
</p> | ||
<p> | ||
We have received your request for help. Our team will get in touch with you within 3 Business Days. | ||
</p> | ||
<p> | ||
Regards, | ||
</p> | ||
<p> | ||
<b>My Company</b> | ||
<br /><br /> | ||
E - <a href="mailto:[email protected]">[email protected]</a><br /> | ||
M - +1 555-123-4567<br /> | ||
W - <a href="https://mycompany.com">mycompany.com</a> | ||
</p> | ||
{% endblock %} | ||
{% block footer %} | ||
<p style="text-align: center;">My Company - All Rights Reserved</p> | ||
{% endblock %} | ||
``` | ||
|
||
## Sending Attachments | ||
|
@@ -267,8 +331,7 @@ form: | |
name: custom_form | ||
fields: | ||
- | ||
name: my-file | ||
my-file: | ||
label: 'Add a file' | ||
type: file | ||
multiple: false | ||
|
@@ -280,11 +343,11 @@ form: | |
- text/plain | ||
process: | ||
- | ||
email: | ||
body: '{% include "forms/data.html.twig" %}' | ||
attachments: | ||
- 'my-file' | ||
email: | ||
body: '{% include "forms/data.html.twig" %}' | ||
attachments: | ||
- 'my-file' | ||
``` | ||
|
||
## Additional action parameters | ||
|
@@ -323,6 +386,12 @@ to: | |
name: Human-readable name | ||
``` | ||
|
||
or inline: | ||
|
||
``` | ||
to: {mail: '[email protected]', name: 'Human-readable name'} | ||
``` | ||
|
||
#### Multiple email addresses (with and without names) | ||
|
||
``` | ||
|
@@ -339,6 +408,16 @@ to: | |
[email protected] | ||
``` | ||
|
||
or inline: | ||
|
||
``` | ||
to: | ||
- {mail: '[email protected]', name: 'Human-readable name'} | ||
- {mail: '[email protected]', name: 'Another human-readable name'} | ||
- [email protected] | ||
- [email protected] | ||
``` | ||
|
||
## Multi-part MIME messages | ||
|
||
Apart from a simple string, an email body may contain different MIME parts (e.g. HTML body with plain text fallback). You may even specify a different charset for each part (default to `utf-8`): | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters