quick-mail 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/LICENCE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Chetan Khulage
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,148 @@
1
+ # Quick Mail
2
+
3
+ A simple and quick email sending package for Node.js. Built on top of Nodemailer with sensible defaults for Gmail.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ npm install quick-mail
9
+ ```
10
+
11
+ ## Quick Start
12
+
13
+ ```typescript
14
+ import { QuickMail } from "quick-mail";
15
+
16
+ // Initialize with your Gmail credentials
17
+ QuickMail.init({
18
+ email: "your-email@gmail.com",
19
+ password: "your-gmail-app-password",
20
+ });
21
+
22
+ // Send an email
23
+ const result = await QuickMail.send({
24
+ to: "recipient@example.com",
25
+ subject: "Hello from QuickMail!",
26
+ html: "<h1>Welcome!</h1><p>This is a test email.</p>",
27
+ });
28
+
29
+ if (result.success) {
30
+ console.log("Email sent!", result.messageId);
31
+ } else {
32
+ console.error("Failed:", result.error);
33
+ }
34
+ ```
35
+
36
+ ## Configuration Options
37
+
38
+ ### `QuickMail.init(config)`
39
+
40
+ | Option | Type | Default | Description |
41
+ | ------------ | ------- | ---------------- | ------------------------------------------------------------------ |
42
+ | `email` | string | **required** | Your email address used for sending (SMTP username) |
43
+ | `password` | string | **required** | SMTP password. For Gmail, use App Password from Google Account |
44
+ | `smtpHost` | string | `smtp.gmail.com` | SMTP server hostname |
45
+ | `smtpPort` | number | `587` | SMTP server port (587 for TLS, 465 for SSL) |
46
+ | `smtpSecure` | boolean | auto | Use SSL/TLS connection (auto-detects: false for 587, true for 465) |
47
+ | `senderName` | string | - | Display name shown in recipient's inbox |
48
+
49
+ ### `QuickMail.send(options)`
50
+
51
+ | Option | Type | Required | Description |
52
+ | ------------- | --------------- | -------- | ----------------------------------- |
53
+ | `to` | string \| array | yes | Recipient email(s) |
54
+ | `subject` | string | yes | Email subject |
55
+ | `html` | string | yes\* | HTML content (\*or `text` required) |
56
+ | `text` | string | yes\* | Plain text (\*or `html` required) |
57
+ | `from` | string | - | Sender (defaults to `email`) |
58
+ | `cc` | string \| array | - | CC recipients |
59
+ | `bcc` | string \| array | - | BCC recipients |
60
+ | `replyTo` | string | - | Reply-to address |
61
+ | `attachments` | Attachment[] | - | File attachments |
62
+
63
+ ## Examples
64
+
65
+ ### Basic Email
66
+
67
+ ```typescript
68
+ await QuickMail.send({
69
+ to: "friend@example.com",
70
+ subject: "Hello!",
71
+ html: "<p>How are you?</p>",
72
+ });
73
+ ```
74
+
75
+ ### Multiple Recipients
76
+
77
+ ```typescript
78
+ await QuickMail.send({
79
+ to: ["user1@example.com", "user2@example.com"],
80
+ cc: "manager@example.com",
81
+ subject: "Team Update",
82
+ html: "<p>Here's the weekly update...</p>",
83
+ });
84
+ ```
85
+
86
+ ### With Attachments
87
+
88
+ ```typescript
89
+ await QuickMail.send({
90
+ to: "client@example.com",
91
+ subject: "Invoice",
92
+ html: "<p>Please find the invoice attached.</p>",
93
+ attachments: [
94
+ { filename: "invoice.pdf", path: "./invoice.pdf" },
95
+ { filename: "readme.txt", content: "Hello World!" },
96
+ ],
97
+ });
98
+ ```
99
+
100
+ ### Custom SMTP Server
101
+
102
+ ```typescript
103
+ QuickMail.init({
104
+ email: "your-email@outlook.com",
105
+ password: "your-password",
106
+ smtpHost: "smtp.office365.com",
107
+ smtpPort: 587,
108
+ });
109
+ ```
110
+
111
+ ### With Display Name
112
+
113
+ ```typescript
114
+ QuickMail.init({
115
+ email: "noreply@company.com",
116
+ password: "password",
117
+ senderName: "Company Name",
118
+ });
119
+
120
+ // Emails will show: "Company Name" <noreply@company.com>
121
+ ```
122
+
123
+ ## Utility Methods
124
+
125
+ ```typescript
126
+ // Verify SMTP connection
127
+ const isConnected = await QuickMail.verify();
128
+
129
+ // Check if initialized
130
+ const ready = QuickMail.isInitialized();
131
+
132
+ // Reset/disconnect
133
+ QuickMail.reset();
134
+ ```
135
+
136
+ ## Gmail App Password
137
+
138
+ To use with Gmail, you need an App Password:
139
+
140
+ 1. Go to [Google Account Security](https://myaccount.google.com/security)
141
+ 2. Enable 2-Step Verification
142
+ 3. Go to App Passwords
143
+ 4. Generate a new app password for "Mail"
144
+ 5. Use that 16-character password in the `password` field
145
+
146
+ ## License
147
+
148
+ MIT
@@ -0,0 +1,115 @@
1
+ /**
2
+ * Configuration options for initializing QuickMail
3
+ */
4
+ interface QuickMailConfig {
5
+ /** Your email address used for sending emails (SMTP username) */
6
+ email: string;
7
+ /** SMTP password for authentication. For Gmail, use an App Password generated from Google Account settings */
8
+ password: string;
9
+ /** SMTP server hostname. Default: smtp.gmail.com */
10
+ smtpHost?: string;
11
+ /** SMTP server port. Default: 587 (TLS) */
12
+ smtpPort?: number;
13
+ /** Enable SSL/TLS secure connection. Default: auto-detects (false for port 587, true for port 465) */
14
+ smtpSecure?: boolean;
15
+ /** Display name shown in recipient's inbox. If not provided, only email address is shown */
16
+ senderName?: string;
17
+ }
18
+ /**
19
+ * Options for sending an email
20
+ */
21
+ interface SendMailOptions {
22
+ /** Recipient email address(es). Can be a single email string or array of emails */
23
+ to: string | string[];
24
+ /** Email subject line shown in recipient's inbox */
25
+ subject: string;
26
+ /** HTML formatted email content. Recommended for rich formatting */
27
+ html?: string;
28
+ /** Plain text email content. Used as fallback if HTML is not supported by recipient's email client */
29
+ text?: string;
30
+ /** Sender email address. If not provided, uses the email from init() configuration */
31
+ from?: string;
32
+ /** CC (Carbon Copy) recipients - visible to all recipients */
33
+ cc?: string | string[];
34
+ /** BCC (Blind Carbon Copy) recipients - hidden from other recipients */
35
+ bcc?: string | string[];
36
+ /** Reply-To email address. Responses will be sent to this address instead of the 'from' address */
37
+ replyTo?: string;
38
+ /** File attachments to include in the email */
39
+ attachments?: Attachment[];
40
+ }
41
+ /**
42
+ * Email attachment configuration
43
+ */
44
+ interface Attachment {
45
+ /** Name of the file as it will appear to the recipient */
46
+ filename: string;
47
+ /** Local file path or URL to the file. Example: './document.pdf' or 'https://example.com/file.pdf' */
48
+ path?: string;
49
+ /** Raw file content as string or Buffer. Use this instead of 'path' for in-memory files */
50
+ content?: string | Buffer;
51
+ /** MIME type of the file. Example: 'application/pdf', 'image/png'. Auto-detected if not provided */
52
+ contentType?: string;
53
+ }
54
+ /**
55
+ * Result returned after attempting to send an email
56
+ */
57
+ interface SendMailResult {
58
+ /** Whether the email was sent successfully */
59
+ success: boolean;
60
+ /** Unique message ID assigned by the email server. Only present if success is true */
61
+ messageId?: string;
62
+ /** Error message describing what went wrong. Only present if success is false */
63
+ error?: string;
64
+ }
65
+
66
+ /**
67
+ * QuickMail - Simple and quick email sending package
68
+ */
69
+ declare class QuickMailClass {
70
+ private transporter;
71
+ private config;
72
+ private initialized;
73
+ /**
74
+ * Initialize QuickMail with your SMTP credentials
75
+ * @param config - SMTP configuration options including email and password
76
+ * @example
77
+ * ```ts
78
+ * QuickMail.init({
79
+ * email: 'your-email@gmail.com',
80
+ * password: 'your-app-password'
81
+ * });
82
+ * ```
83
+ */
84
+ init(config: QuickMailConfig): void;
85
+ /**
86
+ * Send an email
87
+ * @param options - Email options
88
+ * @returns Promise with send result
89
+ * @example
90
+ * ```ts
91
+ * const result = await QuickMail.send({
92
+ * to: 'recipient@example.com',
93
+ * subject: 'Hello!',
94
+ * html: '<h1>Welcome!</h1>'
95
+ * });
96
+ * ```
97
+ */
98
+ send(options: SendMailOptions): Promise<SendMailResult>;
99
+ /**
100
+ * Verify the SMTP connection
101
+ * @returns Promise<boolean> - true if connection is valid
102
+ */
103
+ verify(): Promise<boolean>;
104
+ /**
105
+ * Check if QuickMail is initialized
106
+ */
107
+ isInitialized(): boolean;
108
+ /**
109
+ * Reset the QuickMail instance
110
+ */
111
+ reset(): void;
112
+ }
113
+ declare const QuickMail: QuickMailClass;
114
+
115
+ export { type Attachment, QuickMail, type QuickMailConfig, type SendMailOptions, type SendMailResult };
@@ -0,0 +1,115 @@
1
+ /**
2
+ * Configuration options for initializing QuickMail
3
+ */
4
+ interface QuickMailConfig {
5
+ /** Your email address used for sending emails (SMTP username) */
6
+ email: string;
7
+ /** SMTP password for authentication. For Gmail, use an App Password generated from Google Account settings */
8
+ password: string;
9
+ /** SMTP server hostname. Default: smtp.gmail.com */
10
+ smtpHost?: string;
11
+ /** SMTP server port. Default: 587 (TLS) */
12
+ smtpPort?: number;
13
+ /** Enable SSL/TLS secure connection. Default: auto-detects (false for port 587, true for port 465) */
14
+ smtpSecure?: boolean;
15
+ /** Display name shown in recipient's inbox. If not provided, only email address is shown */
16
+ senderName?: string;
17
+ }
18
+ /**
19
+ * Options for sending an email
20
+ */
21
+ interface SendMailOptions {
22
+ /** Recipient email address(es). Can be a single email string or array of emails */
23
+ to: string | string[];
24
+ /** Email subject line shown in recipient's inbox */
25
+ subject: string;
26
+ /** HTML formatted email content. Recommended for rich formatting */
27
+ html?: string;
28
+ /** Plain text email content. Used as fallback if HTML is not supported by recipient's email client */
29
+ text?: string;
30
+ /** Sender email address. If not provided, uses the email from init() configuration */
31
+ from?: string;
32
+ /** CC (Carbon Copy) recipients - visible to all recipients */
33
+ cc?: string | string[];
34
+ /** BCC (Blind Carbon Copy) recipients - hidden from other recipients */
35
+ bcc?: string | string[];
36
+ /** Reply-To email address. Responses will be sent to this address instead of the 'from' address */
37
+ replyTo?: string;
38
+ /** File attachments to include in the email */
39
+ attachments?: Attachment[];
40
+ }
41
+ /**
42
+ * Email attachment configuration
43
+ */
44
+ interface Attachment {
45
+ /** Name of the file as it will appear to the recipient */
46
+ filename: string;
47
+ /** Local file path or URL to the file. Example: './document.pdf' or 'https://example.com/file.pdf' */
48
+ path?: string;
49
+ /** Raw file content as string or Buffer. Use this instead of 'path' for in-memory files */
50
+ content?: string | Buffer;
51
+ /** MIME type of the file. Example: 'application/pdf', 'image/png'. Auto-detected if not provided */
52
+ contentType?: string;
53
+ }
54
+ /**
55
+ * Result returned after attempting to send an email
56
+ */
57
+ interface SendMailResult {
58
+ /** Whether the email was sent successfully */
59
+ success: boolean;
60
+ /** Unique message ID assigned by the email server. Only present if success is true */
61
+ messageId?: string;
62
+ /** Error message describing what went wrong. Only present if success is false */
63
+ error?: string;
64
+ }
65
+
66
+ /**
67
+ * QuickMail - Simple and quick email sending package
68
+ */
69
+ declare class QuickMailClass {
70
+ private transporter;
71
+ private config;
72
+ private initialized;
73
+ /**
74
+ * Initialize QuickMail with your SMTP credentials
75
+ * @param config - SMTP configuration options including email and password
76
+ * @example
77
+ * ```ts
78
+ * QuickMail.init({
79
+ * email: 'your-email@gmail.com',
80
+ * password: 'your-app-password'
81
+ * });
82
+ * ```
83
+ */
84
+ init(config: QuickMailConfig): void;
85
+ /**
86
+ * Send an email
87
+ * @param options - Email options
88
+ * @returns Promise with send result
89
+ * @example
90
+ * ```ts
91
+ * const result = await QuickMail.send({
92
+ * to: 'recipient@example.com',
93
+ * subject: 'Hello!',
94
+ * html: '<h1>Welcome!</h1>'
95
+ * });
96
+ * ```
97
+ */
98
+ send(options: SendMailOptions): Promise<SendMailResult>;
99
+ /**
100
+ * Verify the SMTP connection
101
+ * @returns Promise<boolean> - true if connection is valid
102
+ */
103
+ verify(): Promise<boolean>;
104
+ /**
105
+ * Check if QuickMail is initialized
106
+ */
107
+ isInitialized(): boolean;
108
+ /**
109
+ * Reset the QuickMail instance
110
+ */
111
+ reset(): void;
112
+ }
113
+ declare const QuickMail: QuickMailClass;
114
+
115
+ export { type Attachment, QuickMail, type QuickMailConfig, type SendMailOptions, type SendMailResult };
package/dist/index.js ADDED
@@ -0,0 +1,180 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+
30
+ // src/index.ts
31
+ var index_exports = {};
32
+ __export(index_exports, {
33
+ QuickMail: () => QuickMail
34
+ });
35
+ module.exports = __toCommonJS(index_exports);
36
+
37
+ // src/functions.ts
38
+ var import_nodemailer = __toESM(require("nodemailer"));
39
+ var QuickMailClass = class {
40
+ transporter = null;
41
+ config = null;
42
+ initialized = false;
43
+ /**
44
+ * Initialize QuickMail with your SMTP credentials
45
+ * @param config - SMTP configuration options including email and password
46
+ * @example
47
+ * ```ts
48
+ * QuickMail.init({
49
+ * email: 'your-email@gmail.com',
50
+ * password: 'your-app-password'
51
+ * });
52
+ * ```
53
+ */
54
+ init(config) {
55
+ const {
56
+ email,
57
+ password,
58
+ smtpHost = "smtp.gmail.com",
59
+ smtpPort = 587,
60
+ smtpSecure,
61
+ senderName
62
+ } = config;
63
+ if (!email || !password) {
64
+ throw new Error("QuickMail: email and password are required");
65
+ }
66
+ const isSecure = smtpSecure ?? smtpPort === 465;
67
+ this.config = {
68
+ email,
69
+ password,
70
+ smtpHost,
71
+ smtpPort,
72
+ smtpSecure: isSecure,
73
+ senderName
74
+ };
75
+ this.transporter = import_nodemailer.default.createTransport({
76
+ host: smtpHost,
77
+ port: smtpPort,
78
+ secure: isSecure,
79
+ auth: {
80
+ user: email,
81
+ pass: password
82
+ }
83
+ });
84
+ this.initialized = true;
85
+ }
86
+ /**
87
+ * Send an email
88
+ * @param options - Email options
89
+ * @returns Promise with send result
90
+ * @example
91
+ * ```ts
92
+ * const result = await QuickMail.send({
93
+ * to: 'recipient@example.com',
94
+ * subject: 'Hello!',
95
+ * html: '<h1>Welcome!</h1>'
96
+ * });
97
+ * ```
98
+ */
99
+ async send(options) {
100
+ if (!this.initialized || !this.transporter || !this.config) {
101
+ throw new Error(
102
+ "QuickMail: Not initialized. Call QuickMail.init() first."
103
+ );
104
+ }
105
+ const { to, subject, html, text, from, cc, bcc, replyTo, attachments } = options;
106
+ if (!to) {
107
+ throw new Error("QuickMail: 'to' is required");
108
+ }
109
+ if (!subject) {
110
+ throw new Error("QuickMail: 'subject' is required");
111
+ }
112
+ if (!html && !text) {
113
+ throw new Error("QuickMail: Either 'html' or 'text' is required");
114
+ }
115
+ const fromAddress = from || this.config.email;
116
+ const fromField = this.config.senderName ? `"${this.config.senderName}" <${fromAddress}>` : fromAddress;
117
+ try {
118
+ const info = await this.transporter.sendMail({
119
+ from: fromField,
120
+ to: Array.isArray(to) ? to.join(", ") : to,
121
+ cc: cc ? Array.isArray(cc) ? cc.join(", ") : cc : void 0,
122
+ bcc: bcc ? Array.isArray(bcc) ? bcc.join(", ") : bcc : void 0,
123
+ replyTo,
124
+ subject,
125
+ html: html || void 0,
126
+ text: text || void 0,
127
+ attachments
128
+ });
129
+ return {
130
+ success: true,
131
+ messageId: info.messageId
132
+ };
133
+ } catch (error) {
134
+ const errorMessage = error instanceof Error ? error.message : "Unknown error occurred";
135
+ return {
136
+ success: false,
137
+ error: errorMessage
138
+ };
139
+ }
140
+ }
141
+ /**
142
+ * Verify the SMTP connection
143
+ * @returns Promise<boolean> - true if connection is valid
144
+ */
145
+ async verify() {
146
+ if (!this.initialized || !this.transporter) {
147
+ throw new Error(
148
+ "QuickMail: Not initialized. Call QuickMail.init() first."
149
+ );
150
+ }
151
+ try {
152
+ await this.transporter.verify();
153
+ return true;
154
+ } catch {
155
+ return false;
156
+ }
157
+ }
158
+ /**
159
+ * Check if QuickMail is initialized
160
+ */
161
+ isInitialized() {
162
+ return this.initialized;
163
+ }
164
+ /**
165
+ * Reset the QuickMail instance
166
+ */
167
+ reset() {
168
+ if (this.transporter) {
169
+ this.transporter.close();
170
+ }
171
+ this.transporter = null;
172
+ this.config = null;
173
+ this.initialized = false;
174
+ }
175
+ };
176
+ var QuickMail = new QuickMailClass();
177
+ // Annotate the CommonJS export names for ESM import in node:
178
+ 0 && (module.exports = {
179
+ QuickMail
180
+ });
package/dist/index.mjs ADDED
@@ -0,0 +1,143 @@
1
+ // src/functions.ts
2
+ import nodemailer from "nodemailer";
3
+ var QuickMailClass = class {
4
+ transporter = null;
5
+ config = null;
6
+ initialized = false;
7
+ /**
8
+ * Initialize QuickMail with your SMTP credentials
9
+ * @param config - SMTP configuration options including email and password
10
+ * @example
11
+ * ```ts
12
+ * QuickMail.init({
13
+ * email: 'your-email@gmail.com',
14
+ * password: 'your-app-password'
15
+ * });
16
+ * ```
17
+ */
18
+ init(config) {
19
+ const {
20
+ email,
21
+ password,
22
+ smtpHost = "smtp.gmail.com",
23
+ smtpPort = 587,
24
+ smtpSecure,
25
+ senderName
26
+ } = config;
27
+ if (!email || !password) {
28
+ throw new Error("QuickMail: email and password are required");
29
+ }
30
+ const isSecure = smtpSecure ?? smtpPort === 465;
31
+ this.config = {
32
+ email,
33
+ password,
34
+ smtpHost,
35
+ smtpPort,
36
+ smtpSecure: isSecure,
37
+ senderName
38
+ };
39
+ this.transporter = nodemailer.createTransport({
40
+ host: smtpHost,
41
+ port: smtpPort,
42
+ secure: isSecure,
43
+ auth: {
44
+ user: email,
45
+ pass: password
46
+ }
47
+ });
48
+ this.initialized = true;
49
+ }
50
+ /**
51
+ * Send an email
52
+ * @param options - Email options
53
+ * @returns Promise with send result
54
+ * @example
55
+ * ```ts
56
+ * const result = await QuickMail.send({
57
+ * to: 'recipient@example.com',
58
+ * subject: 'Hello!',
59
+ * html: '<h1>Welcome!</h1>'
60
+ * });
61
+ * ```
62
+ */
63
+ async send(options) {
64
+ if (!this.initialized || !this.transporter || !this.config) {
65
+ throw new Error(
66
+ "QuickMail: Not initialized. Call QuickMail.init() first."
67
+ );
68
+ }
69
+ const { to, subject, html, text, from, cc, bcc, replyTo, attachments } = options;
70
+ if (!to) {
71
+ throw new Error("QuickMail: 'to' is required");
72
+ }
73
+ if (!subject) {
74
+ throw new Error("QuickMail: 'subject' is required");
75
+ }
76
+ if (!html && !text) {
77
+ throw new Error("QuickMail: Either 'html' or 'text' is required");
78
+ }
79
+ const fromAddress = from || this.config.email;
80
+ const fromField = this.config.senderName ? `"${this.config.senderName}" <${fromAddress}>` : fromAddress;
81
+ try {
82
+ const info = await this.transporter.sendMail({
83
+ from: fromField,
84
+ to: Array.isArray(to) ? to.join(", ") : to,
85
+ cc: cc ? Array.isArray(cc) ? cc.join(", ") : cc : void 0,
86
+ bcc: bcc ? Array.isArray(bcc) ? bcc.join(", ") : bcc : void 0,
87
+ replyTo,
88
+ subject,
89
+ html: html || void 0,
90
+ text: text || void 0,
91
+ attachments
92
+ });
93
+ return {
94
+ success: true,
95
+ messageId: info.messageId
96
+ };
97
+ } catch (error) {
98
+ const errorMessage = error instanceof Error ? error.message : "Unknown error occurred";
99
+ return {
100
+ success: false,
101
+ error: errorMessage
102
+ };
103
+ }
104
+ }
105
+ /**
106
+ * Verify the SMTP connection
107
+ * @returns Promise<boolean> - true if connection is valid
108
+ */
109
+ async verify() {
110
+ if (!this.initialized || !this.transporter) {
111
+ throw new Error(
112
+ "QuickMail: Not initialized. Call QuickMail.init() first."
113
+ );
114
+ }
115
+ try {
116
+ await this.transporter.verify();
117
+ return true;
118
+ } catch {
119
+ return false;
120
+ }
121
+ }
122
+ /**
123
+ * Check if QuickMail is initialized
124
+ */
125
+ isInitialized() {
126
+ return this.initialized;
127
+ }
128
+ /**
129
+ * Reset the QuickMail instance
130
+ */
131
+ reset() {
132
+ if (this.transporter) {
133
+ this.transporter.close();
134
+ }
135
+ this.transporter = null;
136
+ this.config = null;
137
+ this.initialized = false;
138
+ }
139
+ };
140
+ var QuickMail = new QuickMailClass();
141
+ export {
142
+ QuickMail
143
+ };
package/package.json ADDED
@@ -0,0 +1,36 @@
1
+ {
2
+ "name": "quick-mail",
3
+ "version": "0.0.1",
4
+ "description": "quick mail sending package",
5
+ "keywords": [
6
+ "mail",
7
+ "gmail",
8
+ "quick"
9
+ ],
10
+ "homepage": "https://github.com/Chetan-KK/quick-mail#readme",
11
+ "bugs": {
12
+ "url": "https://github.com/Chetan-KK/quick-mail/issues"
13
+ },
14
+ "repository": {
15
+ "type": "git",
16
+ "url": "git+https://github.com/Chetan-KK/quick-mail.git"
17
+ },
18
+ "license": "MIT",
19
+ "author": "Chetan-KK",
20
+ "type": "commonjs",
21
+ "main": "./dist/index.js",
22
+ "module": "./dist/index.mjs",
23
+ "types": "./dist/index.d.ts",
24
+ "scripts": {
25
+ "build": "tsup",
26
+ "test": "echo \"Error: no test specified\" && exit 1"
27
+ },
28
+ "devDependencies": {
29
+ "@types/nodemailer": "^7.0.4",
30
+ "tsup": "^8.5.1",
31
+ "typescript": "^5.9.3"
32
+ },
33
+ "dependencies": {
34
+ "nodemailer": "^7.0.12"
35
+ }
36
+ }