@appweaver/nodemailer 2.4.1 → 2.6.0
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 +4 -4
- package/smtp-mailer.d.ts +6 -0
- package/smtp-mailer.js +16 -4
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@appweaver/nodemailer",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.6.0",
|
|
4
4
|
"description": "Appweaver - the backend framework for AI-first development (@nodemailer)",
|
|
5
5
|
"author": "Luka Matosevic",
|
|
6
6
|
"license": "MIT",
|
|
@@ -40,11 +40,11 @@
|
|
|
40
40
|
},
|
|
41
41
|
"dependencies": {
|
|
42
42
|
"@sinclair/typebox": "0.34.49",
|
|
43
|
-
"nodemailer": "10.
|
|
43
|
+
"nodemailer": "10.4.1"
|
|
44
44
|
},
|
|
45
45
|
"peerDependencies": {
|
|
46
|
-
"@appweaver/common": "^2.
|
|
47
|
-
"@appweaver/core": "^2.
|
|
46
|
+
"@appweaver/common": "^2.6.0",
|
|
47
|
+
"@appweaver/core": "^2.6.0"
|
|
48
48
|
},
|
|
49
49
|
"devDependencies": {
|
|
50
50
|
"@appweaver/common": "^1.12.2",
|
package/smtp-mailer.d.ts
CHANGED
|
@@ -1,6 +1,12 @@
|
|
|
1
1
|
import { Email, HealthCheckResult, Mailer } from '@appweaver/common';
|
|
2
2
|
export declare class SmtpMailer extends Mailer {
|
|
3
3
|
constructor();
|
|
4
|
+
/**
|
|
5
|
+
* Sends an email through the SMTP server.
|
|
6
|
+
*
|
|
7
|
+
* @throws {MailerError} `MAILER_SEND_FAILED` if the server rejects the email, with its SMTP response code as the
|
|
8
|
+
* `status`, or cannot be reached, `MAILER_SENDER_MISSING` if the email has no sender.
|
|
9
|
+
*/
|
|
4
10
|
sendEmail(data: Email): Promise<boolean>;
|
|
5
11
|
checkHealth(): Promise<HealthCheckResult>;
|
|
6
12
|
}
|
package/smtp-mailer.js
CHANGED
|
@@ -21,11 +21,23 @@ class SmtpMailer extends common_1.Mailer {
|
|
|
21
21
|
}
|
|
22
22
|
});
|
|
23
23
|
}
|
|
24
|
+
/**
|
|
25
|
+
* Sends an email through the SMTP server.
|
|
26
|
+
*
|
|
27
|
+
* @throws {MailerError} `MAILER_SEND_FAILED` if the server rejects the email, with its SMTP response code as the
|
|
28
|
+
* `status`, or cannot be reached, `MAILER_SENDER_MISSING` if the email has no sender.
|
|
29
|
+
*/
|
|
24
30
|
async sendEmail(data) {
|
|
25
31
|
const { providerOptions, ...email } = (0, core_1.completeEmail)(data);
|
|
26
|
-
const info = await this._transporter
|
|
27
|
-
...providerOptions,
|
|
28
|
-
|
|
32
|
+
const info = await this._transporter
|
|
33
|
+
.sendMail({ ...providerOptions, ...email })
|
|
34
|
+
.catch((e) => {
|
|
35
|
+
throw new common_1.MailerError(common_1.ErrorCode.MailerSendFailed, `SMTP ${e.responseCode ? 'server rejected the email' : 'request failed'}: ${(0, common_1.errorMessage)(e)}`, {
|
|
36
|
+
provider: 'smtp',
|
|
37
|
+
subject: email.subject,
|
|
38
|
+
status: e.responseCode,
|
|
39
|
+
providerCode: e.code
|
|
40
|
+
}, { cause: e });
|
|
29
41
|
});
|
|
30
42
|
logger.debug({ messageId: info.messageId, response: info.response }, 'SMTP message accepted');
|
|
31
43
|
return true;
|
|
@@ -36,7 +48,7 @@ class SmtpMailer extends common_1.Mailer {
|
|
|
36
48
|
return { success };
|
|
37
49
|
}
|
|
38
50
|
catch (e) {
|
|
39
|
-
return { success: false, message: e
|
|
51
|
+
return { success: false, message: (0, common_1.errorMessage)(e) };
|
|
40
52
|
}
|
|
41
53
|
}
|
|
42
54
|
}
|