@storecraft/mailer-providers-http 1.0.13 → 1.0.15
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/README.md +92 -44
- package/package.json +1 -1
package/README.md
CHANGED
@@ -12,8 +12,6 @@ Supports wellknown http-based `serverless` friendly `email` providers,
|
|
12
12
|
- [Mailchimp](https://mailchimp.com/developer/transactional/api/messages/send-new-message/)
|
13
13
|
- [Mailgun](https://documentation.mailgun.com/en/latest/api-sending.html#examples)
|
14
14
|
|
15
|
-
> TODO: confirm tests
|
16
|
-
|
17
15
|
```bash
|
18
16
|
npm i @storecraft/mailer-providers-http
|
19
17
|
```
|
@@ -23,91 +21,141 @@ npm i @storecraft/mailer-providers-http
|
|
23
21
|
### Sendgrid
|
24
22
|
|
25
23
|
```js
|
24
|
+
import { App } from '@storecraft/core';
|
26
25
|
import { SendGrid } from '@storecraft/mailer-providers-http/sendgrid';
|
27
26
|
|
28
|
-
const
|
29
|
-
|
27
|
+
const app = new App(config)
|
28
|
+
.withPlatform(new NodePlatform())
|
29
|
+
.withDatabase(new MongoDB())
|
30
|
+
.withStorage(new GoogleStorage())
|
31
|
+
.withMailer(
|
32
|
+
new SendGrid(
|
33
|
+
{
|
30
34
|
apikey: process.env.SEND_GRID_SECRET
|
31
|
-
|
35
|
+
}
|
36
|
+
)
|
32
37
|
);
|
33
38
|
|
39
|
+
await app.init();
|
40
|
+
```
|
41
|
+
|
42
|
+
Storecraft will search the following `env` variables
|
43
|
+
|
44
|
+
```bash
|
45
|
+
SENDGRID_API_KEY=<key>
|
46
|
+
```
|
34
47
|
|
35
|
-
|
36
|
-
from: {name: 'bob 👻', address: process.env.FROM_EMAIL }, // sender address
|
37
|
-
to: [ { address: process.env.TO_EMAIL } ], // list of receivers
|
38
|
-
subject: 'subject test', // Subject line
|
39
|
-
text: 'plain text test', // plain text body
|
40
|
-
html: '<p>html test</p>', // html body
|
41
|
-
});
|
48
|
+
So, you can instantiate with empty config
|
42
49
|
|
50
|
+
```ts
|
51
|
+
.withMailer(
|
52
|
+
new SendGrid()
|
53
|
+
)
|
43
54
|
```
|
44
55
|
|
45
56
|
### Resend
|
46
57
|
```js
|
58
|
+
import { App } from '@storecraft/core';
|
47
59
|
import { Resend } from '@storecraft/mailer-providers-http/resend';
|
48
60
|
|
49
|
-
const
|
50
|
-
|
61
|
+
const app = new App(config)
|
62
|
+
.withPlatform(new NodePlatform())
|
63
|
+
.withDatabase(new MongoDB())
|
64
|
+
.withStorage(new GoogleStorage())
|
65
|
+
.withMailer(
|
66
|
+
new Resend(
|
67
|
+
{
|
51
68
|
apikey: process.env.RESEND_API_KEY
|
52
|
-
|
69
|
+
}
|
70
|
+
)
|
53
71
|
);
|
54
72
|
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
text: 'plain text test', // plain text body
|
60
|
-
html: '<p>html test</p>', // html body
|
61
|
-
});
|
73
|
+
await app.init();
|
74
|
+
```
|
75
|
+
|
76
|
+
Storecraft will search the following `env` variables
|
62
77
|
|
78
|
+
```bash
|
79
|
+
RESEND_API_KEY=<key>
|
63
80
|
```
|
64
81
|
|
82
|
+
So, you can instantiate with empty config
|
83
|
+
|
84
|
+
```ts
|
85
|
+
.withMailer(
|
86
|
+
new Resend()
|
87
|
+
)
|
88
|
+
```
|
65
89
|
|
66
90
|
### Mailchimp
|
67
91
|
|
68
92
|
```js
|
93
|
+
import { App } from '@storecraft/core';
|
69
94
|
import { MailChimp } from '@storecraft/mailer-providers-http/mailchimp';
|
70
95
|
|
71
|
-
const
|
72
|
-
|
96
|
+
const app = new App(config)
|
97
|
+
.withPlatform(new NodePlatform())
|
98
|
+
.withDatabase(new MongoDB())
|
99
|
+
.withStorage(new GoogleStorage())
|
100
|
+
.withMailer(
|
101
|
+
new MailChimp(
|
102
|
+
{
|
73
103
|
apikey: process.env.MAILCHIMP_API_KEY
|
74
|
-
|
104
|
+
}
|
105
|
+
)
|
75
106
|
);
|
76
107
|
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
subject: 'subject test', // Subject line
|
81
|
-
text: 'plain text test', // plain text body
|
82
|
-
html: '<p>html test</p>', // html body
|
83
|
-
});
|
108
|
+
await app.init();
|
109
|
+
```
|
110
|
+
Storecraft will search the following `env` variables
|
84
111
|
|
112
|
+
```bash
|
113
|
+
MAILCHIMP_API_KEY=<key>
|
85
114
|
```
|
86
115
|
|
116
|
+
So, you can instantiate with empty config
|
117
|
+
|
118
|
+
```ts
|
119
|
+
.withMailer(
|
120
|
+
new MailChimp()
|
121
|
+
)
|
122
|
+
```
|
87
123
|
|
88
124
|
### Mailgun
|
89
125
|
|
90
126
|
```js
|
127
|
+
|
128
|
+
import { App } from '@storecraft/core';
|
91
129
|
import { Mailgun } from '@storecraft/mailer-providers-http/mailgun';
|
92
130
|
|
93
|
-
const
|
94
|
-
|
131
|
+
const app = new App(config)
|
132
|
+
.withPlatform(new NodePlatform())
|
133
|
+
.withDatabase(new MongoDB())
|
134
|
+
.withStorage(new GoogleStorage())
|
135
|
+
.withMailer(
|
136
|
+
new Mailgun(
|
137
|
+
{
|
95
138
|
apikey: process.env.MAILGUN_API_KEY
|
96
|
-
|
139
|
+
}
|
140
|
+
)
|
97
141
|
);
|
98
142
|
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
subject: 'subject test', // Subject line
|
104
|
-
text: 'plain text test', // plain text body
|
105
|
-
html: '<p>html test</p>', // html body
|
106
|
-
}
|
107
|
-
);
|
143
|
+
await app.init();
|
144
|
+
```
|
145
|
+
|
146
|
+
Storecraft will search the following `env` variables
|
108
147
|
|
148
|
+
```bash
|
149
|
+
MAILGUN_API_KEY=<key>
|
109
150
|
```
|
110
151
|
|
152
|
+
So, you can instantiate with empty config
|
153
|
+
|
154
|
+
```ts
|
155
|
+
.withMailer(
|
156
|
+
new Mailgun()
|
157
|
+
)
|
158
|
+
```
|
111
159
|
|
112
160
|
```text
|
113
161
|
Author: Tomer Shalev (tomer.shalev@gmail.com)
|
package/package.json
CHANGED