@sibiltech/sibil-mail 1.0.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 +3 -0
- package/README.md +2 -0
- package/dist/errors/sibil-mail-error.d.ts +41 -0
- package/dist/errors/sibil-mail-error.d.ts.map +1 -0
- package/dist/errors/sibil-mail-error.js +64 -0
- package/dist/errors/sibil-mail-error.js.map +1 -0
- package/dist/index.d.ts +13 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +35 -0
- package/dist/index.js.map +1 -0
- package/dist/sibil-mail.d.ts +123 -0
- package/dist/sibil-mail.d.ts.map +1 -0
- package/dist/sibil-mail.js +286 -0
- package/dist/sibil-mail.js.map +1 -0
- package/dist/test-connection-simple.d.ts +8 -0
- package/dist/test-connection-simple.d.ts.map +1 -0
- package/dist/test-connection-simple.js +96 -0
- package/dist/test-connection-simple.js.map +1 -0
- package/dist/test-email.d.ts +9 -0
- package/dist/test-email.d.ts.map +1 -0
- package/dist/test-email.js +124 -0
- package/dist/test-email.js.map +1 -0
- package/dist/test-server.d.ts +9 -0
- package/dist/test-server.d.ts.map +1 -0
- package/dist/test-server.js +140 -0
- package/dist/test-server.js.map +1 -0
- package/dist/transport.d.ts +37 -0
- package/dist/transport.d.ts.map +1 -0
- package/dist/transport.js +194 -0
- package/dist/transport.js.map +1 -0
- package/dist/types.d.ts +64 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +8 -0
- package/dist/types.js.map +1 -0
- package/dist/utils/email-validator.d.ts +51 -0
- package/dist/utils/email-validator.d.ts.map +1 -0
- package/dist/utils/email-validator.js +74 -0
- package/dist/utils/email-validator.js.map +1 -0
- package/dist/utils/template-engine.d.ts +51 -0
- package/dist/utils/template-engine.d.ts.map +1 -0
- package/dist/utils/template-engine.js +102 -0
- package/dist/utils/template-engine.js.map +1 -0
- package/package.json +41 -0
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Type Definitions
|
|
3
|
+
*
|
|
4
|
+
* All TypeScript interfaces and types for the email library.
|
|
5
|
+
*/
|
|
6
|
+
import { Transporter } from 'nodemailer';
|
|
7
|
+
/**
|
|
8
|
+
* SMTP Configuration
|
|
9
|
+
* Configuration object for SMTP server connection
|
|
10
|
+
*/
|
|
11
|
+
export interface SmtpConfig {
|
|
12
|
+
host: string;
|
|
13
|
+
port: number;
|
|
14
|
+
secure?: boolean;
|
|
15
|
+
auth: {
|
|
16
|
+
user: string;
|
|
17
|
+
pass: string;
|
|
18
|
+
};
|
|
19
|
+
tls?: {
|
|
20
|
+
rejectUnauthorized?: boolean;
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Email Options
|
|
25
|
+
* Configuration for sending an email
|
|
26
|
+
*/
|
|
27
|
+
export interface EmailOptions {
|
|
28
|
+
from: string;
|
|
29
|
+
to: string | string[];
|
|
30
|
+
subject: string;
|
|
31
|
+
text?: string;
|
|
32
|
+
html?: string;
|
|
33
|
+
cc?: string | string[];
|
|
34
|
+
bcc?: string | string[];
|
|
35
|
+
replyTo?: string;
|
|
36
|
+
attachments?: EmailAttachment[];
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Email Attachment
|
|
40
|
+
* File attachment configuration
|
|
41
|
+
*/
|
|
42
|
+
export interface EmailAttachment {
|
|
43
|
+
filename: string;
|
|
44
|
+
path?: string;
|
|
45
|
+
content?: string | Buffer;
|
|
46
|
+
contentType?: string;
|
|
47
|
+
cid?: string;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Email Result
|
|
51
|
+
* Result of email sending operation
|
|
52
|
+
*/
|
|
53
|
+
export interface EmailResult {
|
|
54
|
+
success: boolean;
|
|
55
|
+
messageId?: string;
|
|
56
|
+
error?: string;
|
|
57
|
+
response?: string;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Transport Factory Function
|
|
61
|
+
* Creates a nodemailer transporter instance
|
|
62
|
+
*/
|
|
63
|
+
export type TransportFactory = (config: SmtpConfig) => Transporter;
|
|
64
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAEzC;;;GAGG;AACH,MAAM,WAAW,UAAU;IACzB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,IAAI,EAAE;QACJ,IAAI,EAAE,MAAM,CAAC;QACb,IAAI,EAAE,MAAM,CAAC;KACd,CAAC;IACF,GAAG,CAAC,EAAE;QACJ,kBAAkB,CAAC,EAAE,OAAO,CAAC;KAC9B,CAAC;CACH;AAED;;;GAGG;AACH,MAAM,WAAW,YAAY;IAC3B,IAAI,EAAE,MAAM,CAAC;IACb,EAAE,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;IACtB,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;IACvB,GAAG,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;IACxB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,WAAW,CAAC,EAAE,eAAe,EAAE,CAAC;CACjC;AAED;;;GAGG;AACH,MAAM,WAAW,eAAe;IAC9B,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IAC1B,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,GAAG,CAAC,EAAE,MAAM,CAAC;CACd;AAED;;;GAGG;AACH,MAAM,WAAW,WAAW;IAC1B,OAAO,EAAE,OAAO,CAAC;IACjB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED;;;GAGG;AACH,MAAM,MAAM,gBAAgB,GAAG,CAAC,MAAM,EAAE,UAAU,KAAK,WAAW,CAAC"}
|
package/dist/types.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":";AAAA;;;;GAIG"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Email Validation Utilities
|
|
3
|
+
*
|
|
4
|
+
* Helper functions for validating email addresses and email-related data.
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Validate Email Address
|
|
8
|
+
*
|
|
9
|
+
* Validates if a string is a valid email address format.
|
|
10
|
+
*
|
|
11
|
+
* @param email - Email address to validate
|
|
12
|
+
* @returns True if email is valid, false otherwise
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* ```typescript
|
|
16
|
+
* isValidEmail('user@example.com'); // true
|
|
17
|
+
* isValidEmail('invalid-email'); // false
|
|
18
|
+
* ```
|
|
19
|
+
*/
|
|
20
|
+
export declare function isValidEmail(email: string): boolean;
|
|
21
|
+
/**
|
|
22
|
+
* Validate Email Addresses
|
|
23
|
+
*
|
|
24
|
+
* Validates an array of email addresses.
|
|
25
|
+
*
|
|
26
|
+
* @param emails - Array of email addresses
|
|
27
|
+
* @returns Object with valid and invalid emails
|
|
28
|
+
*/
|
|
29
|
+
export declare function validateEmails(emails: string[]): {
|
|
30
|
+
valid: string[];
|
|
31
|
+
invalid: string[];
|
|
32
|
+
};
|
|
33
|
+
/**
|
|
34
|
+
* Normalize Email Address
|
|
35
|
+
*
|
|
36
|
+
* Normalizes email address by trimming and converting to lowercase.
|
|
37
|
+
*
|
|
38
|
+
* @param email - Email address to normalize
|
|
39
|
+
* @returns Normalized email address
|
|
40
|
+
*/
|
|
41
|
+
export declare function normalizeEmail(email: string): string;
|
|
42
|
+
/**
|
|
43
|
+
* Extract Domain from Email
|
|
44
|
+
*
|
|
45
|
+
* Extracts the domain part from an email address.
|
|
46
|
+
*
|
|
47
|
+
* @param email - Email address
|
|
48
|
+
* @returns Domain part or null if invalid
|
|
49
|
+
*/
|
|
50
|
+
export declare function extractDomain(email: string): string | null;
|
|
51
|
+
//# sourceMappingURL=email-validator.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"email-validator.d.ts","sourceRoot":"","sources":["../../src/utils/email-validator.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH;;;;;;;;;;;;;GAaG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAGnD;AAED;;;;;;;GAOG;AACH,wBAAgB,cAAc,CAAC,MAAM,EAAE,MAAM,EAAE,GAAG;IAChD,KAAK,EAAE,MAAM,EAAE,CAAC;IAChB,OAAO,EAAE,MAAM,EAAE,CAAC;CACnB,CAaA;AAED;;;;;;;GAOG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAEpD;AAED;;;;;;;GAOG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAG1D"}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Email Validation Utilities
|
|
4
|
+
*
|
|
5
|
+
* Helper functions for validating email addresses and email-related data.
|
|
6
|
+
*/
|
|
7
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
+
exports.isValidEmail = isValidEmail;
|
|
9
|
+
exports.validateEmails = validateEmails;
|
|
10
|
+
exports.normalizeEmail = normalizeEmail;
|
|
11
|
+
exports.extractDomain = extractDomain;
|
|
12
|
+
/**
|
|
13
|
+
* Validate Email Address
|
|
14
|
+
*
|
|
15
|
+
* Validates if a string is a valid email address format.
|
|
16
|
+
*
|
|
17
|
+
* @param email - Email address to validate
|
|
18
|
+
* @returns True if email is valid, false otherwise
|
|
19
|
+
*
|
|
20
|
+
* @example
|
|
21
|
+
* ```typescript
|
|
22
|
+
* isValidEmail('user@example.com'); // true
|
|
23
|
+
* isValidEmail('invalid-email'); // false
|
|
24
|
+
* ```
|
|
25
|
+
*/
|
|
26
|
+
function isValidEmail(email) {
|
|
27
|
+
const emailRegex = /^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/;
|
|
28
|
+
return emailRegex.test(email);
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Validate Email Addresses
|
|
32
|
+
*
|
|
33
|
+
* Validates an array of email addresses.
|
|
34
|
+
*
|
|
35
|
+
* @param emails - Array of email addresses
|
|
36
|
+
* @returns Object with valid and invalid emails
|
|
37
|
+
*/
|
|
38
|
+
function validateEmails(emails) {
|
|
39
|
+
const valid = [];
|
|
40
|
+
const invalid = [];
|
|
41
|
+
emails.forEach((email) => {
|
|
42
|
+
if (isValidEmail(email)) {
|
|
43
|
+
valid.push(email);
|
|
44
|
+
}
|
|
45
|
+
else {
|
|
46
|
+
invalid.push(email);
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
return { valid, invalid };
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Normalize Email Address
|
|
53
|
+
*
|
|
54
|
+
* Normalizes email address by trimming and converting to lowercase.
|
|
55
|
+
*
|
|
56
|
+
* @param email - Email address to normalize
|
|
57
|
+
* @returns Normalized email address
|
|
58
|
+
*/
|
|
59
|
+
function normalizeEmail(email) {
|
|
60
|
+
return email.trim().toLowerCase();
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Extract Domain from Email
|
|
64
|
+
*
|
|
65
|
+
* Extracts the domain part from an email address.
|
|
66
|
+
*
|
|
67
|
+
* @param email - Email address
|
|
68
|
+
* @returns Domain part or null if invalid
|
|
69
|
+
*/
|
|
70
|
+
function extractDomain(email) {
|
|
71
|
+
const match = email.match(/@(.+)$/);
|
|
72
|
+
return match ? match[1] : null;
|
|
73
|
+
}
|
|
74
|
+
//# sourceMappingURL=email-validator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"email-validator.js","sourceRoot":"","sources":["../../src/utils/email-validator.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;AAgBH,oCAGC;AAUD,wCAgBC;AAUD,wCAEC;AAUD,sCAGC;AApED;;;;;;;;;;;;;GAaG;AACH,SAAgB,YAAY,CAAC,KAAa;IACxC,MAAM,UAAU,GAAG,kDAAkD,CAAC;IACtE,OAAO,UAAU,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;AAChC,CAAC;AAED;;;;;;;GAOG;AACH,SAAgB,cAAc,CAAC,MAAgB;IAI7C,MAAM,KAAK,GAAa,EAAE,CAAC;IAC3B,MAAM,OAAO,GAAa,EAAE,CAAC;IAE7B,MAAM,CAAC,OAAO,CAAC,CAAC,KAAK,EAAE,EAAE;QACvB,IAAI,YAAY,CAAC,KAAK,CAAC,EAAE,CAAC;YACxB,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QACpB,CAAC;aAAM,CAAC;YACN,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QACtB,CAAC;IACH,CAAC,CAAC,CAAC;IAEH,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,CAAC;AAC5B,CAAC;AAED;;;;;;;GAOG;AACH,SAAgB,cAAc,CAAC,KAAa;IAC1C,OAAO,KAAK,CAAC,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC;AACpC,CAAC;AAED;;;;;;;GAOG;AACH,SAAgB,aAAa,CAAC,KAAa;IACzC,MAAM,KAAK,GAAG,KAAK,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;IACpC,OAAO,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;AACjC,CAAC"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Template Engine Utilities
|
|
3
|
+
*
|
|
4
|
+
* Simple template engine for email content.
|
|
5
|
+
* Supports variable replacement in email templates.
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* Replace Variables in Template
|
|
9
|
+
*
|
|
10
|
+
* Replaces {{variable}} placeholders with actual values.
|
|
11
|
+
*
|
|
12
|
+
* @param template - Template string with {{variable}} placeholders
|
|
13
|
+
* @param variables - Object with variable values
|
|
14
|
+
* @returns Template with replaced variables
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* ```typescript
|
|
18
|
+
* const template = 'Hello {{name}}, welcome to {{company}}!';
|
|
19
|
+
* const result = replaceVariables(template, {
|
|
20
|
+
* name: 'John',
|
|
21
|
+
* company: 'Sibil'
|
|
22
|
+
* });
|
|
23
|
+
* // Result: 'Hello John, welcome to Sibil!'
|
|
24
|
+
* ```
|
|
25
|
+
*/
|
|
26
|
+
export declare function replaceVariables(template: string, variables: Record<string, string | number | boolean>): string;
|
|
27
|
+
/**
|
|
28
|
+
* Replace Variables in HTML Template
|
|
29
|
+
*
|
|
30
|
+
* Same as replaceVariables but also escapes HTML in values.
|
|
31
|
+
*
|
|
32
|
+
* @param template - HTML template string
|
|
33
|
+
* @param variables - Object with variable values
|
|
34
|
+
* @returns HTML template with replaced variables
|
|
35
|
+
*/
|
|
36
|
+
export declare function replaceVariablesInHtml(template: string, variables: Record<string, string | number | boolean>): string;
|
|
37
|
+
/**
|
|
38
|
+
* Create Email Template
|
|
39
|
+
*
|
|
40
|
+
* Creates a complete email template with header and footer.
|
|
41
|
+
*
|
|
42
|
+
* @param content - Main content
|
|
43
|
+
* @param options - Template options
|
|
44
|
+
* @returns Complete HTML email template
|
|
45
|
+
*/
|
|
46
|
+
export declare function createEmailTemplate(content: string, options?: {
|
|
47
|
+
header?: string;
|
|
48
|
+
footer?: string;
|
|
49
|
+
styles?: string;
|
|
50
|
+
}): string;
|
|
51
|
+
//# sourceMappingURL=template-engine.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"template-engine.d.ts","sourceRoot":"","sources":["../../src/utils/template-engine.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,gBAAgB,CAC9B,QAAQ,EAAE,MAAM,EAChB,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC,GACnD,MAAM,CASR;AAED;;;;;;;;GAQG;AACH,wBAAgB,sBAAsB,CACpC,QAAQ,EAAE,MAAM,EAChB,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC,GACnD,MAAM,CAgBR;AAED;;;;;;;;GAQG;AACH,wBAAgB,mBAAmB,CACjC,OAAO,EAAE,MAAM,EACf,OAAO,CAAC,EAAE;IACR,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB,GACA,MAAM,CA8BR"}
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Template Engine Utilities
|
|
4
|
+
*
|
|
5
|
+
* Simple template engine for email content.
|
|
6
|
+
* Supports variable replacement in email templates.
|
|
7
|
+
*/
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.replaceVariables = replaceVariables;
|
|
10
|
+
exports.replaceVariablesInHtml = replaceVariablesInHtml;
|
|
11
|
+
exports.createEmailTemplate = createEmailTemplate;
|
|
12
|
+
/**
|
|
13
|
+
* Replace Variables in Template
|
|
14
|
+
*
|
|
15
|
+
* Replaces {{variable}} placeholders with actual values.
|
|
16
|
+
*
|
|
17
|
+
* @param template - Template string with {{variable}} placeholders
|
|
18
|
+
* @param variables - Object with variable values
|
|
19
|
+
* @returns Template with replaced variables
|
|
20
|
+
*
|
|
21
|
+
* @example
|
|
22
|
+
* ```typescript
|
|
23
|
+
* const template = 'Hello {{name}}, welcome to {{company}}!';
|
|
24
|
+
* const result = replaceVariables(template, {
|
|
25
|
+
* name: 'John',
|
|
26
|
+
* company: 'Sibil'
|
|
27
|
+
* });
|
|
28
|
+
* // Result: 'Hello John, welcome to Sibil!'
|
|
29
|
+
* ```
|
|
30
|
+
*/
|
|
31
|
+
function replaceVariables(template, variables) {
|
|
32
|
+
let result = template;
|
|
33
|
+
Object.entries(variables).forEach(([key, value]) => {
|
|
34
|
+
const regex = new RegExp(`\\{\\{${key}\\}\\}`, 'g');
|
|
35
|
+
result = result.replace(regex, String(value));
|
|
36
|
+
});
|
|
37
|
+
return result;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Replace Variables in HTML Template
|
|
41
|
+
*
|
|
42
|
+
* Same as replaceVariables but also escapes HTML in values.
|
|
43
|
+
*
|
|
44
|
+
* @param template - HTML template string
|
|
45
|
+
* @param variables - Object with variable values
|
|
46
|
+
* @returns HTML template with replaced variables
|
|
47
|
+
*/
|
|
48
|
+
function replaceVariablesInHtml(template, variables) {
|
|
49
|
+
let result = template;
|
|
50
|
+
Object.entries(variables).forEach(([key, value]) => {
|
|
51
|
+
const regex = new RegExp(`\\{\\{${key}\\}\\}`, 'g');
|
|
52
|
+
// Escape HTML in values
|
|
53
|
+
const escapedValue = String(value)
|
|
54
|
+
.replace(/&/g, '&')
|
|
55
|
+
.replace(/</g, '<')
|
|
56
|
+
.replace(/>/g, '>')
|
|
57
|
+
.replace(/"/g, '"')
|
|
58
|
+
.replace(/'/g, ''');
|
|
59
|
+
result = result.replace(regex, escapedValue);
|
|
60
|
+
});
|
|
61
|
+
return result;
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Create Email Template
|
|
65
|
+
*
|
|
66
|
+
* Creates a complete email template with header and footer.
|
|
67
|
+
*
|
|
68
|
+
* @param content - Main content
|
|
69
|
+
* @param options - Template options
|
|
70
|
+
* @returns Complete HTML email template
|
|
71
|
+
*/
|
|
72
|
+
function createEmailTemplate(content, options) {
|
|
73
|
+
const header = options?.header || '';
|
|
74
|
+
const footer = options?.footer || '';
|
|
75
|
+
const styles = options?.styles || '';
|
|
76
|
+
return `
|
|
77
|
+
<!DOCTYPE html>
|
|
78
|
+
<html>
|
|
79
|
+
<head>
|
|
80
|
+
<meta charset="UTF-8">
|
|
81
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
82
|
+
<style>
|
|
83
|
+
${styles}
|
|
84
|
+
body {
|
|
85
|
+
font-family: Arial, sans-serif;
|
|
86
|
+
line-height: 1.6;
|
|
87
|
+
color: #333;
|
|
88
|
+
max-width: 600px;
|
|
89
|
+
margin: 0 auto;
|
|
90
|
+
padding: 20px;
|
|
91
|
+
}
|
|
92
|
+
</style>
|
|
93
|
+
</head>
|
|
94
|
+
<body>
|
|
95
|
+
${header}
|
|
96
|
+
${content}
|
|
97
|
+
${footer}
|
|
98
|
+
</body>
|
|
99
|
+
</html>
|
|
100
|
+
`.trim();
|
|
101
|
+
}
|
|
102
|
+
//# sourceMappingURL=template-engine.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"template-engine.js","sourceRoot":"","sources":["../../src/utils/template-engine.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;AAqBH,4CAYC;AAWD,wDAmBC;AAWD,kDAqCC;AA7GD;;;;;;;;;;;;;;;;;;GAkBG;AACH,SAAgB,gBAAgB,CAC9B,QAAgB,EAChB,SAAoD;IAEpD,IAAI,MAAM,GAAG,QAAQ,CAAC;IAEtB,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,EAAE,KAAK,CAAC,EAAE,EAAE;QACjD,MAAM,KAAK,GAAG,IAAI,MAAM,CAAC,SAAS,GAAG,QAAQ,EAAE,GAAG,CAAC,CAAC;QACpD,MAAM,GAAG,MAAM,CAAC,OAAO,CAAC,KAAK,EAAE,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC;IAChD,CAAC,CAAC,CAAC;IAEH,OAAO,MAAM,CAAC;AAChB,CAAC;AAED;;;;;;;;GAQG;AACH,SAAgB,sBAAsB,CACpC,QAAgB,EAChB,SAAoD;IAEpD,IAAI,MAAM,GAAG,QAAQ,CAAC;IAEtB,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,EAAE,KAAK,CAAC,EAAE,EAAE;QACjD,MAAM,KAAK,GAAG,IAAI,MAAM,CAAC,SAAS,GAAG,QAAQ,EAAE,GAAG,CAAC,CAAC;QACpD,wBAAwB;QACxB,MAAM,YAAY,GAAG,MAAM,CAAC,KAAK,CAAC;aAC/B,OAAO,CAAC,IAAI,EAAE,OAAO,CAAC;aACtB,OAAO,CAAC,IAAI,EAAE,MAAM,CAAC;aACrB,OAAO,CAAC,IAAI,EAAE,MAAM,CAAC;aACrB,OAAO,CAAC,IAAI,EAAE,QAAQ,CAAC;aACvB,OAAO,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;QAC3B,MAAM,GAAG,MAAM,CAAC,OAAO,CAAC,KAAK,EAAE,YAAY,CAAC,CAAC;IAC/C,CAAC,CAAC,CAAC;IAEH,OAAO,MAAM,CAAC;AAChB,CAAC;AAED;;;;;;;;GAQG;AACH,SAAgB,mBAAmB,CACjC,OAAe,EACf,OAIC;IAED,MAAM,MAAM,GAAG,OAAO,EAAE,MAAM,IAAI,EAAE,CAAC;IACrC,MAAM,MAAM,GAAG,OAAO,EAAE,MAAM,IAAI,EAAE,CAAC;IACrC,MAAM,MAAM,GAAG,OAAO,EAAE,MAAM,IAAI,EAAE,CAAC;IAErC,OAAO;;;;;;;MAOH,MAAM;;;;;;;;;;;;IAYR,MAAM;IACN,OAAO;IACP,MAAM;;;GAGP,CAAC,IAAI,EAAE,CAAC;AACX,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@sibiltech/sibil-mail",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "SMTP Email Sending Library for Sibil Platform",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"types": "dist/index.d.ts",
|
|
7
|
+
"scripts": {
|
|
8
|
+
"build": "tsc",
|
|
9
|
+
"dev": "ts-node src/index.ts",
|
|
10
|
+
"test": "jest",
|
|
11
|
+
"test:email": "ts-node src/test-email.ts",
|
|
12
|
+
"test:server": "ts-node src/test-server.ts",
|
|
13
|
+
"prepublishOnly": "npm run build"
|
|
14
|
+
},
|
|
15
|
+
"keywords": [
|
|
16
|
+
"email",
|
|
17
|
+
"smtp",
|
|
18
|
+
"mail",
|
|
19
|
+
"nodemailer",
|
|
20
|
+
"sibil"
|
|
21
|
+
],
|
|
22
|
+
"author": "sibiltech",
|
|
23
|
+
"license": "UNLICENSED",
|
|
24
|
+
"publishConfig": {
|
|
25
|
+
"access": "restricted"
|
|
26
|
+
},
|
|
27
|
+
"dependencies": {
|
|
28
|
+
"cors": "^2.8.5",
|
|
29
|
+
"express": "^4.18.2",
|
|
30
|
+
"nodemailer": "^8.0.0"
|
|
31
|
+
},
|
|
32
|
+
"devDependencies": {
|
|
33
|
+
"@types/cors": "^2.8.17",
|
|
34
|
+
"@types/express": "^4.17.21",
|
|
35
|
+
"@types/node": "^20.10.0",
|
|
36
|
+
"@types/nodemailer": "^6.4.14",
|
|
37
|
+
"dotenv": "^16.3.1",
|
|
38
|
+
"ts-node": "^10.9.2",
|
|
39
|
+
"typescript": "^5.3.3"
|
|
40
|
+
}
|
|
41
|
+
}
|