@hedhog/mail 0.0.4 → 0.0.6
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/interfaces/mail-module-options.interface.d.ts +2 -2
- package/dist/interfaces/mail-module-options.interface.d.ts.map +1 -1
- package/dist/mail.service.d.ts.map +1 -1
- package/dist/mail.service.js +1 -1
- package/dist/mail.service.js.map +1 -1
- package/package.json +6 -1
- package/src/mail.template.ejs +1 -0
- package/src/enums/mail-configuration-type.enum.ts +0 -5
- package/src/index.ts +0 -4
- package/src/interfaces/index.ts +0 -2
- package/src/interfaces/mail-module-options.interface.ts +0 -44
- package/src/interfaces/mail-type.ts +0 -12
- package/src/mail.consts.ts +0 -20
- package/src/mail.module.ts +0 -75
- package/src/mail.service.spec.ts +0 -18
- package/src/mail.service.ts +0 -296
- package/tsconfig.lib.json +0 -9
- package/tsconfig.production.json +0 -20
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"mail-module-options.interface.d.ts","sourceRoot":"","sources":["../../src/interfaces/mail-module-options.interface.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,gBAAgB,CAAC;AAEhE,MAAM,MAAM,iBAAiB,GACzB;IACE,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,IAAI,EAAE,KAAK,CAAC;IACZ,MAAM,EAAE,MAAM,CAAC;IACf,WAAW,EAAE,MAAM,CAAC;IACpB,eAAe,EAAE,MAAM,CAAC;IACxB,IAAI,EAAE,MAAM,CAAC;CACd,GACD;IACE,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,
|
1
|
+
{"version":3,"file":"mail-module-options.interface.d.ts","sourceRoot":"","sources":["../../src/interfaces/mail-module-options.interface.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,QAAQ,E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|
1
|
-
{"version":3,"file":"mail.service.d.ts","sourceRoot":"","sources":["../src/mail.service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAK5C,OAAO,EAAE,iBAAiB,EAAE,MAAM,4CAA4C,CAAC;AAC/E,OAAO,EAAE,IAAI,EAAuB,MAAM,eAAe,CAAC;AAE1D,qBACa,WAAW;IAES,OAAO,CAAC,QAAQ,CAAC,UAAU;IACxD,OAAO,CAAC,QAAQ,CAAC,WAAW;gBADkB,UAAU,EAAE,iBAAiB,EAC1D,WAAW,EAAE,WAAW;IAGrC,IAAI,CAAC,IAAI,EAAE,IAAI;IAaf,cAAc,CAAC,IAAI,EAAE,IAAI;IAyEzB,YAAY,CAAC,IAAI,EAAE,IAAI;
|
1
|
+
{"version":3,"file":"mail.service.d.ts","sourceRoot":"","sources":["../src/mail.service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAK5C,OAAO,EAAE,iBAAiB,EAAE,MAAM,4CAA4C,CAAC;AAC/E,OAAO,EAAE,IAAI,EAAuB,MAAM,eAAe,CAAC;AAE1D,qBACa,WAAW;IAES,OAAO,CAAC,QAAQ,CAAC,UAAU;IACxD,OAAO,CAAC,QAAQ,CAAC,WAAW;gBADkB,UAAU,EAAE,iBAAiB,EAC1D,WAAW,EAAE,WAAW;IAGrC,IAAI,CAAC,IAAI,EAAE,IAAI;IAaf,cAAc,CAAC,IAAI,EAAE,IAAI;IAyEzB,YAAY,CAAC,IAAI,EAAE,IAAI;IAqCvB,aAAa,CAAC,IAAI,EAAE,IAAI;IA0CxB,WAAW,CAAC,IAAI,EAAE,IAAI;CAyH7B"}
|
package/dist/mail.service.js
CHANGED
@@ -118,7 +118,7 @@ let MailService = class MailService {
|
|
118
118
|
if (this.mailConfig.type !== 'SMTP') {
|
119
119
|
throw new Error('Invalid mail configuration type');
|
120
120
|
}
|
121
|
-
const { pass, user, host, port, secure = false } = this.mailConfig;
|
121
|
+
const { password: pass, username: user, host, port, secure = false, } = this.mailConfig;
|
122
122
|
const nodemailer = await Promise.resolve().then(() => __importStar(require('nodemailer')));
|
123
123
|
const transporter = nodemailer.createTransport({
|
124
124
|
host,
|
package/dist/mail.service.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"mail.service.js","sourceRoot":"","sources":["../src/mail.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,yCAA4C;AAC5C,2CAAoD;AACpD,yDAA2C;AAC3C,+BAAsC;AACtC,uFAAiF;AAEjF,+CAA0D;AAGnD,IAAM,WAAW,GAAjB,MAAM,WAAW;IACtB,YACgD,UAA6B,EAC1D,WAAwB;QADK,eAAU,GAAV,UAAU,CAAmB;QAC1D,gBAAW,GAAX,WAAW,CAAa;IACxC,CAAC;IAEJ,KAAK,CAAC,IAAI,CAAC,IAAU;QACnB,QAAQ,IAAI,CAAC,UAAU,CAAC,IAAI,EAAE,CAAC;YAC7B,KAAK,wDAAyB,CAAC,GAAG;gBAChC,OAAO,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC;YAEhC,KAAK,wDAAyB,CAAC,KAAK;gBAClC,OAAO,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC;YAElC,KAAK,wDAAyB,CAAC,IAAI;gBACjC,OAAO,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC;QACnC,CAAC;IACH,CAAC;IAED,KAAK,CAAC,cAAc,CAAC,IAAU;;QAC7B,IAAI,IAAI,CAAC,WAAW,YAAY,KAAK,KAAI,MAAA,IAAI,CAAC,WAAW,0CAAE,MAAM,CAAA,EAAE,CAAC;YAClE,MAAM,WAAW,GAAG,WAAW,CAAC,OAAO,CAAC;gBACtC,WAAW,EAAE,iBAAiB;gBAC9B,IAAI,EAAE,EAAE;aACT,CAAC,CAAC;YAEH,WAAW,CAAC,MAAM,CAAC,MAAM,EAA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,SAAS,CAAC,MAAM,CAAC,CAAC,OAAO,EAAE,CAAC;QACzC,CAAC;IACH,CAAC;CACF,CAAA;AApSY,kCAAW;sBAAX,WAAW;IADvB,IAAA,mBAAU,GAAE;IAGR,WAAA,IAAA,eAAM,EAAC,iCAAmB,CAAC,CAAA;6CACE,mBAAW;GAHhC,WAAW,CAoSvB"}
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@hedhog/mail",
|
3
|
-
"version": "0.0.
|
3
|
+
"version": "0.0.6",
|
4
4
|
"main": "dist/index.js",
|
5
5
|
"scripts": {
|
6
6
|
"build": "tsc --project tsconfig.production.json && npm version patch",
|
@@ -10,6 +10,11 @@
|
|
10
10
|
"author": "HedHog",
|
11
11
|
"license": "MIT",
|
12
12
|
"description": "",
|
13
|
+
"files": [
|
14
|
+
"dist/**/*",
|
15
|
+
"src/migrations/**/*.ts",
|
16
|
+
"src/**/*.ejs"
|
17
|
+
],
|
13
18
|
"dependencies": {
|
14
19
|
"mimemessage": "1.0.5"
|
15
20
|
},
|
@@ -0,0 +1 @@
|
|
1
|
+
MailModule.register({ global: true, type: 'SMTP', host: 'changeme', port: 465, secure: false, username: 'changeme', password: 'changeme' })
|
package/src/index.ts
DELETED
package/src/interfaces/index.ts
DELETED
@@ -1,44 +0,0 @@
|
|
1
|
-
import { ModuleMetadata, Provider, Type } from '@nestjs/common';
|
2
|
-
|
3
|
-
export type MailModuleOptions =
|
4
|
-
| {
|
5
|
-
global?: boolean;
|
6
|
-
type: 'AWS';
|
7
|
-
region: string;
|
8
|
-
accessKeyId: string;
|
9
|
-
secretAccessKey: string;
|
10
|
-
from: string;
|
11
|
-
}
|
12
|
-
| {
|
13
|
-
global?: boolean;
|
14
|
-
type: 'SMTP';
|
15
|
-
host: string;
|
16
|
-
port: number;
|
17
|
-
secure?: boolean;
|
18
|
-
user: string;
|
19
|
-
pass: string;
|
20
|
-
}
|
21
|
-
| {
|
22
|
-
global?: boolean;
|
23
|
-
type: 'GMAIL';
|
24
|
-
clientId: string;
|
25
|
-
clientSecret: string;
|
26
|
-
refreshToken: string;
|
27
|
-
from: string;
|
28
|
-
};
|
29
|
-
|
30
|
-
export interface MailOptionsFactory {
|
31
|
-
createMailOptions(): Promise<MailModuleOptions> | MailModuleOptions;
|
32
|
-
}
|
33
|
-
|
34
|
-
export interface MailModuleAsyncOptions
|
35
|
-
extends Pick<ModuleMetadata, 'imports'> {
|
36
|
-
global?: boolean;
|
37
|
-
useExisting?: Type<MailOptionsFactory>;
|
38
|
-
useClass?: Type<MailOptionsFactory>;
|
39
|
-
useFactory?: (
|
40
|
-
...args: any[]
|
41
|
-
) => Promise<MailModuleOptions> | MailModuleOptions;
|
42
|
-
inject?: any[];
|
43
|
-
extraProviders?: Provider[];
|
44
|
-
}
|
@@ -1,12 +0,0 @@
|
|
1
|
-
export interface MailType {
|
2
|
-
from?: string;
|
3
|
-
to: string | string[];
|
4
|
-
cc?: string | string[];
|
5
|
-
bcc?: string | string[];
|
6
|
-
subject?: string;
|
7
|
-
body?: string;
|
8
|
-
replyTo?: string | string[];
|
9
|
-
priority?: string;
|
10
|
-
createdAt?: string;
|
11
|
-
updatedAt?: string;
|
12
|
-
}
|
package/src/mail.consts.ts
DELETED
@@ -1,20 +0,0 @@
|
|
1
|
-
import { MailType } from './interfaces/mail-type';
|
2
|
-
|
3
|
-
export type MailAttachment = {
|
4
|
-
filename?: string;
|
5
|
-
content?: Buffer;
|
6
|
-
contentType?: string;
|
7
|
-
};
|
8
|
-
|
9
|
-
export type Mail = {
|
10
|
-
attachments?: MailAttachment[];
|
11
|
-
} & MailType;
|
12
|
-
|
13
|
-
export type MailConfig = {
|
14
|
-
host?: string;
|
15
|
-
from?: string;
|
16
|
-
accessKeyId?: string;
|
17
|
-
secretAccessKey?: string;
|
18
|
-
};
|
19
|
-
|
20
|
-
export const MAIL_MODULE_OPTIONS = 'MAIL_MODULE_OPTIONS';
|
package/src/mail.module.ts
DELETED
@@ -1,75 +0,0 @@
|
|
1
|
-
import { HttpModule } from '@nestjs/axios';
|
2
|
-
import { DynamicModule, Module, Provider } from '@nestjs/common';
|
3
|
-
import {
|
4
|
-
MailModuleAsyncOptions,
|
5
|
-
MailModuleOptions,
|
6
|
-
MailOptionsFactory,
|
7
|
-
} from './interfaces/mail-module-options.interface';
|
8
|
-
import { MAIL_MODULE_OPTIONS } from './mail.consts';
|
9
|
-
import { MailService } from './mail.service';
|
10
|
-
|
11
|
-
@Module({
|
12
|
-
imports: [HttpModule],
|
13
|
-
providers: [MailService],
|
14
|
-
exports: [MailService],
|
15
|
-
})
|
16
|
-
export class MailModule {
|
17
|
-
static register(options: MailModuleOptions): DynamicModule {
|
18
|
-
console.log('MailModule.register', { options });
|
19
|
-
return {
|
20
|
-
module: MailModule,
|
21
|
-
global: options.global,
|
22
|
-
providers: [
|
23
|
-
{
|
24
|
-
provide: MAIL_MODULE_OPTIONS,
|
25
|
-
useValue: options || {},
|
26
|
-
},
|
27
|
-
],
|
28
|
-
};
|
29
|
-
}
|
30
|
-
|
31
|
-
static registerAsync(options: MailModuleAsyncOptions): DynamicModule {
|
32
|
-
return {
|
33
|
-
module: MailModule,
|
34
|
-
global: options.global,
|
35
|
-
imports: options.imports || [],
|
36
|
-
providers: [
|
37
|
-
...this.createAsyncProviders(options),
|
38
|
-
...(options.extraProviders ?? []),
|
39
|
-
],
|
40
|
-
};
|
41
|
-
}
|
42
|
-
|
43
|
-
private static createAsyncProviders(
|
44
|
-
options: MailModuleAsyncOptions,
|
45
|
-
): Provider[] {
|
46
|
-
if (options.useExisting || options.useFactory) {
|
47
|
-
return [this.createAsyncOptionsProvider(options)];
|
48
|
-
}
|
49
|
-
return [
|
50
|
-
this.createAsyncOptionsProvider(options),
|
51
|
-
{
|
52
|
-
provide: options.useClass,
|
53
|
-
useClass: options.useClass,
|
54
|
-
},
|
55
|
-
];
|
56
|
-
}
|
57
|
-
|
58
|
-
private static createAsyncOptionsProvider(
|
59
|
-
options: MailModuleAsyncOptions,
|
60
|
-
): Provider {
|
61
|
-
if (options.useFactory) {
|
62
|
-
return {
|
63
|
-
provide: MAIL_MODULE_OPTIONS,
|
64
|
-
useFactory: options.useFactory,
|
65
|
-
inject: options.inject || [],
|
66
|
-
};
|
67
|
-
}
|
68
|
-
return {
|
69
|
-
provide: MAIL_MODULE_OPTIONS,
|
70
|
-
useFactory: async (optionsFactory: MailOptionsFactory) =>
|
71
|
-
await optionsFactory.createMailOptions(),
|
72
|
-
inject: [options.useExisting || options.useClass],
|
73
|
-
};
|
74
|
-
}
|
75
|
-
}
|
package/src/mail.service.spec.ts
DELETED
@@ -1,18 +0,0 @@
|
|
1
|
-
import { Test, TestingModule } from '@nestjs/testing';
|
2
|
-
import { MailService } from './mail.service';
|
3
|
-
|
4
|
-
describe('MailService', () => {
|
5
|
-
let service: MailService;
|
6
|
-
|
7
|
-
beforeEach(async () => {
|
8
|
-
const module: TestingModule = await Test.createTestingModule({
|
9
|
-
providers: [MailService],
|
10
|
-
}).compile();
|
11
|
-
|
12
|
-
service = module.get<MailService>(MailService);
|
13
|
-
});
|
14
|
-
|
15
|
-
it('should be defined', () => {
|
16
|
-
expect(service).toBeDefined();
|
17
|
-
});
|
18
|
-
});
|
package/src/mail.service.ts
DELETED
@@ -1,296 +0,0 @@
|
|
1
|
-
import { HttpService } from '@nestjs/axios';
|
2
|
-
import { Inject, Injectable } from '@nestjs/common';
|
3
|
-
import * as mimemessage from 'mimemessage';
|
4
|
-
import { firstValueFrom } from 'rxjs';
|
5
|
-
import { MailConfigurationTypeEnum } from './enums/mail-configuration-type.enum';
|
6
|
-
import { MailModuleOptions } from './interfaces/mail-module-options.interface';
|
7
|
-
import { Mail, MAIL_MODULE_OPTIONS } from './mail.consts';
|
8
|
-
|
9
|
-
@Injectable()
|
10
|
-
export class MailService {
|
11
|
-
constructor(
|
12
|
-
@Inject(MAIL_MODULE_OPTIONS) private readonly mailConfig: MailModuleOptions,
|
13
|
-
private readonly httpService: HttpService,
|
14
|
-
) {}
|
15
|
-
|
16
|
-
async send(mail: Mail) {
|
17
|
-
switch (this.mailConfig.type) {
|
18
|
-
case MailConfigurationTypeEnum.AWS:
|
19
|
-
return this.sendWithSES(mail);
|
20
|
-
|
21
|
-
case MailConfigurationTypeEnum.GMAIL:
|
22
|
-
return this.sendWithGmail(mail);
|
23
|
-
|
24
|
-
case MailConfigurationTypeEnum.SMTP:
|
25
|
-
return this.sendWithSMTP(mail);
|
26
|
-
}
|
27
|
-
}
|
28
|
-
|
29
|
-
async createRawEmail(mail: Mail) {
|
30
|
-
if (mail.attachments instanceof Array && mail.attachments?.length) {
|
31
|
-
const mailContent = mimemessage.factory({
|
32
|
-
contentType: 'multipart/mixed',
|
33
|
-
body: [],
|
34
|
-
});
|
35
|
-
|
36
|
-
mailContent.header('From', mail.from);
|
37
|
-
mailContent.header('To', mail.to);
|
38
|
-
mailContent.header('Subject', mail.subject);
|
39
|
-
|
40
|
-
const alternateEntity = mimemessage.factory({
|
41
|
-
contentType: 'multipart/alternate',
|
42
|
-
body: [],
|
43
|
-
});
|
44
|
-
|
45
|
-
const htmlEntity = mimemessage.factory({
|
46
|
-
contentType: 'text/html;charset=utf-8',
|
47
|
-
body: mail.body,
|
48
|
-
});
|
49
|
-
|
50
|
-
alternateEntity.body.push(htmlEntity);
|
51
|
-
|
52
|
-
mailContent.body.push(alternateEntity);
|
53
|
-
|
54
|
-
await Promise.all(
|
55
|
-
(mail.attachments ?? []).map(async (attachment) => {
|
56
|
-
const attachmentEntity = mimemessage.factory({
|
57
|
-
contentType: attachment.contentType,
|
58
|
-
contentTransferEncoding: 'base64',
|
59
|
-
body: attachment.content
|
60
|
-
.toString('base64')
|
61
|
-
.replace(/([^\0]{76})/g, '$1\n'),
|
62
|
-
});
|
63
|
-
|
64
|
-
attachmentEntity.header(
|
65
|
-
'Content-Disposition',
|
66
|
-
`attachment; filename="${attachment.filename}"`,
|
67
|
-
);
|
68
|
-
|
69
|
-
mailContent.body.push(attachmentEntity);
|
70
|
-
}),
|
71
|
-
);
|
72
|
-
|
73
|
-
const messageString = mailContent.toString();
|
74
|
-
const encodedMessage = Buffer.from(messageString)
|
75
|
-
.toString('base64')
|
76
|
-
.replace(/\+/g, '-')
|
77
|
-
.replace(/\//g, '_')
|
78
|
-
.replace(/=+$/, '');
|
79
|
-
|
80
|
-
return encodedMessage;
|
81
|
-
} else {
|
82
|
-
const messageParts = [
|
83
|
-
`From: ${mail.from}`,
|
84
|
-
`To: ${mail.to instanceof Array ? mail.to.join(',') : mail.to}`,
|
85
|
-
`Subject: ${mail.subject}`,
|
86
|
-
'Content-Type: text/plain; charset="UTF-8"',
|
87
|
-
'',
|
88
|
-
mail.body,
|
89
|
-
];
|
90
|
-
|
91
|
-
const message = messageParts.join('\n');
|
92
|
-
const encodedMessage = Buffer.from(message)
|
93
|
-
.toString('base64')
|
94
|
-
.replace(/\+/g, '-')
|
95
|
-
.replace(/\//g, '_')
|
96
|
-
.replace(/=+$/, '');
|
97
|
-
|
98
|
-
return encodedMessage;
|
99
|
-
}
|
100
|
-
}
|
101
|
-
|
102
|
-
async sendWithSMTP(mail: Mail) {
|
103
|
-
if (this.mailConfig.type !== 'SMTP') {
|
104
|
-
throw new Error('Invalid mail configuration type');
|
105
|
-
}
|
106
|
-
|
107
|
-
const { pass, user, host, port, secure = false } = this.mailConfig;
|
108
|
-
|
109
|
-
const nodemailer = await import('nodemailer');
|
110
|
-
|
111
|
-
const transporter = nodemailer.createTransport({
|
112
|
-
host,
|
113
|
-
port,
|
114
|
-
secure,
|
115
|
-
auth: {
|
116
|
-
user,
|
117
|
-
pass,
|
118
|
-
},
|
119
|
-
});
|
120
|
-
|
121
|
-
return transporter.sendMail({
|
122
|
-
from: mail.from || process.env.SMTP_FROM || process.env.SMTP_USER,
|
123
|
-
to: mail.to,
|
124
|
-
subject: mail.subject,
|
125
|
-
html: mail.body,
|
126
|
-
cc: mail.cc,
|
127
|
-
bcc: mail.bcc,
|
128
|
-
replyTo: mail.replyTo,
|
129
|
-
priority: mail.priority,
|
130
|
-
});
|
131
|
-
}
|
132
|
-
|
133
|
-
async sendWithGmail(mail: Mail) {
|
134
|
-
if (this.mailConfig.type !== 'GMAIL') {
|
135
|
-
throw new Error('Invalid mail configuration type');
|
136
|
-
}
|
137
|
-
const { clientId, clientSecret, from, refreshToken } = this.mailConfig;
|
138
|
-
const redirectURI = 'https://developers.google.com/oauthplayground';
|
139
|
-
|
140
|
-
const { google } = await import('googleapis');
|
141
|
-
|
142
|
-
const oauth2Client = new google.auth.OAuth2(
|
143
|
-
clientId,
|
144
|
-
clientSecret,
|
145
|
-
redirectURI,
|
146
|
-
);
|
147
|
-
|
148
|
-
oauth2Client.setCredentials({
|
149
|
-
refresh_token: refreshToken,
|
150
|
-
});
|
151
|
-
|
152
|
-
const { token } = await oauth2Client.getAccessToken();
|
153
|
-
|
154
|
-
const raw = await this.createRawEmail({
|
155
|
-
...mail,
|
156
|
-
from,
|
157
|
-
});
|
158
|
-
|
159
|
-
const url = 'https://www.googleapis.com/gmail/v1/users/me/messages/send';
|
160
|
-
|
161
|
-
const requestBody = {
|
162
|
-
raw,
|
163
|
-
};
|
164
|
-
|
165
|
-
const headers = {
|
166
|
-
Authorization: `Bearer ${token}`,
|
167
|
-
'Content-Type': 'application/json',
|
168
|
-
};
|
169
|
-
|
170
|
-
const response = this.httpService.post(url, requestBody, { headers });
|
171
|
-
|
172
|
-
return firstValueFrom(response);
|
173
|
-
}
|
174
|
-
|
175
|
-
async sendWithSES(mail: Mail) {
|
176
|
-
if (this.mailConfig.type !== 'AWS') {
|
177
|
-
throw new Error('Invalid mail configuration type');
|
178
|
-
}
|
179
|
-
const { region, from, accessKeyId, secretAccessKey } = this.mailConfig;
|
180
|
-
|
181
|
-
const { SES } = await import('aws-sdk');
|
182
|
-
|
183
|
-
const ses = new SES({
|
184
|
-
apiVersion: '2010-12-01',
|
185
|
-
region,
|
186
|
-
credentials: {
|
187
|
-
accessKeyId,
|
188
|
-
secretAccessKey,
|
189
|
-
},
|
190
|
-
});
|
191
|
-
|
192
|
-
ses.config.update({
|
193
|
-
credentials: {
|
194
|
-
accessKeyId,
|
195
|
-
secretAccessKey,
|
196
|
-
},
|
197
|
-
});
|
198
|
-
|
199
|
-
if (typeof mail.to === 'string') {
|
200
|
-
mail.to = mail.to.split(';');
|
201
|
-
}
|
202
|
-
if (typeof mail.bcc === 'string') {
|
203
|
-
mail.bcc = mail.bcc.split(';');
|
204
|
-
} else if (!mail.bcc) {
|
205
|
-
mail.bcc = [];
|
206
|
-
}
|
207
|
-
if (typeof mail.cc === 'string') {
|
208
|
-
mail.cc = mail.cc.split(';');
|
209
|
-
} else if (!mail.cc) {
|
210
|
-
mail.cc = [];
|
211
|
-
}
|
212
|
-
if (typeof mail.replyTo === 'string') {
|
213
|
-
mail.replyTo = mail.replyTo.split(';');
|
214
|
-
} else if (!mail.replyTo) {
|
215
|
-
mail.replyTo = [];
|
216
|
-
}
|
217
|
-
|
218
|
-
if (mail.attachments instanceof Array && mail.attachments.length > 0) {
|
219
|
-
const mailContent = mimemessage.factory({
|
220
|
-
contentType: 'multipart/mixed',
|
221
|
-
body: [],
|
222
|
-
});
|
223
|
-
|
224
|
-
mailContent.header('From', from);
|
225
|
-
mailContent.header('To', mail.to);
|
226
|
-
mailContent.header('Subject', mail.subject);
|
227
|
-
|
228
|
-
const alternateEntity = mimemessage.factory({
|
229
|
-
contentType: 'multipart/alternate',
|
230
|
-
body: [],
|
231
|
-
});
|
232
|
-
|
233
|
-
const htmlEntity = mimemessage.factory({
|
234
|
-
contentType: 'text/html;charset=utf-8',
|
235
|
-
body: mail.body,
|
236
|
-
});
|
237
|
-
|
238
|
-
alternateEntity.body.push(htmlEntity);
|
239
|
-
|
240
|
-
mailContent.body.push(alternateEntity);
|
241
|
-
|
242
|
-
await Promise.all(
|
243
|
-
(mail.attachments ?? []).map((item) => {
|
244
|
-
const attachmentEntity = mimemessage.factory({
|
245
|
-
contentType: item.contentType,
|
246
|
-
contentTransferEncoding: 'base64',
|
247
|
-
body: item.content
|
248
|
-
.toString('base64')
|
249
|
-
.replace(/([^\0]{76})/g, '$1\n'),
|
250
|
-
});
|
251
|
-
|
252
|
-
attachmentEntity.header(
|
253
|
-
'Content-Disposition',
|
254
|
-
`attachment ;filename="${item.filename}"`,
|
255
|
-
);
|
256
|
-
|
257
|
-
mailContent.body.push(attachmentEntity);
|
258
|
-
}),
|
259
|
-
);
|
260
|
-
|
261
|
-
return ses
|
262
|
-
.sendRawEmail({
|
263
|
-
RawMessage: { Data: mailContent.toString() },
|
264
|
-
})
|
265
|
-
.promise();
|
266
|
-
} else {
|
267
|
-
const params = {
|
268
|
-
Destination: {
|
269
|
-
ToAddresses: mail.to,
|
270
|
-
BccAddresses: mail.bcc,
|
271
|
-
CcAddresses: mail.cc,
|
272
|
-
},
|
273
|
-
Message: {
|
274
|
-
Body: {
|
275
|
-
Html: {
|
276
|
-
Data: mail.body,
|
277
|
-
Charset: 'utf-8',
|
278
|
-
},
|
279
|
-
Text: {
|
280
|
-
Data: mail.body,
|
281
|
-
Charset: 'utf-8',
|
282
|
-
},
|
283
|
-
},
|
284
|
-
Subject: {
|
285
|
-
Data: mail.subject,
|
286
|
-
Charset: 'utf-8',
|
287
|
-
},
|
288
|
-
},
|
289
|
-
ReplyToAddresses: mail.replyTo,
|
290
|
-
Source: from,
|
291
|
-
};
|
292
|
-
|
293
|
-
return ses.sendEmail(params).promise();
|
294
|
-
}
|
295
|
-
}
|
296
|
-
}
|
package/tsconfig.lib.json
DELETED
package/tsconfig.production.json
DELETED
@@ -1,20 +0,0 @@
|
|
1
|
-
{
|
2
|
-
"compilerOptions": {
|
3
|
-
"experimentalDecorators": true,
|
4
|
-
"target": "es2017",
|
5
|
-
"module": "commonjs",
|
6
|
-
"lib": ["es2017", "es7", "es6"],
|
7
|
-
"declaration": true,
|
8
|
-
"declarationMap": true,
|
9
|
-
"sourceMap": true,
|
10
|
-
"outDir": "./dist",
|
11
|
-
"rootDir": "./src",
|
12
|
-
"strict": true,
|
13
|
-
"noImplicitAny": false,
|
14
|
-
"strictNullChecks": false,
|
15
|
-
"allowSyntheticDefaultImports": true,
|
16
|
-
"esModuleInterop": true,
|
17
|
-
"emitDecoratorMetadata": true
|
18
|
-
},
|
19
|
-
"exclude": ["node_modules", "dist"]
|
20
|
-
}
|