@bernierllc/email-sender 0.2.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/LICENSE +7 -0
- package/README.md +430 -0
- package/dist/core/email-sender.d.ts +71 -0
- package/dist/core/email-sender.d.ts.map +1 -0
- package/dist/core/email-sender.js +125 -0
- package/dist/core/email-sender.js.map +1 -0
- package/dist/index.d.ts +14 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +47 -0
- package/dist/index.js.map +1 -0
- package/dist/providers/base.d.ts +63 -0
- package/dist/providers/base.d.ts.map +1 -0
- package/dist/providers/base.js +132 -0
- package/dist/providers/base.js.map +1 -0
- package/dist/providers/mailgun.d.ts +40 -0
- package/dist/providers/mailgun.d.ts.map +1 -0
- package/dist/providers/mailgun.js +525 -0
- package/dist/providers/mailgun.js.map +1 -0
- package/dist/providers/postmark.d.ts +37 -0
- package/dist/providers/postmark.d.ts.map +1 -0
- package/dist/providers/postmark.js +482 -0
- package/dist/providers/postmark.js.map +1 -0
- package/dist/providers/sendgrid.d.ts +80 -0
- package/dist/providers/sendgrid.d.ts.map +1 -0
- package/dist/providers/sendgrid.js +407 -0
- package/dist/providers/sendgrid.js.map +1 -0
- package/dist/providers/ses.d.ts +38 -0
- package/dist/providers/ses.d.ts.map +1 -0
- package/dist/providers/ses.js +404 -0
- package/dist/providers/ses.js.map +1 -0
- package/dist/providers/smtp.d.ts +61 -0
- package/dist/providers/smtp.d.ts.map +1 -0
- package/dist/providers/smtp.js +201 -0
- package/dist/providers/smtp.js.map +1 -0
- package/dist/types/index.d.ts +99 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +10 -0
- package/dist/types/index.js.map +1 -0
- package/package.json +55 -0
package/dist/index.js
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
Copyright (c) 2025 Bernier LLC
|
|
4
|
+
|
|
5
|
+
This file is licensed to the client under a limited-use license.
|
|
6
|
+
The client may use and modify this code *only within the scope of the project it was delivered for*.
|
|
7
|
+
Redistribution or use in other products or commercial offerings is not permitted without written consent from Bernier LLC.
|
|
8
|
+
*/
|
|
9
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
12
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
13
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
14
|
+
}
|
|
15
|
+
Object.defineProperty(o, k2, desc);
|
|
16
|
+
}) : (function(o, m, k, k2) {
|
|
17
|
+
if (k2 === undefined) k2 = k;
|
|
18
|
+
o[k2] = m[k];
|
|
19
|
+
}));
|
|
20
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
21
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
22
|
+
};
|
|
23
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
24
|
+
exports.PostmarkProvider = exports.MailgunProvider = exports.SesProvider = exports.SendGridProvider = exports.SmtpProvider = exports.EmailProvider = exports.EmailSender = void 0;
|
|
25
|
+
/**
|
|
26
|
+
* Email Sender - Core Library
|
|
27
|
+
* Main entry point for the email sending system
|
|
28
|
+
*/
|
|
29
|
+
// Core types
|
|
30
|
+
__exportStar(require("./types"), exports);
|
|
31
|
+
// Core classes
|
|
32
|
+
var email_sender_1 = require("./core/email-sender");
|
|
33
|
+
Object.defineProperty(exports, "EmailSender", { enumerable: true, get: function () { return email_sender_1.EmailSender; } });
|
|
34
|
+
// Provider classes
|
|
35
|
+
var base_1 = require("./providers/base");
|
|
36
|
+
Object.defineProperty(exports, "EmailProvider", { enumerable: true, get: function () { return base_1.EmailProvider; } });
|
|
37
|
+
var smtp_1 = require("./providers/smtp");
|
|
38
|
+
Object.defineProperty(exports, "SmtpProvider", { enumerable: true, get: function () { return smtp_1.SmtpProvider; } });
|
|
39
|
+
var sendgrid_1 = require("./providers/sendgrid");
|
|
40
|
+
Object.defineProperty(exports, "SendGridProvider", { enumerable: true, get: function () { return sendgrid_1.SendGridProvider; } });
|
|
41
|
+
var ses_1 = require("./providers/ses");
|
|
42
|
+
Object.defineProperty(exports, "SesProvider", { enumerable: true, get: function () { return ses_1.SesProvider; } });
|
|
43
|
+
var mailgun_1 = require("./providers/mailgun");
|
|
44
|
+
Object.defineProperty(exports, "MailgunProvider", { enumerable: true, get: function () { return mailgun_1.MailgunProvider; } });
|
|
45
|
+
var postmark_1 = require("./providers/postmark");
|
|
46
|
+
Object.defineProperty(exports, "PostmarkProvider", { enumerable: true, get: function () { return postmark_1.PostmarkProvider; } });
|
|
47
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;;;;;EAME;;;;;;;;;;;;;;;;;AAEF;;;GAGG;AAEH,aAAa;AACb,0CAAwB;AAExB,eAAe;AACf,oDAAkD;AAAzC,2GAAA,WAAW,OAAA;AAEpB,mBAAmB;AACnB,yCAAiD;AAAxC,qGAAA,aAAa,OAAA;AACtB,yCAAgD;AAAvC,oGAAA,YAAY,OAAA;AACrB,iDAAwD;AAA/C,4GAAA,gBAAgB,OAAA;AACzB,uCAA8C;AAArC,kGAAA,WAAW,OAAA;AACpB,+CAAsD;AAA7C,0GAAA,eAAe,OAAA;AACxB,iDAAwD;AAA/C,4GAAA,gBAAgB,OAAA"}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Base EmailProvider abstract class
|
|
3
|
+
*/
|
|
4
|
+
import { EmailMessage, SendResult, DeliveryStatus, WebhookEvent, EmailProviderCapabilities, EmailProviderConfig, EmailValidationResult } from '../types';
|
|
5
|
+
export { EmailMessage, SendResult, DeliveryStatus, WebhookEvent, EmailProviderCapabilities, EmailProviderConfig, EmailValidationResult };
|
|
6
|
+
export declare abstract class EmailProvider {
|
|
7
|
+
protected config: EmailProviderConfig;
|
|
8
|
+
constructor(config: EmailProviderConfig);
|
|
9
|
+
/**
|
|
10
|
+
* Send a single email
|
|
11
|
+
*/
|
|
12
|
+
abstract sendEmail(email: EmailMessage): Promise<SendResult>;
|
|
13
|
+
/**
|
|
14
|
+
* Send multiple emails
|
|
15
|
+
*/
|
|
16
|
+
abstract sendBatch(emails: EmailMessage[]): Promise<SendResult[]>;
|
|
17
|
+
/**
|
|
18
|
+
* Get delivery status for a message
|
|
19
|
+
*/
|
|
20
|
+
abstract getDeliveryStatus(messageId: string): Promise<DeliveryStatus | null>;
|
|
21
|
+
/**
|
|
22
|
+
* Process webhook events from the provider
|
|
23
|
+
*/
|
|
24
|
+
abstract processWebhook(payload: any, signature: string): Promise<WebhookEvent[]>;
|
|
25
|
+
/**
|
|
26
|
+
* Validate provider configuration
|
|
27
|
+
*/
|
|
28
|
+
validateConfiguration(): EmailValidationResult;
|
|
29
|
+
/**
|
|
30
|
+
* Get provider name
|
|
31
|
+
*/
|
|
32
|
+
getProviderName(): string;
|
|
33
|
+
/**
|
|
34
|
+
* Get provider capabilities
|
|
35
|
+
*/
|
|
36
|
+
getCapabilities(): EmailProviderCapabilities;
|
|
37
|
+
/**
|
|
38
|
+
* Create a template in the provider (if supported)
|
|
39
|
+
*/
|
|
40
|
+
createTemplate?(templateData: {
|
|
41
|
+
name: string;
|
|
42
|
+
subject: string;
|
|
43
|
+
htmlContent: string;
|
|
44
|
+
textContent?: string;
|
|
45
|
+
}): Promise<string>;
|
|
46
|
+
/**
|
|
47
|
+
* Send an email using a provider template (if supported)
|
|
48
|
+
*/
|
|
49
|
+
sendTemplateEmail?(templateId: string, toEmail: string, templateData: Record<string, any>, toName?: string): Promise<SendResult>;
|
|
50
|
+
/**
|
|
51
|
+
* Test the provider connection
|
|
52
|
+
*/
|
|
53
|
+
testConnection(): Promise<boolean>;
|
|
54
|
+
/**
|
|
55
|
+
* Validate an email message
|
|
56
|
+
*/
|
|
57
|
+
validateEmailMessage(email: EmailMessage): EmailValidationResult;
|
|
58
|
+
/**
|
|
59
|
+
* Simple email validation
|
|
60
|
+
*/
|
|
61
|
+
protected isValidEmail(email: string): boolean;
|
|
62
|
+
}
|
|
63
|
+
//# sourceMappingURL=base.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"base.d.ts","sourceRoot":"","sources":["../../src/providers/base.ts"],"names":[],"mappings":"AAQA;;GAEG;AAEH,OAAO,EACL,YAAY,EACZ,UAAU,EACV,cAAc,EACd,YAAY,EACZ,yBAAyB,EACzB,mBAAmB,EACnB,qBAAqB,EACtB,MAAM,UAAU,CAAC;AAGlB,OAAO,EACL,YAAY,EACZ,UAAU,EACV,cAAc,EACd,YAAY,EACZ,yBAAyB,EACzB,mBAAmB,EACnB,qBAAqB,EACtB,CAAC;AAEF,8BAAsB,aAAa;IACjC,SAAS,CAAC,MAAM,EAAE,mBAAmB,CAAC;gBAE1B,MAAM,EAAE,mBAAmB;IAIvC;;OAEG;IACH,QAAQ,CAAC,SAAS,CAAC,KAAK,EAAE,YAAY,GAAG,OAAO,CAAC,UAAU,CAAC;IAE5D;;OAEG;IACH,QAAQ,CAAC,SAAS,CAAC,MAAM,EAAE,YAAY,EAAE,GAAG,OAAO,CAAC,UAAU,EAAE,CAAC;IAEjE;;OAEG;IACH,QAAQ,CAAC,iBAAiB,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,cAAc,GAAG,IAAI,CAAC;IAE7E;;OAEG;IACH,QAAQ,CAAC,cAAc,CAAC,OAAO,EAAE,GAAG,EAAE,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,YAAY,EAAE,CAAC;IAEjF;;OAEG;IACH,qBAAqB,IAAI,qBAAqB;IAwC9C;;OAEG;IACH,eAAe,IAAI,MAAM;IAIzB;;OAEG;IACH,eAAe,IAAI,yBAAyB;IAY5C;;OAEG;IACG,cAAc,CAAC,CAAC,YAAY,EAAE;QAClC,IAAI,EAAE,MAAM,CAAC;QACb,OAAO,EAAE,MAAM,CAAC;QAChB,WAAW,EAAE,MAAM,CAAC;QACpB,WAAW,CAAC,EAAE,MAAM,CAAC;KACtB,GAAG,OAAO,CAAC,MAAM,CAAC;IAEnB;;OAEG;IACG,iBAAiB,CAAC,CACtB,UAAU,EAAE,MAAM,EAClB,OAAO,EAAE,MAAM,EACf,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EACjC,MAAM,CAAC,EAAE,MAAM,GACd,OAAO,CAAC,UAAU,CAAC;IAEtB;;OAEG;IACG,cAAc,IAAI,OAAO,CAAC,OAAO,CAAC;IASxC;;OAEG;IACH,oBAAoB,CAAC,KAAK,EAAE,YAAY,GAAG,qBAAqB;IAyChE;;OAEG;IACH,SAAS,CAAC,YAAY,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO;CAI/C"}
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
Copyright (c) 2025 Bernier LLC
|
|
4
|
+
|
|
5
|
+
This file is licensed to the client under a limited-use license.
|
|
6
|
+
The client may use and modify this code *only within the scope of the project it was delivered for*.
|
|
7
|
+
Redistribution or use in other products or commercial offerings is not permitted without written consent from Bernier LLC.
|
|
8
|
+
*/
|
|
9
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
+
exports.EmailProvider = void 0;
|
|
11
|
+
class EmailProvider {
|
|
12
|
+
constructor(config) {
|
|
13
|
+
this.config = config;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Validate provider configuration
|
|
17
|
+
*/
|
|
18
|
+
validateConfiguration() {
|
|
19
|
+
const errors = [];
|
|
20
|
+
const warnings = [];
|
|
21
|
+
// Check required fields
|
|
22
|
+
if (!this.config.fromEmail) {
|
|
23
|
+
errors.push('fromEmail is required');
|
|
24
|
+
}
|
|
25
|
+
if (!this.config.provider) {
|
|
26
|
+
errors.push('provider is required');
|
|
27
|
+
}
|
|
28
|
+
// Provider-specific validation
|
|
29
|
+
switch (this.config.provider) {
|
|
30
|
+
case 'sendgrid':
|
|
31
|
+
case 'ses':
|
|
32
|
+
case 'mailgun':
|
|
33
|
+
case 'postmark':
|
|
34
|
+
if (!this.config.apiKey) {
|
|
35
|
+
errors.push(`${this.config.provider} requires apiKey`);
|
|
36
|
+
}
|
|
37
|
+
break;
|
|
38
|
+
case 'smtp':
|
|
39
|
+
if (!this.config.host) {
|
|
40
|
+
errors.push('SMTP requires host');
|
|
41
|
+
}
|
|
42
|
+
if (!this.config.port) {
|
|
43
|
+
errors.push('SMTP requires port');
|
|
44
|
+
}
|
|
45
|
+
break;
|
|
46
|
+
}
|
|
47
|
+
return {
|
|
48
|
+
isValid: errors.length === 0,
|
|
49
|
+
errors,
|
|
50
|
+
warnings
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Get provider name
|
|
55
|
+
*/
|
|
56
|
+
getProviderName() {
|
|
57
|
+
return this.constructor.name.replace('Provider', '').toLowerCase();
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Get provider capabilities
|
|
61
|
+
*/
|
|
62
|
+
getCapabilities() {
|
|
63
|
+
return {
|
|
64
|
+
supportsBatch: true,
|
|
65
|
+
supportsTemplates: false,
|
|
66
|
+
supportsWebhooks: false,
|
|
67
|
+
supportsAttachments: true,
|
|
68
|
+
supportsDeliveryTracking: false,
|
|
69
|
+
maxBatchSize: 100,
|
|
70
|
+
maxAttachmentSize: 25 * 1024 * 1024 // 25MB
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Test the provider connection
|
|
75
|
+
*/
|
|
76
|
+
async testConnection() {
|
|
77
|
+
try {
|
|
78
|
+
const validation = this.validateConfiguration();
|
|
79
|
+
return validation.isValid;
|
|
80
|
+
}
|
|
81
|
+
catch {
|
|
82
|
+
return false;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Validate an email message
|
|
87
|
+
*/
|
|
88
|
+
validateEmailMessage(email) {
|
|
89
|
+
const errors = [];
|
|
90
|
+
const warnings = [];
|
|
91
|
+
if (!email.toEmail) {
|
|
92
|
+
errors.push('toEmail is required');
|
|
93
|
+
}
|
|
94
|
+
else if (!this.isValidEmail(email.toEmail)) {
|
|
95
|
+
errors.push('toEmail must be a valid email address');
|
|
96
|
+
}
|
|
97
|
+
if (!email.subject) {
|
|
98
|
+
errors.push('subject is required');
|
|
99
|
+
}
|
|
100
|
+
if (!email.htmlContent && !email.textContent) {
|
|
101
|
+
errors.push('Either htmlContent or textContent is required');
|
|
102
|
+
}
|
|
103
|
+
if (email.attachments && email.attachments.length > 0) {
|
|
104
|
+
const capabilities = this.getCapabilities();
|
|
105
|
+
if (!capabilities.supportsAttachments) {
|
|
106
|
+
errors.push('This provider does not support attachments');
|
|
107
|
+
}
|
|
108
|
+
for (const attachment of email.attachments) {
|
|
109
|
+
if (!attachment.filename) {
|
|
110
|
+
errors.push('Attachment filename is required');
|
|
111
|
+
}
|
|
112
|
+
if (!attachment.content) {
|
|
113
|
+
errors.push('Attachment content is required');
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
return {
|
|
118
|
+
isValid: errors.length === 0,
|
|
119
|
+
errors,
|
|
120
|
+
warnings
|
|
121
|
+
};
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* Simple email validation
|
|
125
|
+
*/
|
|
126
|
+
isValidEmail(email) {
|
|
127
|
+
const emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
|
|
128
|
+
return emailRegex.test(email);
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
exports.EmailProvider = EmailProvider;
|
|
132
|
+
//# sourceMappingURL=base.js.map
|
|
@@ -0,0 +1 @@
|
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,EAAE,CAAC;YAC7C,MAAM,CAAC,IAAI,CAAC,+CAA+C,CAAC,CAAC;QAC/D,CAAC;QAED,IAAI,KAAK,CAAC,WAAW,IAAI,KAAK,CAAC,WAAW,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YACtD,MAAM,YAAY,GAAG,IAAI,CAAC,eAAe,EAAE,CAAC;YAC5C,IAAI,CAAC,YAAY,CAAC,mBAAmB,EAAE,CAAC;gBACtC,MAAM,CAAC,IAAI,CAAC,4CAA4C,CAAC,CAAC;YAC5D,CAAC;YAED,KAAK,MAAM,UAAU,IAAI,KAAK,CAAC,WAAW,EAAE,CAAC;gBAC3C,IAAI,CAAC,UAAU,CAAC,QAAQ,EAAE,CAAC;oBACzB,MAAM,CAAC,IAAI,CAAC,iCAAiC,CAAC,CAAC;gBACjD,CAAC;gBACD,IAAI,CAAC,UAAU,CAAC,OAAO,EAAE,CAAC;oBACxB,MAAM,CAAC,IAAI,CAAC,gCAAgC,CAAC,CAAC;gBAChD,CAAC;YACH,CAAC;QACH,CAAC;QAED,OAAO;YACL,OAAO,EAAE,MAAM,CAAC,MAAM,KAAK,CAAC;YAC5B,MAAM;YACN,QAAQ;SACT,CAAC;IACJ,CAAC;IAED;;OAEG;IACO,YAAY,CAAC,KAAa;QAClC,MAAM,UAAU,GAAG,4BAA4B,CAAC;QAChD,OAAO,UAAU,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IAChC,CAAC;CACF;AA/KD,sCA+KC"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Mailgun Email Provider
|
|
3
|
+
* Handles email sending through Mailgun API
|
|
4
|
+
*/
|
|
5
|
+
import { EmailProvider } from './base';
|
|
6
|
+
import type { EmailMessage, SendResult, EmailProviderConfig, EmailProviderCapabilities, EmailValidationResult, EmailTemplate, DeliveryStatus, WebhookEvent } from '../types';
|
|
7
|
+
interface MailgunConfig extends EmailProviderConfig {
|
|
8
|
+
provider: 'mailgun';
|
|
9
|
+
apiKey: string;
|
|
10
|
+
domain: string;
|
|
11
|
+
endpoint?: string;
|
|
12
|
+
region?: 'us' | 'eu';
|
|
13
|
+
}
|
|
14
|
+
export declare class MailgunProvider extends EmailProvider {
|
|
15
|
+
private baseUrl;
|
|
16
|
+
constructor(config: MailgunConfig);
|
|
17
|
+
private buildBaseUrl;
|
|
18
|
+
sendEmail(message: EmailMessage): Promise<SendResult>;
|
|
19
|
+
sendBatch(emails: EmailMessage[]): Promise<SendResult[]>;
|
|
20
|
+
private sendBatchChunk;
|
|
21
|
+
sendTemplateEmail(templateId: string, toEmail: string, variables: Record<string, any>): Promise<SendResult>;
|
|
22
|
+
createTemplate(template: Omit<EmailTemplate, 'id' | 'createdAt' | 'updatedAt'>): Promise<string>;
|
|
23
|
+
updateTemplate(template: EmailTemplate): Promise<void>;
|
|
24
|
+
deleteTemplate(templateId: string): Promise<void>;
|
|
25
|
+
getTemplate(templateId: string): Promise<EmailTemplate | null>;
|
|
26
|
+
listTemplates(): Promise<EmailTemplate[]>;
|
|
27
|
+
getDeliveryStatus(messageId: string): Promise<DeliveryStatus | null>;
|
|
28
|
+
processWebhook(_payload: any, _signature: string): Promise<WebhookEvent[]>;
|
|
29
|
+
testConnection(): Promise<boolean>;
|
|
30
|
+
validateConfiguration(): EmailValidationResult;
|
|
31
|
+
validateEmailMessage(message: EmailMessage): EmailValidationResult;
|
|
32
|
+
getCapabilities(): EmailProviderCapabilities;
|
|
33
|
+
private convertToMailgunMessage;
|
|
34
|
+
private createBatchHtmlTemplate;
|
|
35
|
+
private createBatchTextTemplate;
|
|
36
|
+
private mapMailgunEventToStatus;
|
|
37
|
+
private formatMailgunError;
|
|
38
|
+
}
|
|
39
|
+
export {};
|
|
40
|
+
//# sourceMappingURL=mailgun.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mailgun.d.ts","sourceRoot":"","sources":["../../src/providers/mailgun.ts"],"names":[],"mappings":"AAQA;;;GAGG;AAE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