A plugin for sending emails via forms using the MailerSend API.
The MailerSend Plugin is an extension for Grav CMS.
NOTE: Currently this works via processing Grav forms only!
Installing the MailerSend plugin can be done in one of three ways: The GPM (Grav Package Manager) installation method lets you quickly install the plugin with a simple terminal command, the manual method lets you do so via a zip file, and the admin method lets you do so via the Admin Plugin.
To install the plugin via the GPM, through your system's terminal (also called the command line), navigate to the root of your Grav-installation, and enter:
bin/gpm install mailersend
This will install the MailerSend plugin into your /user/plugins
-directory within Grav. Its files can be found under /your/site/grav/user/plugins/mailersend
.
enabled: true
api_token: <YOUR API TOKEN>
debug: false
defaults:
to:
from:
cc:
bcc:
NOTE: You can create a custom permission token, but it at least needs full Email permissions. - https://www.mailersend.com/help/managing-api-tokens
form:
name: test-form
...
process:
mailersend:
subject: "[WEB Form] {{ form.value.name|e }}" # REQUIRED
reply_to: ["{{ form.value.email }}", "{{ form.value.name|e }}"] # REQUIRED
from: ["[email protected]", "Your Name"] # OPTIONAL: can use defaults if provided
bcc: ["{{ form.value.email }}", "{{ form.value.name|e }}"] # OPTIONAL: can use defaults if provided
to: ["[email protected]", "Your Name"] # OPTIONAL: can use defaults if provided
html: true # OPTIONAL: will assume message is HTML and create a text version automatically
message: "{{ form.value.message }}" # OPTIONAL: will use form.value.message if not set
template_id: jy7zpl98ye345vx6 # OPTIONAL: will use this template ID if specified and messages is ignored
substitutions: # OPTIONAL: only used when template_id is provided
name: "{{ form.value.name|e }}"
email: "{{ form.value.email }}"
message: "{{ form.value.message|e }}"
You can use any value from the form via {{ form.value.<field-attribute> }}
or from Grav's configuration via {{ config.x.y.z }}
All these email formats are valid:
YAML:
[[email protected], Your Name]
# simple arrayYour Name <[email protected]>
# name-addr spec string{[email protected]: Your Name}
# basic associative array{email: [email protected], name: Your Name}
# full associative array[email protected]
# basic addr-spec string<[email protected]>
# basic angle-addr string
PHP:
['[email protected]', 'Your Name']
# simple array'Your Name <[email protected]>'
# name-addr spec string['[email protected]' => 'Your Name']
# basic associative array['email' => '[email protected]', 'name' => 'Your Name']
# full associative array'[email protected]'
# basic addr-spec string'<[email protected]>'
# basic angle-addr string
Arrays of these email addresses (or comma-seperated strings) are support for multiple email addresses. For example:
[[[email protected], Your Name], [[email protected], Contact]]
Your Name <[email protected]>, Contact <[email protected]>
or[Your Name <[email protected]>, Contact <[email protected]>]
[{[email protected]: Your Name}, {[email protected]: Contact}]
[{email: [email protected], name: Your Name}, {email: [email protected], name: Contact}]
[email protected], [email protected]
or[[email protected], [email protected]]
<[email protected]>, <[email protected]>
or[<[email protected]>, <[email protected]>]