@spinajs/email-smtp-transport 2.0.180 → 2.0.181

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.
@@ -1,17 +1,17 @@
1
- import { Log } from '@spinajs/log';
2
- import { IEmail, EmailSender, EmailConnectionOptions } from '@spinajs/email';
3
- import { Templates } from '@spinajs/templates';
4
- import * as nodemailer from 'nodemailer';
5
- import { fs } from '@spinajs/fs';
6
- export declare class EmailSenderSmtp extends EmailSender {
7
- Options: EmailConnectionOptions;
8
- protected Log: Log;
9
- protected Tempates: Templates;
10
- protected FileSystems: Map<string, fs>;
11
- protected DefaultFileProvider: string;
12
- protected Transporter: nodemailer.Transporter;
13
- constructor(Options: EmailConnectionOptions);
14
- resolve(): Promise<void>;
15
- send(email: IEmail): Promise<void>;
16
- }
1
+ import { Log } from '@spinajs/log';
2
+ import { IEmail, EmailSender, EmailConnectionOptions } from '@spinajs/email';
3
+ import { Templates } from '@spinajs/templates';
4
+ import * as nodemailer from 'nodemailer';
5
+ import { fs } from '@spinajs/fs';
6
+ export declare class EmailSenderSmtp extends EmailSender {
7
+ Options: EmailConnectionOptions;
8
+ protected Log: Log;
9
+ protected Tempates: Templates;
10
+ protected FileSystems: Map<string, fs>;
11
+ protected DefaultFileProvider: string;
12
+ protected Transporter: nodemailer.Transporter;
13
+ constructor(Options: EmailConnectionOptions);
14
+ resolve(): Promise<void>;
15
+ send(email: IEmail): Promise<void>;
16
+ }
17
17
  //# sourceMappingURL=index.d.ts.map
package/lib/cjs/index.js CHANGED
@@ -1,139 +1,139 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
19
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
20
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
21
- else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
22
- return c > 3 && r && Object.defineProperty(target, key, r), r;
23
- };
24
- var __importStar = (this && this.__importStar) || function (mod) {
25
- if (mod && mod.__esModule) return mod;
26
- var result = {};
27
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
28
- __setModuleDefault(result, mod);
29
- return result;
30
- };
31
- var __metadata = (this && this.__metadata) || function (k, v) {
32
- if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
33
- };
34
- var __importDefault = (this && this.__importDefault) || function (mod) {
35
- return (mod && mod.__esModule) ? mod : { "default": mod };
36
- };
37
- Object.defineProperty(exports, "__esModule", { value: true });
38
- exports.EmailSenderSmtp = void 0;
39
- const exceptions_1 = require("@spinajs/exceptions");
40
- const di_1 = require("@spinajs/di");
41
- const log_1 = require("@spinajs/log");
42
- const email_1 = require("@spinajs/email");
43
- const templates_1 = require("@spinajs/templates");
44
- const nodemailer = __importStar(require("nodemailer"));
45
- const fs_1 = require("@spinajs/fs");
46
- const lodash_1 = __importDefault(require("lodash"));
47
- const configuration_1 = require("@spinajs/configuration");
48
- let EmailSenderSmtp = class EmailSenderSmtp extends email_1.EmailSender {
49
- constructor(Options) {
50
- super();
51
- this.Options = Options;
52
- }
53
- async resolve() {
54
- // create reusable transporter object using the default SMTP transport
55
- this.Transporter = nodemailer.createTransport(Object.assign({
56
- host: this.Options.host,
57
- port: this.Options.port,
58
- secure: this.Options.ssl,
59
- auth: {
60
- user: this.Options.user,
61
- pass: this.Options.pass, // generated ethereal password
62
- },
63
- },
64
- // all additional options merged
65
- this.Options.options));
66
- try {
67
- // verify returns Promise<true> so always is true
68
- // we must catch exception
69
- await this.Transporter.verify();
70
- }
71
- catch (err) {
72
- this.Log.error(`Cannot connect to smtp server. Error: ${err.message}, connection: ${this.Options.name}`);
73
- throw new Error(`cannot send smtp emails, verify() failed. Pleas check email smtp configuration for connection ${this.Options.name}`);
74
- }
75
- this.Log.success(`Email smtp connection ${this.Options.name} on host ${this.Options.host} established !`);
76
- }
77
- async send(email) {
78
- const options = {
79
- from: email.from,
80
- to: email.to.join(','),
81
- cc: email.cc ? email.cc.join(',') : null,
82
- bcc: email.bcc ? email.bcc.join(',') : null,
83
- replyTo: email.replyTo,
84
- subject: email.subject,
85
- text: email.text,
86
- html: email.template ? await this.Tempates.render(email.template, email.model, email.lang) : null,
87
- attachments: [],
88
- };
89
- if (email.attachements) {
90
- options.attachments = await Promise.all(email.attachements.map(async (a) => {
91
- // we allow to use multiple file sources, default is local
92
- const provider = this.FileSystems.get(a.provider ?? this.DefaultFileProvider);
93
- if (!provider) {
94
- throw new exceptions_1.IOFail(`Filesystem provider for ${a.provider} not registered. Make sure you importer all required fs providers`);
95
- }
96
- // with local filesystem, it just return original path
97
- // other implementations should dodwnload file locally,
98
- // and return temporary path
99
- // we provide path to file, becouse nodemailer
100
- // prefer it when sending bigger files
101
- const file = await provider.download(a.path);
102
- return {
103
- filename: a.name,
104
- path: file,
105
- provider: provider.Name,
106
- };
107
- }));
108
- }
109
- let message = await this.Transporter.sendMail(options);
110
- // delete all downloaded files for attachement
111
- // all non local files are downloaded
112
- // and temporary path is in email attachement path property
113
- await Promise.all(options.attachments.filter((x) => x.provider !== 'fs-local').map((x) => this.FileSystems.get(x.provider).unlink(x.path)));
114
- this.Log.trace(`Sent email with data: ${JSON.stringify(lodash_1.default.pick(email, ['from', 'to', 'cc', 'bcc', 'replyTo', 'subject']))}, SMTP response: ${JSON.stringify(message)}`);
115
- }
116
- };
117
- __decorate([
118
- (0, log_1.Logger)('email'),
119
- __metadata("design:type", log_1.Log)
120
- ], EmailSenderSmtp.prototype, "Log", void 0);
121
- __decorate([
122
- (0, di_1.Autoinject)(templates_1.Templates),
123
- __metadata("design:type", templates_1.Templates)
124
- ], EmailSenderSmtp.prototype, "Tempates", void 0);
125
- __decorate([
126
- (0, configuration_1.AutoinjectService)('fs.providers', fs_1.fs),
127
- __metadata("design:type", Map)
128
- ], EmailSenderSmtp.prototype, "FileSystems", void 0);
129
- __decorate([
130
- (0, configuration_1.Config)('fs.defaultProvider'),
131
- __metadata("design:type", String)
132
- ], EmailSenderSmtp.prototype, "DefaultFileProvider", void 0);
133
- EmailSenderSmtp = __decorate([
134
- (0, di_1.Injectable)(email_1.EmailSender),
135
- (0, di_1.PerInstanceCheck)(),
136
- __metadata("design:paramtypes", [Object])
137
- ], EmailSenderSmtp);
138
- exports.EmailSenderSmtp = EmailSenderSmtp;
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
19
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
20
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
21
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
22
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
23
+ };
24
+ var __importStar = (this && this.__importStar) || function (mod) {
25
+ if (mod && mod.__esModule) return mod;
26
+ var result = {};
27
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
28
+ __setModuleDefault(result, mod);
29
+ return result;
30
+ };
31
+ var __metadata = (this && this.__metadata) || function (k, v) {
32
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
33
+ };
34
+ var __importDefault = (this && this.__importDefault) || function (mod) {
35
+ return (mod && mod.__esModule) ? mod : { "default": mod };
36
+ };
37
+ Object.defineProperty(exports, "__esModule", { value: true });
38
+ exports.EmailSenderSmtp = void 0;
39
+ const exceptions_1 = require("@spinajs/exceptions");
40
+ const di_1 = require("@spinajs/di");
41
+ const log_1 = require("@spinajs/log");
42
+ const email_1 = require("@spinajs/email");
43
+ const templates_1 = require("@spinajs/templates");
44
+ const nodemailer = __importStar(require("nodemailer"));
45
+ const fs_1 = require("@spinajs/fs");
46
+ const lodash_1 = __importDefault(require("lodash"));
47
+ const configuration_1 = require("@spinajs/configuration");
48
+ let EmailSenderSmtp = class EmailSenderSmtp extends email_1.EmailSender {
49
+ constructor(Options) {
50
+ super();
51
+ this.Options = Options;
52
+ }
53
+ async resolve() {
54
+ // create reusable transporter object using the default SMTP transport
55
+ this.Transporter = nodemailer.createTransport(Object.assign({
56
+ host: this.Options.host,
57
+ port: this.Options.port,
58
+ secure: this.Options.ssl,
59
+ auth: {
60
+ user: this.Options.user,
61
+ pass: this.Options.pass, // generated ethereal password
62
+ },
63
+ },
64
+ // all additional options merged
65
+ this.Options.options));
66
+ try {
67
+ // verify returns Promise<true> so always is true
68
+ // we must catch exception
69
+ await this.Transporter.verify();
70
+ }
71
+ catch (err) {
72
+ this.Log.error(`Cannot connect to smtp server. Error: ${err.message}, connection: ${this.Options.name}`);
73
+ throw new Error(`cannot send smtp emails, verify() failed. Pleas check email smtp configuration for connection ${this.Options.name}`);
74
+ }
75
+ this.Log.success(`Email smtp connection ${this.Options.name} on host ${this.Options.host} established !`);
76
+ }
77
+ async send(email) {
78
+ const options = {
79
+ from: email.from,
80
+ to: email.to.join(','),
81
+ cc: email.cc ? email.cc.join(',') : null,
82
+ bcc: email.bcc ? email.bcc.join(',') : null,
83
+ replyTo: email.replyTo,
84
+ subject: email.subject,
85
+ text: email.text,
86
+ html: email.template ? await this.Tempates.render(email.template, email.model, email.lang) : null,
87
+ attachments: [],
88
+ };
89
+ if (email.attachements) {
90
+ options.attachments = await Promise.all(email.attachements.map(async (a) => {
91
+ // we allow to use multiple file sources, default is local
92
+ const provider = this.FileSystems.get(a.provider ?? this.DefaultFileProvider);
93
+ if (!provider) {
94
+ throw new exceptions_1.IOFail(`Filesystem provider for ${a.provider} not registered. Make sure you importer all required fs providers`);
95
+ }
96
+ // with local filesystem, it just return original path
97
+ // other implementations should dodwnload file locally,
98
+ // and return temporary path
99
+ // we provide path to file, becouse nodemailer
100
+ // prefer it when sending bigger files
101
+ const file = await provider.download(a.path);
102
+ return {
103
+ filename: a.name,
104
+ path: file,
105
+ provider: provider.Name,
106
+ };
107
+ }));
108
+ }
109
+ let message = await this.Transporter.sendMail(options);
110
+ // delete all downloaded files for attachement
111
+ // all non local files are downloaded
112
+ // and temporary path is in email attachement path property
113
+ await Promise.all(options.attachments.filter((x) => x.provider !== 'fs-local').map((x) => this.FileSystems.get(x.provider).rm(x.path)));
114
+ this.Log.trace(`Sent email with data: ${JSON.stringify(lodash_1.default.pick(email, ['from', 'to', 'cc', 'bcc', 'replyTo', 'subject']))}, SMTP response: ${JSON.stringify(message)}`);
115
+ }
116
+ };
117
+ exports.EmailSenderSmtp = EmailSenderSmtp;
118
+ __decorate([
119
+ (0, log_1.Logger)('email'),
120
+ __metadata("design:type", log_1.Log)
121
+ ], EmailSenderSmtp.prototype, "Log", void 0);
122
+ __decorate([
123
+ (0, di_1.Autoinject)(templates_1.Templates),
124
+ __metadata("design:type", templates_1.Templates)
125
+ ], EmailSenderSmtp.prototype, "Tempates", void 0);
126
+ __decorate([
127
+ (0, configuration_1.AutoinjectService)('fs.providers', fs_1.fs),
128
+ __metadata("design:type", Map)
129
+ ], EmailSenderSmtp.prototype, "FileSystems", void 0);
130
+ __decorate([
131
+ (0, configuration_1.Config)('fs.defaultProvider'),
132
+ __metadata("design:type", String)
133
+ ], EmailSenderSmtp.prototype, "DefaultFileProvider", void 0);
134
+ exports.EmailSenderSmtp = EmailSenderSmtp = __decorate([
135
+ (0, di_1.Injectable)(email_1.EmailSender),
136
+ (0, di_1.PerInstanceCheck)(),
137
+ __metadata("design:paramtypes", [Object])
138
+ ], EmailSenderSmtp);
139
139
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,oDAA6C;AAC7C,oCAAuE;AACvE,sCAA2C;AAC3C,0CAA6E;AAC7E,kDAA+C;AAC/C,uDAAyC;AACzC,oCAAiC;AACjC,oDAAuB;AACvB,0DAAmE;AAI5D,IAAM,eAAe,GAArB,MAAM,eAAgB,SAAQ,mBAAW;IAe9C,YAAmB,OAA+B;QAChD,KAAK,EAAE,CAAC;QADS,YAAO,GAAP,OAAO,CAAwB;IAElD,CAAC;IAEM,KAAK,CAAC,OAAO;QAClB,sEAAsE;QACtE,IAAI,CAAC,WAAW,GAAG,UAAU,CAAC,eAAe,CAC3C,M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AgB,GAAE;;GACN,eAAe,CAgG3B"}
@@ -1,17 +1,17 @@
1
- import { Log } from '@spinajs/log';
2
- import { IEmail, EmailSender, EmailConnectionOptions } from '@spinajs/email';
3
- import { Templates } from '@spinajs/templates';
4
- import * as nodemailer from 'nodemailer';
5
- import { fs } from '@spinajs/fs';
6
- export declare class EmailSenderSmtp extends EmailSender {
7
- Options: EmailConnectionOptions;
8
- protected Log: Log;
9
- protected Tempates: Templates;
10
- protected FileSystems: Map<string, fs>;
11
- protected DefaultFileProvider: string;
12
- protected Transporter: nodemailer.Transporter;
13
- constructor(Options: EmailConnectionOptions);
14
- resolve(): Promise<void>;
15
- send(email: IEmail): Promise<void>;
16
- }
1
+ import { Log } from '@spinajs/log';
2
+ import { IEmail, EmailSender, EmailConnectionOptions } from '@spinajs/email';
3
+ import { Templates } from '@spinajs/templates';
4
+ import * as nodemailer from 'nodemailer';
5
+ import { fs } from '@spinajs/fs';
6
+ export declare class EmailSenderSmtp extends EmailSender {
7
+ Options: EmailConnectionOptions;
8
+ protected Log: Log;
9
+ protected Tempates: Templates;
10
+ protected FileSystems: Map<string, fs>;
11
+ protected DefaultFileProvider: string;
12
+ protected Transporter: nodemailer.Transporter;
13
+ constructor(Options: EmailConnectionOptions);
14
+ resolve(): Promise<void>;
15
+ send(email: IEmail): Promise<void>;
16
+ }
17
17
  //# sourceMappingURL=index.d.ts.map
package/lib/mjs/index.js CHANGED
@@ -1,110 +1,110 @@
1
- var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
- else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
- return c > 3 && r && Object.defineProperty(target, key, r), r;
6
- };
7
- var __metadata = (this && this.__metadata) || function (k, v) {
8
- if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
9
- };
10
- import { IOFail } from '@spinajs/exceptions';
11
- import { Autoinject, Injectable, PerInstanceCheck } from '@spinajs/di';
12
- import { Log, Logger } from '@spinajs/log';
13
- import { EmailSender } from '@spinajs/email';
14
- import { Templates } from '@spinajs/templates';
15
- import * as nodemailer from 'nodemailer';
16
- import { fs } from '@spinajs/fs';
17
- import _ from 'lodash';
18
- import { AutoinjectService, Config } from '@spinajs/configuration';
19
- let EmailSenderSmtp = class EmailSenderSmtp extends EmailSender {
20
- constructor(Options) {
21
- super();
22
- this.Options = Options;
23
- }
24
- async resolve() {
25
- // create reusable transporter object using the default SMTP transport
26
- this.Transporter = nodemailer.createTransport(Object.assign({
27
- host: this.Options.host,
28
- port: this.Options.port,
29
- secure: this.Options.ssl,
30
- auth: {
31
- user: this.Options.user,
32
- pass: this.Options.pass, // generated ethereal password
33
- },
34
- },
35
- // all additional options merged
36
- this.Options.options));
37
- try {
38
- // verify returns Promise<true> so always is true
39
- // we must catch exception
40
- await this.Transporter.verify();
41
- }
42
- catch (err) {
43
- this.Log.error(`Cannot connect to smtp server. Error: ${err.message}, connection: ${this.Options.name}`);
44
- throw new Error(`cannot send smtp emails, verify() failed. Pleas check email smtp configuration for connection ${this.Options.name}`);
45
- }
46
- this.Log.success(`Email smtp connection ${this.Options.name} on host ${this.Options.host} established !`);
47
- }
48
- async send(email) {
49
- const options = {
50
- from: email.from,
51
- to: email.to.join(','),
52
- cc: email.cc ? email.cc.join(',') : null,
53
- bcc: email.bcc ? email.bcc.join(',') : null,
54
- replyTo: email.replyTo,
55
- subject: email.subject,
56
- text: email.text,
57
- html: email.template ? await this.Tempates.render(email.template, email.model, email.lang) : null,
58
- attachments: [],
59
- };
60
- if (email.attachements) {
61
- options.attachments = await Promise.all(email.attachements.map(async (a) => {
62
- // we allow to use multiple file sources, default is local
63
- const provider = this.FileSystems.get(a.provider ?? this.DefaultFileProvider);
64
- if (!provider) {
65
- throw new IOFail(`Filesystem provider for ${a.provider} not registered. Make sure you importer all required fs providers`);
66
- }
67
- // with local filesystem, it just return original path
68
- // other implementations should dodwnload file locally,
69
- // and return temporary path
70
- // we provide path to file, becouse nodemailer
71
- // prefer it when sending bigger files
72
- const file = await provider.download(a.path);
73
- return {
74
- filename: a.name,
75
- path: file,
76
- provider: provider.Name,
77
- };
78
- }));
79
- }
80
- let message = await this.Transporter.sendMail(options);
81
- // delete all downloaded files for attachement
82
- // all non local files are downloaded
83
- // and temporary path is in email attachement path property
84
- await Promise.all(options.attachments.filter((x) => x.provider !== 'fs-local').map((x) => this.FileSystems.get(x.provider).unlink(x.path)));
85
- this.Log.trace(`Sent email with data: ${JSON.stringify(_.pick(email, ['from', 'to', 'cc', 'bcc', 'replyTo', 'subject']))}, SMTP response: ${JSON.stringify(message)}`);
86
- }
87
- };
88
- __decorate([
89
- Logger('email'),
90
- __metadata("design:type", Log)
91
- ], EmailSenderSmtp.prototype, "Log", void 0);
92
- __decorate([
93
- Autoinject(Templates),
94
- __metadata("design:type", Templates)
95
- ], EmailSenderSmtp.prototype, "Tempates", void 0);
96
- __decorate([
97
- AutoinjectService('fs.providers', fs),
98
- __metadata("design:type", Map)
99
- ], EmailSenderSmtp.prototype, "FileSystems", void 0);
100
- __decorate([
101
- Config('fs.defaultProvider'),
102
- __metadata("design:type", String)
103
- ], EmailSenderSmtp.prototype, "DefaultFileProvider", void 0);
104
- EmailSenderSmtp = __decorate([
105
- Injectable(EmailSender),
106
- PerInstanceCheck(),
107
- __metadata("design:paramtypes", [Object])
108
- ], EmailSenderSmtp);
109
- export { EmailSenderSmtp };
1
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
6
+ };
7
+ var __metadata = (this && this.__metadata) || function (k, v) {
8
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
9
+ };
10
+ import { IOFail } from '@spinajs/exceptions';
11
+ import { Autoinject, Injectable, PerInstanceCheck } from '@spinajs/di';
12
+ import { Log, Logger } from '@spinajs/log';
13
+ import { EmailSender } from '@spinajs/email';
14
+ import { Templates } from '@spinajs/templates';
15
+ import * as nodemailer from 'nodemailer';
16
+ import { fs } from '@spinajs/fs';
17
+ import _ from 'lodash';
18
+ import { AutoinjectService, Config } from '@spinajs/configuration';
19
+ let EmailSenderSmtp = class EmailSenderSmtp extends EmailSender {
20
+ constructor(Options) {
21
+ super();
22
+ this.Options = Options;
23
+ }
24
+ async resolve() {
25
+ // create reusable transporter object using the default SMTP transport
26
+ this.Transporter = nodemailer.createTransport(Object.assign({
27
+ host: this.Options.host,
28
+ port: this.Options.port,
29
+ secure: this.Options.ssl,
30
+ auth: {
31
+ user: this.Options.user,
32
+ pass: this.Options.pass, // generated ethereal password
33
+ },
34
+ },
35
+ // all additional options merged
36
+ this.Options.options));
37
+ try {
38
+ // verify returns Promise<true> so always is true
39
+ // we must catch exception
40
+ await this.Transporter.verify();
41
+ }
42
+ catch (err) {
43
+ this.Log.error(`Cannot connect to smtp server. Error: ${err.message}, connection: ${this.Options.name}`);
44
+ throw new Error(`cannot send smtp emails, verify() failed. Pleas check email smtp configuration for connection ${this.Options.name}`);
45
+ }
46
+ this.Log.success(`Email smtp connection ${this.Options.name} on host ${this.Options.host} established !`);
47
+ }
48
+ async send(email) {
49
+ const options = {
50
+ from: email.from,
51
+ to: email.to.join(','),
52
+ cc: email.cc ? email.cc.join(',') : null,
53
+ bcc: email.bcc ? email.bcc.join(',') : null,
54
+ replyTo: email.replyTo,
55
+ subject: email.subject,
56
+ text: email.text,
57
+ html: email.template ? await this.Tempates.render(email.template, email.model, email.lang) : null,
58
+ attachments: [],
59
+ };
60
+ if (email.attachements) {
61
+ options.attachments = await Promise.all(email.attachements.map(async (a) => {
62
+ // we allow to use multiple file sources, default is local
63
+ const provider = this.FileSystems.get(a.provider ?? this.DefaultFileProvider);
64
+ if (!provider) {
65
+ throw new IOFail(`Filesystem provider for ${a.provider} not registered. Make sure you importer all required fs providers`);
66
+ }
67
+ // with local filesystem, it just return original path
68
+ // other implementations should dodwnload file locally,
69
+ // and return temporary path
70
+ // we provide path to file, becouse nodemailer
71
+ // prefer it when sending bigger files
72
+ const file = await provider.download(a.path);
73
+ return {
74
+ filename: a.name,
75
+ path: file,
76
+ provider: provider.Name,
77
+ };
78
+ }));
79
+ }
80
+ let message = await this.Transporter.sendMail(options);
81
+ // delete all downloaded files for attachement
82
+ // all non local files are downloaded
83
+ // and temporary path is in email attachement path property
84
+ await Promise.all(options.attachments.filter((x) => x.provider !== 'fs-local').map((x) => this.FileSystems.get(x.provider).rm(x.path)));
85
+ this.Log.trace(`Sent email with data: ${JSON.stringify(_.pick(email, ['from', 'to', 'cc', 'bcc', 'replyTo', 'subject']))}, SMTP response: ${JSON.stringify(message)}`);
86
+ }
87
+ };
88
+ __decorate([
89
+ Logger('email'),
90
+ __metadata("design:type", Log)
91
+ ], EmailSenderSmtp.prototype, "Log", void 0);
92
+ __decorate([
93
+ Autoinject(Templates),
94
+ __metadata("design:type", Templates)
95
+ ], EmailSenderSmtp.prototype, "Tempates", void 0);
96
+ __decorate([
97
+ AutoinjectService('fs.providers', fs),
98
+ __metadata("design:type", Map)
99
+ ], EmailSenderSmtp.prototype, "FileSystems", void 0);
100
+ __decorate([
101
+ Config('fs.defaultProvider'),
102
+ __metadata("design:type", String)
103
+ ], EmailSenderSmtp.prototype, "DefaultFileProvider", void 0);
104
+ EmailSenderSmtp = __decorate([
105
+ Injectable(EmailSender),
106
+ PerInstanceCheck(),
107
+ __metadata("design:paramtypes", [Object])
108
+ ], EmailSenderSmtp);
109
+ export { EmailSenderSmtp };
110
110
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAC7C,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AACvE,OAAO,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAC3C,OAAO,EAAU,WAAW,EAA0B,MAAM,gBAAgB,CAAC;AAC7E,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAC/C,OAAO,KAAK,UAAU,MAAM,YAAY,CAAC;AACzC,OAAO,EAAE,EAAE,EAAE,MAAM,aAAa,CAAC;AACjC,OAAO,CAAC,MAAM,QAAQ,CAAC;AACvB,OAAO,EAAE,iBAAiB,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAC;AAI5D,IAAM,eAAe,GAArB,MAAM,eAAgB,SAAQ,WAAW;IAe9C,YAAmB,OAA+B;QAChD,KAAK,EAAE,CAAC;QADS,YAAO,GAAP,OAAO,CAAwB;IAElD,CAAC;IAEM,KAAK,CAAC,OAAO;QAClB,sEAAsE;QACtE,IAAI,CAAC,WAAW,GAAG,UAAU,CAAC,eAAe,CAC3C,MAAM,CAAC,MAAM,CACX;YACE,IAAI,EAAE,IAAI,CAAC,OAAO,CAAC,IAAI;YACvB,IAAI,EAAE,IAAI,CAAC,OAAO,CAAC,IAAI;YACvB,MAAM,EAAE,IAAI,CAAC,OAAO,CAAC,GAAG;YACxB,IAAI,EAAE;gBACJ,IAAI,EAAE,IAAI,CAAC,OAAO,CAAC,IAAI;gBACvB,IAAI,EAAE,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE,8BAA8B;aACxD;SACF;QAED,gCAAgC;QAChC,IAA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