mikromail 0.0.1
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 +99 -0
- package/lib/Configuration.d.mts +41 -0
- package/lib/Configuration.d.ts +41 -0
- package/lib/Configuration.js +153 -0
- package/lib/Configuration.mjs +7 -0
- package/lib/MikroMail.d.mts +30 -0
- package/lib/MikroMail.d.ts +30 -0
- package/lib/MikroMail.js +806 -0
- package/lib/MikroMail.mjs +10 -0
- package/lib/SMTPClient.d.mts +106 -0
- package/lib/SMTPClient.d.ts +106 -0
- package/lib/SMTPClient.js +632 -0
- package/lib/SMTPClient.mjs +7 -0
- package/lib/chunk-47VXJTWV.mjs +13 -0
- package/lib/chunk-TCYL3UFZ.mjs +541 -0
- package/lib/chunk-UDLJWUFN.mjs +83 -0
- package/lib/chunk-V2NYOKWA.mjs +121 -0
- package/lib/chunk-XNGASLEZ.mjs +42 -0
- package/lib/errors/index.d.mts +8 -0
- package/lib/errors/index.d.ts +8 -0
- package/lib/errors/index.js +37 -0
- package/lib/errors/index.mjs +6 -0
- package/lib/index.d.mts +2 -0
- package/lib/index.d.ts +2 -0
- package/lib/index.js +806 -0
- package/lib/index.mjs +10 -0
- package/lib/interfaces/index.d.mts +60 -0
- package/lib/interfaces/index.d.ts +60 -0
- package/lib/interfaces/index.js +18 -0
- package/lib/interfaces/index.mjs +0 -0
- package/lib/utils/index.d.mts +19 -0
- package/lib/utils/index.d.ts +19 -0
- package/lib/utils/index.js +110 -0
- package/lib/utils/index.mjs +12 -0
- package/package.json +56 -0
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import { SMTPConfiguration, EmailOptions, SendResult } from './interfaces/index.mjs';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Enhanced SMTP client for sending emails without dependencies
|
|
5
|
+
* Supports HTML content, improved security and comprehensive error handling
|
|
6
|
+
*/
|
|
7
|
+
declare class SMTPClient {
|
|
8
|
+
private config;
|
|
9
|
+
private socket;
|
|
10
|
+
private connected;
|
|
11
|
+
private lastCommand;
|
|
12
|
+
private serverCapabilities;
|
|
13
|
+
private secureMode;
|
|
14
|
+
private retryCount;
|
|
15
|
+
constructor(config: SMTPConfiguration);
|
|
16
|
+
/**
|
|
17
|
+
* Log debug messages if debug mode is enabled
|
|
18
|
+
*/
|
|
19
|
+
private log;
|
|
20
|
+
/**
|
|
21
|
+
* Connect to the SMTP server
|
|
22
|
+
*/
|
|
23
|
+
connect(): Promise<void>;
|
|
24
|
+
/**
|
|
25
|
+
* Create a secure TLS connection
|
|
26
|
+
*/
|
|
27
|
+
private createTLSConnection;
|
|
28
|
+
/**
|
|
29
|
+
* Create a plain socket connection (for later STARTTLS upgrade)
|
|
30
|
+
*/
|
|
31
|
+
private createPlainConnection;
|
|
32
|
+
/**
|
|
33
|
+
* Set up common socket event handlers
|
|
34
|
+
*/
|
|
35
|
+
private setupSocketEventHandlers;
|
|
36
|
+
/**
|
|
37
|
+
* Upgrade connection to TLS using STARTTLS
|
|
38
|
+
*/
|
|
39
|
+
private upgradeToTLS;
|
|
40
|
+
/**
|
|
41
|
+
* Send an SMTP command and await response
|
|
42
|
+
*/
|
|
43
|
+
sendCommand(command: string, expectedCode: number, timeout?: number): Promise<string>;
|
|
44
|
+
/**
|
|
45
|
+
* Parse EHLO response to determine server capabilities
|
|
46
|
+
*/
|
|
47
|
+
private parseCapabilities;
|
|
48
|
+
/**
|
|
49
|
+
* Determine the best authentication method supported by the server
|
|
50
|
+
*/
|
|
51
|
+
private getBestAuthMethod;
|
|
52
|
+
/**
|
|
53
|
+
* Authenticate with the SMTP server using the best available method
|
|
54
|
+
*/
|
|
55
|
+
private authenticate;
|
|
56
|
+
/**
|
|
57
|
+
* Authenticate using PLAIN method
|
|
58
|
+
*/
|
|
59
|
+
private authenticatePlain;
|
|
60
|
+
/**
|
|
61
|
+
* Authenticate using LOGIN method
|
|
62
|
+
*/
|
|
63
|
+
private authenticateLogin;
|
|
64
|
+
/**
|
|
65
|
+
* Authenticate using CRAM-MD5 method
|
|
66
|
+
*/
|
|
67
|
+
private authenticateCramMD5;
|
|
68
|
+
/**
|
|
69
|
+
* Generate a unique message ID
|
|
70
|
+
*/
|
|
71
|
+
private generateMessageId;
|
|
72
|
+
/**
|
|
73
|
+
* Generate MIME boundary for multipart messages
|
|
74
|
+
*/
|
|
75
|
+
private generateBoundary;
|
|
76
|
+
/**
|
|
77
|
+
* Encode string according to RFC 2047 for headers with non-ASCII characters
|
|
78
|
+
*/
|
|
79
|
+
private encodeHeaderValue;
|
|
80
|
+
/**
|
|
81
|
+
* Sanitize and encode header value to prevent injection and handle internationalization
|
|
82
|
+
*/
|
|
83
|
+
private sanitizeHeader;
|
|
84
|
+
/**
|
|
85
|
+
* Create email headers with proper sanitization
|
|
86
|
+
*/
|
|
87
|
+
private createEmailHeaders;
|
|
88
|
+
/**
|
|
89
|
+
* Create a multipart email with text and HTML parts
|
|
90
|
+
*/
|
|
91
|
+
private createMultipartEmail;
|
|
92
|
+
/**
|
|
93
|
+
* Perform full SMTP handshake, including STARTTLS if needed
|
|
94
|
+
*/
|
|
95
|
+
private smtpHandshake;
|
|
96
|
+
/**
|
|
97
|
+
* Send an email with retry capability
|
|
98
|
+
*/
|
|
99
|
+
sendEmail(options: EmailOptions): Promise<SendResult>;
|
|
100
|
+
/**
|
|
101
|
+
* Close the connection gracefully
|
|
102
|
+
*/
|
|
103
|
+
close(): Promise<void>;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
export { SMTPClient };
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import { SMTPConfiguration, EmailOptions, SendResult } from './interfaces/index.js';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Enhanced SMTP client for sending emails without dependencies
|
|
5
|
+
* Supports HTML content, improved security and comprehensive error handling
|
|
6
|
+
*/
|
|
7
|
+
declare class SMTPClient {
|
|
8
|
+
private config;
|
|
9
|
+
private socket;
|
|
10
|
+
private connected;
|
|
11
|
+
private lastCommand;
|
|
12
|
+
private serverCapabilities;
|
|
13
|
+
private secureMode;
|
|
14
|
+
private retryCount;
|
|
15
|
+
constructor(config: SMTPConfiguration);
|
|
16
|
+
/**
|
|
17
|
+
* Log debug messages if debug mode is enabled
|
|
18
|
+
*/
|
|
19
|
+
private log;
|
|
20
|
+
/**
|
|
21
|
+
* Connect to the SMTP server
|
|
22
|
+
*/
|
|
23
|
+
connect(): Promise<void>;
|
|
24
|
+
/**
|
|
25
|
+
* Create a secure TLS connection
|
|
26
|
+
*/
|
|
27
|
+
private createTLSConnection;
|
|
28
|
+
/**
|
|
29
|
+
* Create a plain socket connection (for later STARTTLS upgrade)
|
|
30
|
+
*/
|
|
31
|
+
private createPlainConnection;
|
|
32
|
+
/**
|
|
33
|
+
* Set up common socket event handlers
|
|
34
|
+
*/
|
|
35
|
+
private setupSocketEventHandlers;
|
|
36
|
+
/**
|
|
37
|
+
* Upgrade connection to TLS using STARTTLS
|
|
38
|
+
*/
|
|
39
|
+
private upgradeToTLS;
|
|
40
|
+
/**
|
|
41
|
+
* Send an SMTP command and await response
|
|
42
|
+
*/
|
|
43
|
+
sendCommand(command: string, expectedCode: number, timeout?: number): Promise<string>;
|
|
44
|
+
/**
|
|
45
|
+
* Parse EHLO response to determine server capabilities
|
|
46
|
+
*/
|
|
47
|
+
private parseCapabilities;
|
|
48
|
+
/**
|
|
49
|
+
* Determine the best authentication method supported by the server
|
|
50
|
+
*/
|
|
51
|
+
private getBestAuthMethod;
|
|
52
|
+
/**
|
|
53
|
+
* Authenticate with the SMTP server using the best available method
|
|
54
|
+
*/
|
|
55
|
+
private authenticate;
|
|
56
|
+
/**
|
|
57
|
+
* Authenticate using PLAIN method
|
|
58
|
+
*/
|
|
59
|
+
private authenticatePlain;
|
|
60
|
+
/**
|
|
61
|
+
* Authenticate using LOGIN method
|
|
62
|
+
*/
|
|
63
|
+
private authenticateLogin;
|
|
64
|
+
/**
|
|
65
|
+
* Authenticate using CRAM-MD5 method
|
|
66
|
+
*/
|
|
67
|
+
private authenticateCramMD5;
|
|
68
|
+
/**
|
|
69
|
+
* Generate a unique message ID
|
|
70
|
+
*/
|
|
71
|
+
private generateMessageId;
|
|
72
|
+
/**
|
|
73
|
+
* Generate MIME boundary for multipart messages
|
|
74
|
+
*/
|
|
75
|
+
private generateBoundary;
|
|
76
|
+
/**
|
|
77
|
+
* Encode string according to RFC 2047 for headers with non-ASCII characters
|
|
78
|
+
*/
|
|
79
|
+
private encodeHeaderValue;
|
|
80
|
+
/**
|
|
81
|
+
* Sanitize and encode header value to prevent injection and handle internationalization
|
|
82
|
+
*/
|
|
83
|
+
private sanitizeHeader;
|
|
84
|
+
/**
|
|
85
|
+
* Create email headers with proper sanitization
|
|
86
|
+
*/
|
|
87
|
+
private createEmailHeaders;
|
|
88
|
+
/**
|
|
89
|
+
* Create a multipart email with text and HTML parts
|
|
90
|
+
*/
|
|
91
|
+
private createMultipartEmail;
|
|
92
|
+
/**
|
|
93
|
+
* Perform full SMTP handshake, including STARTTLS if needed
|
|
94
|
+
*/
|
|
95
|
+
private smtpHandshake;
|
|
96
|
+
/**
|
|
97
|
+
* Send an email with retry capability
|
|
98
|
+
*/
|
|
99
|
+
sendEmail(options: EmailOptions): Promise<SendResult>;
|
|
100
|
+
/**
|
|
101
|
+
* Close the connection gracefully
|
|
102
|
+
*/
|
|
103
|
+
close(): Promise<void>;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
export { SMTPClient };
|