@strapi/provider-email-nodemailer 4.0.0-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +22 -0
- package/README.md +156 -0
- package/lib/index.js +44 -0
- package/package.json +63 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
Copyright (c) 2015-present Strapi Solutions SAS
|
|
2
|
+
|
|
3
|
+
Portions of the Strapi software are licensed as follows:
|
|
4
|
+
|
|
5
|
+
* All software that resides under an "ee/" directory (the “EE Software”), if that directory exists, is licensed under the license defined in "ee/LICENSE".
|
|
6
|
+
|
|
7
|
+
* All software outside of the above-mentioned directories or restrictions above is available under the "MIT Expat" license as set forth below.
|
|
8
|
+
|
|
9
|
+
MIT Expat License
|
|
10
|
+
|
|
11
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
12
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
13
|
+
in the Software without restriction, including without limitation the rights
|
|
14
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
15
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
16
|
+
furnished to do so, subject to the following conditions:
|
|
17
|
+
|
|
18
|
+
The above copyright notice and this permission notice shall be included in all
|
|
19
|
+
copies or substantial portions of the Software.
|
|
20
|
+
|
|
21
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
22
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
# strapi-provider-email-nodemailer
|
|
2
|
+
|
|
3
|
+
## Resources
|
|
4
|
+
|
|
5
|
+
- [License](LICENSE)
|
|
6
|
+
|
|
7
|
+
## Links
|
|
8
|
+
|
|
9
|
+
- [Strapi website](https://strapi.io/)
|
|
10
|
+
- [Strapi community on Slack](https://slack.strapi.io)
|
|
11
|
+
- [Strapi news on Twitter](https://twitter.com/strapijs)
|
|
12
|
+
|
|
13
|
+
## Prerequisites
|
|
14
|
+
|
|
15
|
+
You need to have the plugin `strapi-plugin-email` installed in your Strapi project.
|
|
16
|
+
|
|
17
|
+
## Installation
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
# using yarn
|
|
21
|
+
yarn add strapi-provider-email-nodemailer
|
|
22
|
+
|
|
23
|
+
# using npm
|
|
24
|
+
npm install strapi-provider-email-nodemailer --save
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
## Example
|
|
28
|
+
|
|
29
|
+
**Path -** `config/plugins.js`
|
|
30
|
+
|
|
31
|
+
```js
|
|
32
|
+
module.exports = ({ env }) => ({
|
|
33
|
+
email: {
|
|
34
|
+
provider: 'nodemailer',
|
|
35
|
+
providerOptions: {
|
|
36
|
+
host: env('SMTP_HOST', 'smtp.example.com'),
|
|
37
|
+
port: env('SMTP_PORT', 587),
|
|
38
|
+
auth: {
|
|
39
|
+
user: env('SMTP_USERNAME'),
|
|
40
|
+
pass: env('SMTP_PASSWORD'),
|
|
41
|
+
},
|
|
42
|
+
// ... any custom nodemailer options
|
|
43
|
+
},
|
|
44
|
+
settings: {
|
|
45
|
+
defaultFrom: 'hello@example.com',
|
|
46
|
+
defaultReplyTo: 'hello@example.com',
|
|
47
|
+
},
|
|
48
|
+
},
|
|
49
|
+
});
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
Check out the available options for nodemailer: https://nodemailer.com/about/
|
|
53
|
+
|
|
54
|
+
### Development mode
|
|
55
|
+
|
|
56
|
+
You can override the default configurations for specific environments. E.g. for
|
|
57
|
+
`NODE_ENV=development` in **config/env/development/plugins.js**:
|
|
58
|
+
|
|
59
|
+
```js
|
|
60
|
+
module.exports = ({ env }) => ({
|
|
61
|
+
email: {
|
|
62
|
+
provider: 'nodemailer',
|
|
63
|
+
providerOptions: {
|
|
64
|
+
host: 'localhost',
|
|
65
|
+
port: 1025,
|
|
66
|
+
ignoreTLS: true,
|
|
67
|
+
},
|
|
68
|
+
},
|
|
69
|
+
});
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
The above setting is useful for local development with
|
|
73
|
+
[maildev](https://github.com/maildev/maildev).
|
|
74
|
+
|
|
75
|
+
### Custom authentication mechanisms
|
|
76
|
+
|
|
77
|
+
It is also possible to use custom authentication methods.
|
|
78
|
+
Here is an example for a NTLM authentication:
|
|
79
|
+
|
|
80
|
+
```js
|
|
81
|
+
const nodemailerNTLMAuth = require('nodemailer-ntlm-auth');
|
|
82
|
+
|
|
83
|
+
module.exports = ({ env }) => ({
|
|
84
|
+
email: {
|
|
85
|
+
provider: 'nodemailer',
|
|
86
|
+
providerOptions: {
|
|
87
|
+
host: env('SMTP_HOST', 'smtp.example.com'),
|
|
88
|
+
port: env('SMTP_PORT', 587),
|
|
89
|
+
auth: {
|
|
90
|
+
type: 'custom',
|
|
91
|
+
method: 'NTLM',
|
|
92
|
+
user: env('SMTP_USERNAME'),
|
|
93
|
+
pass: env('SMTP_PASSWORD'),
|
|
94
|
+
},
|
|
95
|
+
customAuth: {
|
|
96
|
+
NTLM: nodemailerNTLMAuth,
|
|
97
|
+
},
|
|
98
|
+
},
|
|
99
|
+
settings: {
|
|
100
|
+
defaultFrom: 'hello@example.com',
|
|
101
|
+
defaultReplyTo: 'hello@example.com',
|
|
102
|
+
},
|
|
103
|
+
},
|
|
104
|
+
});
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
## Usage
|
|
108
|
+
|
|
109
|
+
> :warning: The Shipper Email (or defaultfrom) may also need to be changed in the `Email Templates` tab on the admin panel for emails to send properly
|
|
110
|
+
|
|
111
|
+
To send an email from anywhere inside Strapi:
|
|
112
|
+
|
|
113
|
+
```js
|
|
114
|
+
await strapi
|
|
115
|
+
.plugin('email')
|
|
116
|
+
.service('email')
|
|
117
|
+
.send({
|
|
118
|
+
to: 'someone@example.com',
|
|
119
|
+
from: 'someone2@example.com',
|
|
120
|
+
subject: 'Hello world',
|
|
121
|
+
text: 'Hello world',
|
|
122
|
+
html: `<h4>Hello world</h4>`,
|
|
123
|
+
});
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
The following fields are supported:
|
|
127
|
+
|
|
128
|
+
| Field | Description |
|
|
129
|
+
| ----------- | ----------------------------------------------------------------- |
|
|
130
|
+
| from | Email address of the sender |
|
|
131
|
+
| to | Comma separated list or an array of recipients |
|
|
132
|
+
| replyTo | Email address to which replies are sent |
|
|
133
|
+
| cc | Comma separated list or an array of recipients |
|
|
134
|
+
| bcc | Comma separated list or an array of recipients |
|
|
135
|
+
| subject | Subject of the email |
|
|
136
|
+
| text | Plaintext version of the message |
|
|
137
|
+
| html | HTML version of the message |
|
|
138
|
+
| attachments | Array of objects See: https://nodemailer.com/message/attachments/ |
|
|
139
|
+
|
|
140
|
+
## Troubleshooting
|
|
141
|
+
|
|
142
|
+
Check your firewall to ensure that requests are allowed. If it doesn't work with
|
|
143
|
+
|
|
144
|
+
```js
|
|
145
|
+
port: 465,
|
|
146
|
+
secure: true
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
try using
|
|
150
|
+
|
|
151
|
+
```js
|
|
152
|
+
port: 587,
|
|
153
|
+
secure: false
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
to test if it works correctly.
|
package/lib/index.js
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Module dependencies
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
const _ = require('lodash');
|
|
8
|
+
const nodemailer = require('nodemailer');
|
|
9
|
+
|
|
10
|
+
const emailFields = [
|
|
11
|
+
'from',
|
|
12
|
+
'replyTo',
|
|
13
|
+
'to',
|
|
14
|
+
'cc',
|
|
15
|
+
'bcc',
|
|
16
|
+
'subject',
|
|
17
|
+
'text',
|
|
18
|
+
'html',
|
|
19
|
+
'attachments',
|
|
20
|
+
];
|
|
21
|
+
|
|
22
|
+
module.exports = {
|
|
23
|
+
provider: 'nodemailer',
|
|
24
|
+
name: 'Nodemailer',
|
|
25
|
+
|
|
26
|
+
init(providerOptions = {}, settings = {}) {
|
|
27
|
+
const transporter = nodemailer.createTransport(providerOptions);
|
|
28
|
+
|
|
29
|
+
return {
|
|
30
|
+
send(options) {
|
|
31
|
+
// Default values.
|
|
32
|
+
const emailOptions = {
|
|
33
|
+
..._.pick(options, emailFields),
|
|
34
|
+
from: options.from || settings.defaultFrom,
|
|
35
|
+
replyTo: options.replyTo || settings.defaultReplyTo,
|
|
36
|
+
text: options.text || options.html,
|
|
37
|
+
html: options.html || options.text,
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
return transporter.sendMail(emailOptions);
|
|
41
|
+
},
|
|
42
|
+
};
|
|
43
|
+
},
|
|
44
|
+
};
|
package/package.json
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@strapi/provider-email-nodemailer",
|
|
3
|
+
"version": "4.0.0-beta.0",
|
|
4
|
+
"description": "Nodemailer provider for Strapi 3",
|
|
5
|
+
"homepage": "https://strapi.io",
|
|
6
|
+
"keywords": [
|
|
7
|
+
"strapi",
|
|
8
|
+
"email",
|
|
9
|
+
"provider",
|
|
10
|
+
"nodemailer"
|
|
11
|
+
],
|
|
12
|
+
"main": "./lib",
|
|
13
|
+
"directories": {
|
|
14
|
+
"lib": "./lib"
|
|
15
|
+
},
|
|
16
|
+
"dependencies": {
|
|
17
|
+
"lodash": "4.17.21",
|
|
18
|
+
"nodemailer": "6.5.0"
|
|
19
|
+
},
|
|
20
|
+
"repository": {
|
|
21
|
+
"type": "git",
|
|
22
|
+
"url": "https://github.com/strapi/strapi.git"
|
|
23
|
+
},
|
|
24
|
+
"author": {
|
|
25
|
+
"name": "Yurii Tykhomyrov"
|
|
26
|
+
},
|
|
27
|
+
"strapi": {
|
|
28
|
+
"isProvider": true
|
|
29
|
+
},
|
|
30
|
+
"scripts": {
|
|
31
|
+
"test": "echo \"no tests yet\""
|
|
32
|
+
},
|
|
33
|
+
"contributors": [
|
|
34
|
+
{
|
|
35
|
+
"name": "Veit Bjarsch",
|
|
36
|
+
"email": "vb@poweruplink.com",
|
|
37
|
+
"url": "https://poweruplink.com"
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
"name": "Saunved Mutalik"
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
"name": "Robert Schäfer",
|
|
44
|
+
"email": "git@roschaefer.de"
|
|
45
|
+
}
|
|
46
|
+
],
|
|
47
|
+
"maintainers": [
|
|
48
|
+
{
|
|
49
|
+
"name": "Strapi team",
|
|
50
|
+
"email": "hi@strapi.io",
|
|
51
|
+
"url": "https://strapi.io"
|
|
52
|
+
}
|
|
53
|
+
],
|
|
54
|
+
"license": "SEE LICENSE IN LICENSE",
|
|
55
|
+
"bugs": {
|
|
56
|
+
"url": "https://github.com/strapi/strapi/issues"
|
|
57
|
+
},
|
|
58
|
+
"engines": {
|
|
59
|
+
"node": ">=12.x.x <=16.x.x",
|
|
60
|
+
"npm": ">=6.0.0"
|
|
61
|
+
},
|
|
62
|
+
"gitHead": "9807c78cb7ab6373b7abb46da5ecc4980a9ea56c"
|
|
63
|
+
}
|