@travetto/email 3.0.0-rc.1 → 3.0.0-rc.3
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/package.json +3 -3
- package/src/extension/nodemailer.ts +0 -48
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@travetto/email",
|
|
3
3
|
"displayName": "Email",
|
|
4
|
-
"version": "3.0.0-rc.
|
|
4
|
+
"version": "3.0.0-rc.3",
|
|
5
5
|
"description": "Email transmission module.",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"email",
|
|
@@ -24,8 +24,8 @@
|
|
|
24
24
|
"directory": "module/email"
|
|
25
25
|
},
|
|
26
26
|
"dependencies": {
|
|
27
|
-
"@travetto/config": "^3.0.0-rc.
|
|
28
|
-
"@travetto/di": "^3.0.0-rc.
|
|
27
|
+
"@travetto/config": "^3.0.0-rc.3",
|
|
28
|
+
"@travetto/di": "^3.0.0-rc.3",
|
|
29
29
|
"@types/mustache": "^4.2.1",
|
|
30
30
|
"mustache": "^4.2.0"
|
|
31
31
|
},
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
import type * as nodemailer from 'nodemailer';
|
|
2
|
-
import type * as json from 'nodemailer/lib/json-transport';
|
|
3
|
-
import type * as smtp from 'nodemailer/lib/smtp-transport';
|
|
4
|
-
import type * as ses from 'nodemailer/lib/ses-transport';
|
|
5
|
-
import type * as sendmail from 'nodemailer/lib/sendmail-transport';
|
|
6
|
-
|
|
7
|
-
import { MessageOptions, SentMessage } from '../types';
|
|
8
|
-
import { MailTransport } from '../transport';
|
|
9
|
-
|
|
10
|
-
type Transport = nodemailer.Transport | json.Options | smtp.Options | ses.Options | sendmail.Options;
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* Nodemailer transport, takes in a transport factory as the input
|
|
14
|
-
*/
|
|
15
|
-
export class NodemailerTransport implements MailTransport {
|
|
16
|
-
#transport: nodemailer.Transporter;
|
|
17
|
-
|
|
18
|
-
constructor(transportFactory: Transport) {
|
|
19
|
-
try {
|
|
20
|
-
const nm = require('nodemailer');
|
|
21
|
-
this.#transport = nm.createTransport(transportFactory);
|
|
22
|
-
} catch (err) {
|
|
23
|
-
if (err instanceof Error) {
|
|
24
|
-
console.error('Please install nodemailer before use: "npm install nodemailer"');
|
|
25
|
-
}
|
|
26
|
-
throw err;
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
async send<S extends SentMessage = SentMessage>(mail: MessageOptions): Promise<S> {
|
|
31
|
-
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions
|
|
32
|
-
const res = await this.#transport.sendMail(mail) as {
|
|
33
|
-
messageId?: string;
|
|
34
|
-
envelope?: Record<string, string>;
|
|
35
|
-
accepted?: string[];
|
|
36
|
-
rejected?: string[];
|
|
37
|
-
pending?: string[];
|
|
38
|
-
response?: string;
|
|
39
|
-
};
|
|
40
|
-
|
|
41
|
-
if (res.rejected?.length) {
|
|
42
|
-
console.error('Unable to send emails', { recipientCount: res.rejected?.length });
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions
|
|
46
|
-
return res as S;
|
|
47
|
-
}
|
|
48
|
-
}
|