@strapi/provider-email-sendgrid 0.0.0-4fc90398602f

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 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,58 @@
1
+ # @strapi/provider-email-sendgrid
2
+
3
+ ## Resources
4
+
5
+ - [LICENSE](LICENSE)
6
+
7
+ ## Links
8
+
9
+ - [Strapi website](https://strapi.io/)
10
+ - [Strapi documentation](https://docs.strapi.io)
11
+ - [Strapi community on Discord](https://discord.strapi.io)
12
+ - [Strapi news on Twitter](https://twitter.com/strapijs)
13
+
14
+ ## Installation
15
+
16
+ ```bash
17
+ # using yarn
18
+ yarn add @strapi/provider-email-sendgrid
19
+
20
+ # using npm
21
+ npm install @strapi/provider-email-sendgrid --save
22
+ ```
23
+
24
+ ## Configuration
25
+
26
+ | Variable | Type | Description | Required | Default |
27
+ | ----------------------- | ----------------------- | ----------------------------------------------------------------------------------------------------------------------- | -------- | --------- |
28
+ | provider | string | The name of the provider you use | yes | |
29
+ | providerOptions | object | Provider options | yes | |
30
+ | providerOptions.apiKey | object | Api key given to the function setApiKey. Please refer to [@sendgrid/mail](https://www.npmjs.com/package/@sendgrid/mail) | yes | |
31
+ | settings | object | Settings | no | {} |
32
+ | settings.defaultFrom | string | Default sender mail address | no | undefined |
33
+ | settings.defaultReplyTo | string \| array<string> | Default address or addresses the receiver is asked to reply to | no | undefined |
34
+
35
+ > :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
36
+
37
+ ### Example
38
+
39
+ **Path -** `config/plugins.js`
40
+
41
+ ```js
42
+ module.exports = ({ env }) => ({
43
+ // ...
44
+ email: {
45
+ config: {
46
+ provider: 'sendgrid',
47
+ providerOptions: {
48
+ apiKey: env('SENDGRID_API_KEY'),
49
+ },
50
+ settings: {
51
+ defaultFrom: 'myemail@protonmail.com',
52
+ defaultReplyTo: 'myemail@protonmail.com',
53
+ },
54
+ },
55
+ },
56
+ // ...
57
+ });
58
+ ```
package/lib/index.js ADDED
@@ -0,0 +1,38 @@
1
+ 'use strict';
2
+
3
+ const sendgrid = require('@sendgrid/mail');
4
+ const { removeUndefined } = require('@strapi/utils');
5
+
6
+ module.exports = {
7
+ init(providerOptions = {}, settings = {}) {
8
+ sendgrid.setApiKey(providerOptions.apiKey);
9
+
10
+ return {
11
+ send(options) {
12
+ return new Promise((resolve, reject) => {
13
+ const { from, to, cc, bcc, replyTo, subject, text, html, ...rest } = options;
14
+
15
+ const msg = {
16
+ from: from || settings.defaultFrom,
17
+ to,
18
+ cc,
19
+ bcc,
20
+ replyTo: replyTo || settings.defaultReplyTo,
21
+ subject,
22
+ text,
23
+ html,
24
+ ...rest,
25
+ };
26
+
27
+ sendgrid.send(removeUndefined(msg), (err) => {
28
+ if (err) {
29
+ reject(err);
30
+ } else {
31
+ resolve();
32
+ }
33
+ });
34
+ });
35
+ },
36
+ };
37
+ },
38
+ };
package/package.json ADDED
@@ -0,0 +1,47 @@
1
+ {
2
+ "name": "@strapi/provider-email-sendgrid",
3
+ "version": "0.0.0-4fc90398602f",
4
+ "description": "Sendgrid provider for strapi email",
5
+ "keywords": [
6
+ "email",
7
+ "strapi",
8
+ "sendgrid"
9
+ ],
10
+ "homepage": "https://strapi.io",
11
+ "bugs": {
12
+ "url": "https://github.com/strapi/strapi/issues"
13
+ },
14
+ "repository": {
15
+ "type": "git",
16
+ "url": "git://github.com/strapi/strapi.git"
17
+ },
18
+ "license": "SEE LICENSE IN LICENSE",
19
+ "author": {
20
+ "name": "Strapi Solutions SAS",
21
+ "email": "hi@strapi.io",
22
+ "url": "https://strapi.io"
23
+ },
24
+ "maintainers": [
25
+ {
26
+ "name": "Strapi Solutions SAS",
27
+ "email": "hi@strapi.io",
28
+ "url": "https://strapi.io"
29
+ }
30
+ ],
31
+ "main": "./lib",
32
+ "directories": {
33
+ "lib": "./lib"
34
+ },
35
+ "scripts": {
36
+ "test": "echo \"no tests yet\""
37
+ },
38
+ "dependencies": {
39
+ "@sendgrid/mail": "7.4.7",
40
+ "@strapi/utils": "0.0.0-4fc90398602f"
41
+ },
42
+ "engines": {
43
+ "node": ">=14.19.1 <=16.x.x",
44
+ "npm": ">=6.0.0"
45
+ },
46
+ "gitHead": "4fc90398602f4a07f8ae8f04968c48d669992707"
47
+ }