mailer-advance 1.0.2 → 1.0.4

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.
Files changed (2) hide show
  1. package/README.md +76 -57
  2. package/package.json +3 -2
package/README.md CHANGED
@@ -1,85 +1,104 @@
1
- # @pranay/mailer-advance
1
+ # mailer-advance
2
2
 
3
- Advanced Node.js email service with dynamic SMTP configuration, multi-database support (MongoDB/PostgreSQL/MySQL), and a built-in UI.
3
+ [![npm version](https://img.shields.io/npm/v/mailer-advance.svg)](https://www.npmjs.com/package/mailer-advance)
4
+ [![license](https://img.shields.io/npm/l/mailer-advance.svg)](https://www.npmjs.com/package/mailer-advance)
4
5
 
5
- ## Features
6
+ An advanced, production-ready Node.js email service with dynamic SMTP configuration, multi-database support (MongoDB, PostgreSQL, MySQL), and a premium built-in UI.
6
7
 
7
- - **Multi-DB Support**: Store SMTP settings in MongoDB, PostgreSQL, or MySQL.
8
- - **Dynamic Configuration**: Change SMTP servers on-the-fly via API or UI.
9
- - **Built-in UI**: Modern, dark-mode interface for sending emails and managing configurations.
10
- - **Secure**: TLS support with explicit control over certificate validation.
11
- - **Attachments**: Full support for file attachments and embedded images.
8
+ ## 🚀 Features
12
9
 
13
- ## Quick Start
10
+ - **Multi-Database Support**: Seamlessly store SMTP configurations in MongoDB, PostgreSQL, or MySQL.
11
+ - **Dynamic SMTP**: Switch SMTP servers at runtime via API or the built-in management UI.
12
+ - **Premium UI**: Modern dark-mode interfaces for sending emails, listing configurations, and editing settings.
13
+ - **STARTTLS & SSL/TLS**: Full control over secure connections and certificate validation.
14
+ - **Rich Emails**: Support for file attachments and embedded images ($cid$ mapping).
15
+ - **Developer Friendly**: Exported as a reusable module for any Express/Node.js application.
16
+ - **Ultra Lightweight**: Optimized package size (~11KB) with zero build overhead.
14
17
 
15
- ### 1. Installation
18
+ ## 📦 Installation
16
19
 
17
20
  ```bash
18
- git clone https://github.com/your-repo/mailer-advance
19
- cd mailer-advance
20
- npm install
21
+ npm install mailer-advance
22
+ ```
23
+
24
+ ## 🛠 Usage
25
+
26
+ ### 1. Integration as a Library (Recommended)
27
+
28
+ Import routes and services directly into your existing Express app:
29
+
30
+ ```javascript
31
+ import express from 'express';
32
+ import { contactRoutes, configRoutes, mailService } from 'mailer-advance';
33
+
34
+ const app = express();
35
+ app.use(express.json());
36
+
37
+ // 1. Mount management routes
38
+ app.use('/api/mail', contactRoutes);
39
+ app.use('/api/config', configRoutes);
40
+
41
+ // 2. Or use the mail service programmatically
42
+ const sendTest = async () => {
43
+ await mailService.sendEmail({
44
+ to: 'recipient@example.com',
45
+ subject: 'Hello World',
46
+ text: 'Sent via mailer-advance'
47
+ });
48
+ };
49
+
50
+ app.listen(3000);
21
51
  ```
22
52
 
23
- ### 2. Environment Setup
53
+ ### 2. Standalone Service
24
54
 
25
- Create a `.env` file in the root:
55
+ If you've cloned the repository, you can run it as a standalone server:
26
56
 
27
57
  ```bash
58
+ npm install
59
+ npm run dev # Starts on http://localhost:3000
60
+ ```
61
+
62
+ ## ⚙️ Configuration
63
+
64
+ The service uses Environment Variables for default settings. Create a `.env` file:
65
+
66
+ ```env
28
67
  PORT=3000
68
+
69
+ # Database Configuration
29
70
  DB_TYPE=mongodb # options: mongodb, postgres, mysql
30
71
  DB_URI=mongodb://localhost:27017/mail_service_db
31
72
 
32
- # Default SMTP (Fallback)
73
+ # Default SMTP Fallback
33
74
  MAIL_HOST=smtp.example.com
34
75
  MAIL_PORT=587
35
76
  MAIL_SECURE=false
36
- MAIL_USER=user@example.com
37
- MAIL_PASS=password
38
- MAIL_FROM_NAME="Service Name"
77
+ MAIL_USER=your-user
78
+ MAIL_PASS=your-password
79
+ MAIL_FROM_NAME="System Name"
39
80
  MAIL_FROM_EMAIL=noreply@example.com
40
81
  ```
41
82
 
42
- ### 3. Run the Service
83
+ ## 🖥 Built-in UI
43
84
 
44
- ```bash
45
- # Development
46
- npm run dev
85
+ When running the service, visit:
86
+ - **`http://localhost:3000/contact.html`**: Send test emails with attachments.
87
+ - **`http://localhost:3000/list-configs.html`**: View and manage saved SMTP profiles.
88
+ - **`http://localhost:3000/config.html`**: Add or edit SMTP configurations.
47
89
 
48
- # Production
49
- npm run build
50
- npm start
51
- ```
90
+ ## 📄 API Reference
52
91
 
53
- ## Usage
54
-
55
- ### 1. Standalone Service
56
- - **Send Email**: `http://localhost:3000/contact.html`
57
- - **List Configs**: `http://localhost:3000/list-configs.html`
58
- - **Add Config**: `http://localhost:3000/config.html`
59
-
60
- ### 2. Integration into your Node.js App
61
- You can use this package as a module in your existing Express application:
62
-
63
- ```javascript
64
- import express from 'express';
65
- import { contactRoutes, configRoutes } from 'mailer-advance';
66
-
67
- const app = express();
68
-
69
- // Mount the mailer routes
70
- app.use('/api/mail', contactRoutes);
71
- app.use('/api/config', configRoutes);
72
-
73
- app.listen(3001);
74
- ```
92
+ ### `POST /api/contact`
93
+ Send an email using standard or dynamic config.
94
+ - **Body**: `name`, `email`, `to`, `message`, `configId` (optional).
95
+ - **Files**: Supports `attachments` (multipart/form-data).
75
96
 
76
- ### API Usage
77
- - `POST /api/contact`: Send email (supports attachments).
78
- - `GET /api/config`: List all SMTP configurations.
79
- - `POST /api/config`: Save/Update SMTP configuration.
97
+ ### `GET /api/config`
98
+ Returns a JSON list of all stored SMTP configurations.
80
99
 
81
- ## Optimization
82
- The package size is optimized to be extremely lightweight (~KBs) by excluding build artifacts and dev-dependencies from the final NPM bundle.
100
+ ### `POST /api/config`
101
+ Save or update an SMTP configuration profile.
83
102
 
84
- ## License
85
- MIT
103
+ ## 📜 License
104
+ MIT © Pranay
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mailer-advance",
3
- "version": "1.0.2",
3
+ "version": "1.0.4",
4
4
  "description": "Advanced Node.js email service with dynamic SMTP configuration, multi-database support (MongoDB/SQL), and a built-in UI.",
5
5
  "main": "src/server.js",
6
6
  "type": "module",
@@ -8,7 +8,8 @@
8
8
  "start": "node src/server.js",
9
9
  "dev": "nodemon --watch .env --watch src src/server.js",
10
10
  "build": "esbuild src/server.js --bundle --platform=node --format=esm --target=node20 --outfile=dist/server.js --external:express --external:nodemailer --external:dotenv --external:cors",
11
- "test": "echo \"Error: no test specified\" && exit 1"
11
+ "test": "echo \"Error: no test specified\" && exit 1",
12
+ "release": "git add . && git commit -m 'chore: release v1.0.4' && git push && npm publish"
12
13
  },
13
14
  "publishConfig": {
14
15
  "access": "public"