@cross-solution/strapi-plugin-async-mail
v0.0.16
Published
This is the description of the plugin.
Downloads
3
Readme
Strapi plugin async-mail
Status: Work in Progress
The async-mail
plugin makes it possible to send form data from anonymous users to a defined email address. Form data is stored in a collection and sent asyncronously by a cronjob. A typical use case is a contact form that is supposed to send entered data to a defined email address.
🖐 Requirements
- strapi 4
- nodes 18|20
⏳ Install
The async-mail
is based on the Strapi Email Service. To send emails you need an email plugin. If you just want to send mails via SMTP, we recommend @strapi/provider-email-nodemailer. However, you can use any other Email Provider Plugin. The configuration of the email plugin provider used can be found in the corresponding documentation. E.g. Nodemailer configuration is located in the Readme
yarn add @strapi/provider-email-nodemailer
yarn add @cross-solution/strapi-plugin-async-mail
Configuration:
The default configuration is as follows (you must add it to ./config/plugin.js
):
module.exports = {
// ...
"async-mail": {
enabled: true,
config: {
scanLimit: env.int("SCAN_LIMIT", 10),
recipient: env("ASYNC_MAIL_RECIPIENT"),
},
},
// ...
}
🔌 Usage
The plugin expects the environment variables ASYNC_MAIL_RECIPIENT
and EMAIL_SETTINGS_FROM
.
Both variables must be defined in the .env
Simple mail
A simple mail sets the subject and the text of the mail according to the parameters subject
and message
.
curl -s -d "subject=Mail+Subject&message=Mail+Body+Text" "http://127.0.0.1:1337/async-mail" | jq "."
{
"id": 60,
"subject": "Mail Subject",
"message": "Mail Body Text",
"status": "new",
"from": "[email protected]",
"recipient": "[email protected]",
"sentAt": null,
"replyTo": "[email protected]",
"priority": null,
"meta": {},
"createdAt": "2024-07-10T08:36:10.099Z",
"updatedAt": "2024-07-10T08:36:10.099Z",
"isTemplated": false,
"uid": ""
}
Templated Mail
Mail templates with placeholders can be defined. Async Mail comes with a DEFAULT template, which recognizes the valid placeholders. The values of the placeholders can be passed as POST parameters.
Example
curl -s -d "subject=subject&text=text&contact=123&message=123&company=1235&phone=123&[email protected]&name=test&uid=DEFAULT" http://localhost:1337/async-mail | jq "."
{
"id": 61,
"subject": "subject",
"message": "123",
"status": "new",
"from": "[email protected]",
"recipient": "[email protected]",
"sentAt": null,
"replyTo": "[email protected]",
"priority": null,
"meta": {
"text": "text",
"contact": "123",
"company": "1235",
"phone": "123",
"email": "[email protected]",
"name": "test"
},
"createdAt": "2024-07-10T08:38:23.415Z",
"updatedAt": "2024-07-10T08:38:23.415Z",
"isTemplated": true,
"uid": "DEFAULT"
}
Collections
The plug creates the collections
- async-mail-outbox
- async-mail-templates
License
This plugin is licensed under the MIT License. See the LICENSE file for more information.