@spinajs/email-smtp-transport 2.0.38
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 +11 -0
- package/lib/index.d.ts +0 -0
- package/lib/index.js +79 -0
- package/lib/index.js.map +1 -0
- package/package.json +56 -0
package/README.md
ADDED
package/lib/index.d.ts
ADDED
|
File without changes
|
package/lib/index.js
ADDED
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
// import { IOFail } from '@spinajs/exceptions';
|
|
2
|
+
// import { Autoinject, Injectable, NewInstance } from '@spinajs/di';
|
|
3
|
+
// import { Log, Logger } from '@spinajs/log';
|
|
4
|
+
// import { Email, EmailSender, EmailConnectionOptions } from '@spinajs/email';
|
|
5
|
+
// import { Templates } from '@spinajs/templates';
|
|
6
|
+
// import * as nodemailer from 'nodemailer';
|
|
7
|
+
// import { fs } from '@spinajs/fs';
|
|
8
|
+
// import _ from 'lodash';
|
|
9
|
+
// @Injectable()
|
|
10
|
+
// @NewInstance()
|
|
11
|
+
// export class EmailSenderSmtp extends EmailSender {
|
|
12
|
+
// @Logger('email')
|
|
13
|
+
// protected Log: Log;
|
|
14
|
+
// @Autoinject(Templates)
|
|
15
|
+
// protected Tempates: Templates;
|
|
16
|
+
// @Autoinject(fs, (x) => x.Provider)
|
|
17
|
+
// protected FileSystems: Map<string, fs>;
|
|
18
|
+
// protected Transporter: nodemailer.Transport;
|
|
19
|
+
// constructor(public Options: EmailConnectionOptions) {
|
|
20
|
+
// super();
|
|
21
|
+
// }
|
|
22
|
+
// public async resolveAsync(): Promise<void> {
|
|
23
|
+
// // create reusable transporter object using the default SMTP transport
|
|
24
|
+
// this.Transporter = nodemailer.createTransport(
|
|
25
|
+
// Object.assign(
|
|
26
|
+
// {
|
|
27
|
+
// host: this.Options.host,
|
|
28
|
+
// port: this.Options.port,
|
|
29
|
+
// secure: this.Options.ssl, // true for 465, false for other ports
|
|
30
|
+
// auth: {
|
|
31
|
+
// user: this.Options.login, // generated ethereal user
|
|
32
|
+
// pass: this.Options.password, // generated ethereal password
|
|
33
|
+
// },
|
|
34
|
+
// },
|
|
35
|
+
// // all additional options merged
|
|
36
|
+
// this.Options.options,
|
|
37
|
+
// ),
|
|
38
|
+
// );
|
|
39
|
+
// }
|
|
40
|
+
// public async send(email: Email): Promise<void> {
|
|
41
|
+
// const options = {
|
|
42
|
+
// from: email.from, // sender address
|
|
43
|
+
// to: email.to.join(','), // list of receivers
|
|
44
|
+
// cc: email.cc ? email.cc.join(',') : null,
|
|
45
|
+
// bcc: email.bcc ? email.bcc.join(',') : null,
|
|
46
|
+
// replyTo: email.replyTo,
|
|
47
|
+
// subject: email.subject, // Subject line
|
|
48
|
+
// text: email.text, // plain text body
|
|
49
|
+
// html: email.template ? await this.Tempates.render(email.template, email.model, email.lang) : null,
|
|
50
|
+
// attachments: await Promise.all(
|
|
51
|
+
// email.attachements.map(async (a) => {
|
|
52
|
+
// // we allow to use multiple file sources, default is local
|
|
53
|
+
// const provider = this.FileSystems.get(a.provider ?? 'fs-local');
|
|
54
|
+
// if (!provider) {
|
|
55
|
+
// throw new IOFail(`Filesystem privider for ${a.provider} not registered. Make sure you importer all required fs providers`);
|
|
56
|
+
// }
|
|
57
|
+
// // with local filesystem, it just return original path
|
|
58
|
+
// // other implementations should dodwnload file locally,
|
|
59
|
+
// // and return temporary path
|
|
60
|
+
// // we provide path to file, becouse nodemailer
|
|
61
|
+
// // prefer it when sending bigger files
|
|
62
|
+
// const file = await provider.download(a.path);
|
|
63
|
+
// return {
|
|
64
|
+
// filename: a.name,
|
|
65
|
+
// path: file,
|
|
66
|
+
// provider: provider.Provider,
|
|
67
|
+
// };
|
|
68
|
+
// }),
|
|
69
|
+
// ),
|
|
70
|
+
// };
|
|
71
|
+
// let message = await this.Transporter.sendMail(options);
|
|
72
|
+
// const response = await this.Transporter.send(message);
|
|
73
|
+
// // delete all downloaded files for attachement
|
|
74
|
+
// const fsLocal = this.FileSystems.get('fs-local');
|
|
75
|
+
// await Promise.all(options.attachments.filter((x) => x.provider !== 'fs-local').map((x) => fsLocal.unlink(x.path)));
|
|
76
|
+
// this.Log.trace(`Sent email with data: ${JSON.stringify(_.pick(email, ['from', 'to', 'cc', 'bcc', 'replyTo', 'subject']))}, SMTP response: ${JSON.stringify(response)}`);
|
|
77
|
+
// }
|
|
78
|
+
// }
|
|
79
|
+
//# sourceMappingURL=index.js.map
|
package/lib/index.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,gDAAgD;AAChD,qEAAqE;AACrE,8CAA8C;AAC9C,+EAA+E;AAC/E,kDAAkD;AAClD,4CAA4C;AAC5C,oCAAoC;AACpC,0BAA0B;AAE1B,gBAAgB;AAChB,iBAAiB;AACjB,qDAAqD;AACrD,qBAAqB;AACrB,wBAAwB;AAExB,2BAA2B;AAC3B,mCAAmC;AAEnC,uCAAuC;AACvC,4CAA4C;AAE5C,iDAAiD;AAEjD,0DAA0D;AAC1D,eAAe;AACf,MAAM;AAEN,iDAAiD;AACjD,6EAA6E;AAC7E,qDAAqD;AACrD,uBAAuB;AACvB,YAAY;AACZ,qCAAqC;AACrC,qCAAqC;AACrC,6EAA6E;AAC7E,oBAAoB;AACpB,mEAAmE;AACnE,0EAA0E;AAC1E,eAAe;AACf,aAAa;AAEb,2CAA2C;AAC3C,gCAAgC;AAChC,WAAW;AACX,SAAS;AACT,MAAM;AAEN,qDAAqD;AACrD,wBAAwB;AACxB,4CAA4C;AAC5C,qDAAqD;AACrD,kDAAkD;AAClD,qDAAqD;AACrD,gCAAgC;AAChC,gDAAgD;AAChD,6CAA6C;AAC7C,2GAA2G;AAC3G,wCAAwC;AACxC,gDAAgD;AAChD,uEAAuE;AACvE,6EAA6E;AAC7E,6BAA6B;AAC7B,0IAA0I;AAC1I,cAAc;AAEd,mEAAmE;AACnE,oEAAoE;AACpE,yCAAyC;AACzC,2DAA2D;AAC3D,mDAAmD;AACnD,0DAA0D;AAC1D,qBAAqB;AACrB,gCAAgC;AAChC,0BAA0B;AAC1B,2CAA2C;AAC3C,eAAe;AACf,cAAc;AACd,WAAW;AACX,SAAS;AAET,8DAA8D;AAE9D,6DAA6D;AAE7D,qDAAqD;AACrD,wDAAwD;AACxD,0HAA0H;AAE1H,+KAA+K;AAC/K,MAAM;AACN,IAAI"}
|
package/package.json
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@spinajs/email-smtp-transport",
|
|
3
|
+
"version": "2.0.38",
|
|
4
|
+
"description": "sending emails easy & reliable way",
|
|
5
|
+
"main": "lib/index.js",
|
|
6
|
+
"private": false,
|
|
7
|
+
"scripts": {
|
|
8
|
+
"build": "npm run clean && npm run compile && cpx src/views/**/* lib/views && cpx src/static/**/* lib/static",
|
|
9
|
+
"compile": "tsc -p tsconfig.build.json",
|
|
10
|
+
"clean": "",
|
|
11
|
+
"test": "ts-mocha -p tsconfig.json test/**/*.test.ts",
|
|
12
|
+
"coverage": "nyc npm run test",
|
|
13
|
+
"build-docs": "rimraf docs && typedoc --options typedoc.json src/",
|
|
14
|
+
"prepare": "npm run build",
|
|
15
|
+
"format": "prettier --write \"src/**/*.ts\"",
|
|
16
|
+
"lint": "eslint -c .eslintrc.js --ext .ts src --fix",
|
|
17
|
+
"prepublishOnly": "npm test && npm run lint",
|
|
18
|
+
"preversion": "npm run lint",
|
|
19
|
+
"version": "npm run format && git add -A src",
|
|
20
|
+
"postversion": "git push && git push --tags"
|
|
21
|
+
},
|
|
22
|
+
"files": [
|
|
23
|
+
"lib/**/*"
|
|
24
|
+
],
|
|
25
|
+
"types": "lib",
|
|
26
|
+
"repository": {
|
|
27
|
+
"type": "git",
|
|
28
|
+
"url": "git+https://github.com/spinajs/main.git"
|
|
29
|
+
},
|
|
30
|
+
"keywords": [
|
|
31
|
+
"spinajs",
|
|
32
|
+
"http"
|
|
33
|
+
],
|
|
34
|
+
"author": "SpinaJS <spinajs@coderush.pl> (https://github.com/spinajs/main)",
|
|
35
|
+
"license": "MIT",
|
|
36
|
+
"bugs": {
|
|
37
|
+
"url": "https://github.com/spinajs/main/issues"
|
|
38
|
+
},
|
|
39
|
+
"homepage": "https://github.com/spinajs/main#readme",
|
|
40
|
+
"devDependencies": {
|
|
41
|
+
"@types/luxon": "^2.3.1",
|
|
42
|
+
"@types/node": "^16.11.11",
|
|
43
|
+
"@types/nodemailer": "^6.4.4"
|
|
44
|
+
},
|
|
45
|
+
"dependencies": {
|
|
46
|
+
"@spinajs/configuration": "^2.0.38",
|
|
47
|
+
"@spinajs/di": "^2.0.38",
|
|
48
|
+
"@spinajs/exceptions": "^2.0.12",
|
|
49
|
+
"@spinajs/internal-logger": "^2.0.38",
|
|
50
|
+
"@spinajs/intl": "^2.0.38",
|
|
51
|
+
"@spinajs/log": "^2.0.38",
|
|
52
|
+
"luxon": "^2.3.0",
|
|
53
|
+
"nodemailer": "^6.7.7"
|
|
54
|
+
},
|
|
55
|
+
"gitHead": "5ea5440ee9db49595f531592ebdbc6d69f457082"
|
|
56
|
+
}
|