Resolve merge conflict in .gitignore

This commit is contained in:
2025-12-27 17:13:52 +11:00
12 changed files with 7087 additions and 618 deletions

54
.github/workflows/build-desktop.yml vendored Normal file
View File

@@ -0,0 +1,54 @@
name: Build Desktop App
on:
push:
branches: [ main ]
tags:
- 'v*'
pull_request:
branches: [ main ]
workflow_dispatch:
jobs:
build-windows:
runs-on: windows-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
cache: 'npm'
- name: Install dependencies
run: npm ci
- name: Build with electron-packager
run: npm run package
- name: Verfiy Build
run: ls dist
- name: Create ZIP archive
run: Compress-Archive -Path "dist\*-win32-x64" -DestinationPath "Advanced-SMTP-Tester-Windows.zip"
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: windows-desktop-app
path: Advanced-SMTP-Tester-Windows.zip
retention-days: 30
- name: Create Release (on tag)
if: startsWith(github.ref, 'refs/tags/v')
uses: softprops/action-gh-release@v1
with:
files: Advanced-SMTP-Tester-Windows.zip
draft: false
prerelease: false
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

4
.gitignore vendored
View File

@@ -1,5 +1,9 @@
node_modules
dist
.DS_Store
*.log
.env
deploy-secrets.json
config/secrets.env
scripts/auth.json
*.zip

481
README.md
View File

@@ -1,421 +1,124 @@
# Advanced SMTP Tester
![Advanced SMTP Tester Banner](docs/readme_banner.png)
A powerful desktop application for testing SMTP configurations with support for multiple providers, dark mode, test history, and enhanced error messages..
[![License: GPL v3](https://img.shields.io/badge/License-GPLv3-blue.svg)](https://www.gnu.org/licenses/gpl-3.0)
[![Node.js](https://img.shields.io/badge/node-%3E%3D14.0.0-brightgreen)](https://nodejs.org/)
[![GitHub](https://img.shields.io/badge/GitHub-DeNNiiInc%2FAdvanced--Smtp--Tester-181717?logo=github)](https://github.com/DeNNiiInc/Advanced-Smtp-Tester)
## Features
A professional, feature-rich SMTP testing utility with a modern web interface. Test your email server configurations, troubleshoot delivery issues, and discover optimal SMTP settings automatically.
### 🎨 User Interface
- **Dark/Light Mode** - Toggle between themes with persistence
- **Configuration Presets** - Quick-load for Office 365, Gmail, SendGrid, Mailgun, Amazon SES
- **Test History** - Last 50 tests with click-to-load
- **Enhanced Errors** - Helpful troubleshooting tips for common issues
---
### 🖥️ Desktop Application
- **Native Windows App** - Runs in its own window (no browser needed)
- **System Tray** - Minimize to tray, quick access
- **Menu Bar** - Full application menu
- **Auto-Start Server** - Express server starts automatically
## 📋 Table of Contents
### 📧 SMTP Testing
- **Multiple Encryption** - STARTTLS, SSL/TLS, Unencrypted
- **Auto-Discovery** - Test multiple port/encryption combinations
- **Beautiful Emails** - Professional HTML test emails
- **Detailed Results** - Full response logs and error messages
- [Features](#-features)
- [Screenshots](#-screenshots)
- [Installation](#-installation)
- [Usage](#-usage)
- [Configuration Examples](#-configuration-examples)
- [API Endpoints](#-api-endpoints)
- [Security Notes](#-security-notes)
- [Troubleshooting](#-troubleshooting)
- [Contributing](#-contributing)
- [License](#-license)
## Installation
---
### Desktop App (Windows)
1. Download the latest release from [Releases](https://github.com/DeNNiiInc/Advanced-Smtp-Tester/releases)
2. Extract the ZIP file
3. Run `Advanced-SMTP-Tester.exe`
## ✨ Features
### Web Version
```bash
npm install
npm start
```
Open `http://localhost:3000` in your browser.
### 🔐 Comprehensive SMTP Support
- **Multiple Encryption Methods**: STARTTLS, SSL/TLS, and unencrypted connections
- **Common Ports**: Pre-configured support for ports 587, 465, 25, and 2525
- **Custom Configurations**: Flexible settings for any SMTP server
### Electron Development
```bash
npm install
npm run electron
```
### 🔍 Auto-Discovery Testing
- Automatically tests multiple SMTP configurations
- Intelligently tries common port and encryption combinations
- Reports all successful configurations
- Sends test emails for each working setup
## Building from Source
### 📧 Email Testing
- Sends styled HTML test emails
- Includes configuration details in email body
- Password included for verification (configurable)
- From/To address customization
### Web Version
```bash
npm install
npm start
```
### 🎨 Modern User Interface
- Clean, intuitive design
- Responsive layout for all devices
- Real-time status updates
- Animated background effects
- Dark theme optimized for extended use
### Desktop App
```bash
npm install
npm run build
```
### 🛡️ Security Features
- Password visibility toggle
- Secure encryption options
- Warning notifications for sensitive data
- No credential storage
Or use electron-packager:
```bash
npx electron-packager . "Advanced-SMTP-Tester" --platform=win32 --arch=x64 --out=dist --overwrite
```
---
## <20> How It Works
![Workflow Diagram](docs/workflow_diagram.png)
The SMTP testing process is simple and straightforward:
1. **Enter Credentials** - Provide your SMTP server details and authentication
2. **Connect to Server** - Application establishes secure connection to SMTP server
3. **Send Test Email** - Formatted test email is sent through the configured server
4. **View Results** - Detailed success/failure information displayed in real-time
---
## <20>📸 Screenshots
### Main Interface
![SMTP Tester Interface](docs/smtp_tester_interface.png)
*Clean, modern interface for SMTP configuration*
### Form Example
![Filled Form Example](docs/filled_form_example.png)
*Example configuration with Gmail SMTP settings*
---
## 🚀 Installation
### Prerequisites
- **Node.js** (v14.0.0 or higher)
- **npm** (comes with Node.js)
## Usage
### Quick Start
1. Select a preset (e.g., "Microsoft Office 365")
2. Enter your credentials
3. Enter recipient email
4. Click "Test Configuration & Send Email"
1. **Clone the repository**
```bash
git clone https://github.com/DeNNiiInc/Advanced-Smtp-Tester.git
cd Advanced-Smtp-Tester
```
### Configuration Presets
- **Office 365**: `smtp.office365.com:587` (STARTTLS)
- **Gmail**: `smtp.gmail.com:587` (STARTTLS)
- **SendGrid**: `smtp.sendgrid.net:587` (STARTTLS)
- **Mailgun**: `smtp.mailgun.org:587` (STARTTLS)
- **Amazon SES**: `email-smtp.us-east-1.amazonaws.com:587` (STARTTLS)
2. **Install dependencies**
```bash
npm install
```
### Auto-Discovery
Click "Auto Discovery Test" to automatically test multiple port/encryption combinations.
3. **Start the server**
```bash
npm start
```
4. **Open in browser**
```
http://localhost:3000
```
The application will be running on port 3000 by default.
---
## 📖 Usage
### Manual Configuration Test
1. **Enter SMTP Server Details**
- **Host**: Your SMTP server address (e.g., `smtp.gmail.com`)
- **Port**: SMTP port number (e.g., `587` for STARTTLS)
- **Encryption**: Choose appropriate encryption method
- STARTTLS (587/25) - Most common for modern servers
- SSL/TLS (465) - Legacy secure connection
- Unencrypted - Not recommended for production
2. **Provide Authentication**
- **Username/Email**: Your email address or username
- **Password**: Account password or app-specific password
3. **Configure Email Details**
- **From Address** (Optional): Defaults to username if not specified
- **To Address**: Recipient email for the test
4. **Run Test**
- Click **"Test Configuration & Send Email"**
- Wait for results (typically 5-15 seconds)
- Check the results panel for success or error messages
### Auto-Discovery Test
For when you're not sure which configuration to use:
1. **Enter Basic Details**
- SMTP Host
- Username/Password
- To Address
2. **Click "🔍 Auto Discovery Test"**
3. **Review Results**
- The tool will test multiple port/encryption combinations
- Successful configurations will send test emails
- All working setups will be reported
---
## 🔧 Configuration Examples
![Quick Reference Card](docs/quick_reference.png)
*Quick reference for popular email providers*
### Gmail
## Development
### Project Structure
```
Host: smtp.gmail.com
Port: 587
Encryption: STARTTLS (587/25)
Username: your-email@gmail.com
Password: your-app-password
Advanced-Smtp-Tester/
├── electron-main.js # Electron entry point
├── server.js # Express server
├── index.html # Main UI
├── public/
│ ├── db.js # IndexedDB wrapper
│ ├── script.js # Frontend logic
│ ├── styles.css # Styling
│ └── Logo.png # App icon
└── .github/
└── workflows/
└── build-desktop.yml # Automated builds
```
> **Note**: Gmail requires [App Passwords](https://support.google.com/accounts/answer/185833) when 2FA is enabled.
### Scripts
- `npm start` - Start web server
- `npm run electron` - Run desktop app
- `npm run build` - Build Windows installer
- `npm run build:dir` - Build unpacked directory
### Outlook/Office 365
## Technologies
```
Host: smtp.office365.com
Port: 587
Encryption: STARTTLS (587/25)
Username: your-email@outlook.com
Password: your-password
```
- **Backend**: Node.js, Express, Nodemailer
- **Frontend**: Vanilla JavaScript, IndexedDB
- **Desktop**: Electron
- **Build**: electron-builder, electron-packager
### Yahoo Mail
## License
```
Host: smtp.mail.yahoo.com
Port: 587
Encryption: STARTTLS (587/25)
Username: your-email@yahoo.com
Password: your-app-password
```
ISC
### Custom SMTP Server
## Author
```
Host: mail.yourdomain.com
Port: 587 (or 465, 25, 2525)
Encryption: Based on your server config
Username: user@yourdomain.com
Password: your-password
```
Beyond Cloud Technology
---
## Links
## 🔌 API Endpoints
### POST `/api/test-smtp`
Test a specific SMTP configuration and send an email.
**Request Body:**
```json
{
"host": "smtp.gmail.com",
"port": 587,
"secure": "false",
"user": "your-email@gmail.com",
"pass": "your-password",
"from": "sender@example.com",
"to": "recipient@example.com"
}
```
**Response:**
```json
{
"success": true,
"message": "Email sent successfully!",
"info": {
"accepted": ["recipient@example.com"],
"messageId": "<message-id>"
}
}
```
### POST `/api/auto-test-smtp`
Automatically test multiple SMTP configurations.
**Request Body:**
```json
{
"host": "smtp.gmail.com",
"user": "your-email@gmail.com",
"pass": "your-password",
"to": "recipient@example.com"
}
```
**Response:**
```json
{
"success": true,
"results": [
{
"port": 587,
"secure": "false",
"status": "success",
"message": "Email sent successfully!"
}
]
}
```
---
## 🔒 Security Notes
> [!WARNING]
> **Password Transmission**
> By default, the test email includes the password used for testing in the email body. This is intentional for verification purposes but should be used carefully.
### Best Practices
1. **Use App-Specific Passwords**
- Don't use your main account password
- Create dedicated app passwords for testing
2. **Avoid Public Networks**
- Don't test on public WiFi
- Use VPN when possible
3. **Delete Test Emails**
- Remove test emails containing passwords
- Clear sent items after testing
4. **Local Hosting Only**
- By default, runs on localhost only
- Do not expose to the internet without proper security
5. **HTTPS in Production**
- Use reverse proxy (nginx, Apache) for HTTPS
- Never send credentials over unencrypted connections
---
## 🐛 Troubleshooting
### Common Issues
#### "Connection timeout" or "ETIMEDOUT"
- **Cause**: Firewall blocking SMTP ports
- **Solution**:
- Check firewall settings
- Try different ports (587, 465, 25)
- Contact your hosting provider
#### "Invalid login" or "Authentication failed"
- **Cause**: Incorrect credentials or security settings
- **Solution**:
- Verify username and password
- Use app-specific passwords
- Enable "Less secure apps" (not recommended)
- Check for 2FA requirements
#### "Self-signed certificate" errors
- **Cause**: Server using self-signed SSL certificate
- **Solution**:
- Try unencrypted connection for testing
- Update to use proper SSL certificates
#### Gmail "Username and Password not accepted"
- **Cause**: Gmail security blocks
- **Solution**:
- Enable 2-Step Verification
- Create App Password
- Use the App Password instead of account password
### Debug Mode
Check the browser console (F12) for detailed error messages. Server logs will show in the terminal where you ran `npm start`.
---
## 🤝 Contributing
Contributions are welcome! Please follow these guidelines:
1. **Fork the repository**
2. **Create a feature branch**
```bash
git checkout -b feature/your-feature-name
```
3. **Commit your changes**
```bash
git commit -m "Add your feature description"
```
4. **Push to your branch**
```bash
git push origin feature/your-feature-name
```
5. **Open a Pull Request**
### Development Setup
```bash
# Install dependencies
npm install
# Start development server
npm start
# The server runs with auto-reload enabled
```
---
## 📄 License
This project is licensed under the **GNU General Public License v3.0**.
```
Advanced SMTP Tester - Professional Email Configuration Testing
Copyright (C) 2025 Beyond Cloud Technology
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
```
See the [LICENSE](LICENSE) file for full details.
---
## 🙏 Acknowledgments
- Built with [Node.js](https://nodejs.org/)
- Email functionality powered by [Nodemailer](https://nodemailer.com/)
- UI inspired by modern web design principles
- Developed by [Beyond Cloud Technology](https://github.com/DeNNiiInc)
---
## 📞 Support
- **Issues**: [GitHub Issues](https://github.com/DeNNiiInc/Advanced-Smtp-Tester/issues)
- **YouTube**: [@beyondcloudtechnology](https://www.youtube.com/@beyondcloudtechnology)
- **GitHub**: [@DeNNiiInc](https://github.com/DeNNiiInc)
---
<div align="center">
**Made with ❤️ by Beyond Cloud Technology**
[⭐ Star this repo](https://github.com/DeNNiiInc/Advanced-Smtp-Tester) | [🐛 Report Bug](https://github.com/DeNNiiInc/Advanced-Smtp-Tester/issues) | [✨ Request Feature](https://github.com/DeNNiiInc/Advanced-Smtp-Tester/issues)
</div>
- [GitHub Repository](https://github.com/DeNNiiInc/Advanced-Smtp-Tester)
- [YouTube Channel](https://www.youtube.com/@beyondcloudtechnology)

44
RELEASE-NOTES.md Normal file
View File

@@ -0,0 +1,44 @@
# Creating GitHub Release
The v1.0.0 tag has been pushed to GitHub. The GitHub Actions workflow will automatically:
1. Build the Windows executable
2. Create a release
3. Upload the built files
## What Happened
**Created ZIP:** `Advanced-SMTP-Tester-v1.0.0-Windows.zip` (137MB)
**Created Tag:** `v1.0.0`
**Pushed Tag:** Tag is now on GitHub
## GitHub Actions Status
The workflow `.github/workflows/build-desktop.yml` will:
- Detect the new tag `v1.0.0`
- Build the Windows app
- Create a GitHub Release
- Upload the installer/portable files
## Check Release Status
Visit: https://github.com/DeNNiiInc/Advanced-Smtp-Tester/releases
The release should appear within a few minutes as GitHub Actions completes the build.
## Manual Upload (If Needed)
If the automated release doesn't work, you can manually create a release:
1. Go to: https://github.com/DeNNiiInc/Advanced-Smtp-Tester/releases/new
2. Select tag: `v1.0.0`
3. Title: `Advanced SMTP Tester v1.0.0`
4. Upload: `Advanced-SMTP-Tester-v1.0.0-Windows.zip`
5. Click "Publish release"
## Local ZIP File
The packaged app is ready at:
`Advanced-SMTP-Tester-v1.0.0-Windows.zip` (137MB)
You can manually upload this to GitHub Releases if needed.

211
electron-main.js Normal file
View File

@@ -0,0 +1,211 @@
const { app, BrowserWindow, Tray, Menu, ipcMain } = require('electron');
const path = require('path');
const express = require('express');
const server = require('./server');
let mainWindow;
let tray;
let isQuitting = false;
// Express server instance (from server.js)
const PORT = process.env.PORT || 3000;
function createWindow() {
mainWindow = new BrowserWindow({
width: 1200,
height: 900,
minWidth: 800,
minHeight: 600,
icon: path.join(__dirname, 'public/Logo.png'),
webPreferences: {
nodeIntegration: false,
contextIsolation: true,
enableRemoteModule: false
},
title: 'Advanced SMTP Tester',
backgroundColor: '#0f172a',
show: false // Don't show until ready
});
// Load the app
mainWindow.loadURL(`http://localhost:${PORT}`);
// Show window when ready
mainWindow.once('ready-to-show', () => {
mainWindow.show();
});
// Handle window close
mainWindow.on('close', (event) => {
if (!isQuitting) {
event.preventDefault();
mainWindow.hide();
return false;
}
});
mainWindow.on('closed', () => {
mainWindow = null;
});
// Create application menu
createMenu();
}
function createTray() {
tray = new Tray(path.join(__dirname, 'public/Logo.png'));
const contextMenu = Menu.buildFromTemplate([
{
label: 'Show App',
click: () => {
mainWindow.show();
}
},
{
label: 'Hide App',
click: () => {
mainWindow.hide();
}
},
{ type: 'separator' },
{
label: 'Quit',
click: () => {
isQuitting = true;
app.quit();
}
}
]);
tray.setToolTip('Advanced SMTP Tester');
tray.setContextMenu(contextMenu);
// Double click to show/hide
tray.on('double-click', () => {
if (mainWindow.isVisible()) {
mainWindow.hide();
} else {
mainWindow.show();
}
});
}
function createMenu() {
const template = [
{
label: 'File',
submenu: [
{
label: 'Minimize to Tray',
accelerator: 'CmdOrCtrl+H',
click: () => {
mainWindow.hide();
}
},
{ type: 'separator' },
{
label: 'Quit',
accelerator: 'CmdOrCtrl+Q',
click: () => {
isQuitting = true;
app.quit();
}
}
]
},
{
label: 'Edit',
submenu: [
{ role: 'undo' },
{ role: 'redo' },
{ type: 'separator' },
{ role: 'cut' },
{ role: 'copy' },
{ role: 'paste' },
{ role: 'selectAll' }
]
},
{
label: 'View',
submenu: [
{ role: 'reload' },
{ role: 'forceReload' },
{ role: 'toggleDevTools' },
{ type: 'separator' },
{ role: 'resetZoom' },
{ role: 'zoomIn' },
{ role: 'zoomOut' },
{ type: 'separator' },
{ role: 'togglefullscreen' }
]
},
{
label: 'Help',
submenu: [
{
label: 'About',
click: async () => {
const { shell } = require('electron');
await shell.openExternal('https://github.com/DeNNiiInc/Advanced-Smtp-Tester');
}
},
{
label: 'Documentation',
click: async () => {
const { shell } = require('electron');
await shell.openExternal('https://github.com/DeNNiiInc/Advanced-Smtp-Tester#readme');
}
}
]
}
];
const menu = Menu.buildFromTemplate(template);
Menu.setApplicationMenu(menu);
}
// Wait for server to be ready before creating window
function waitForServer(callback) {
const http = require('http');
const checkServer = () => {
http.get(`http://localhost:${PORT}`, (res) => {
callback();
}).on('error', () => {
setTimeout(checkServer, 100);
});
};
checkServer();
}
// App lifecycle
app.whenReady().then(() => {
// Server is already started by requiring ./server.js
// Wait for it to be ready
waitForServer(() => {
createWindow();
createTray();
});
app.on('activate', () => {
if (BrowserWindow.getAllWindows().length === 0) {
createWindow();
} else {
mainWindow.show();
}
});
});
app.on('window-all-closed', () => {
// Don't quit on window close, keep running in tray
// User must explicitly quit from tray menu
});
app.on('before-quit', () => {
isQuitting = true;
});
// Handle app quit
app.on('will-quit', () => {
// Cleanup if needed
});

View File

@@ -1,197 +1,177 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta
name="description"
content="Advanced SMTP Tester - Test your SMTP configurations securely and easily."
/>
<title>Advanced SMTP Tester</title>
<link rel="icon" type="image/png" href="public/Logo.png" />
<link rel="stylesheet" href="public/styles.css" />
<!-- Fonts -->
<link rel="preconnect" href="https://fonts.googleapis.com" />
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
<link
href="https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&family=JetBrains+Mono:wght@400;500&display=swap"
rel="stylesheet"
/>
</head>
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta name="description" content="Advanced SMTP Tester - Test your SMTP configurations securely and easily." />
<title>Advanced SMTP Tester</title>
<link rel="icon" type="image/png" href="public/Logo.png" />
<link rel="stylesheet" href="public/styles.css" />
<body>
<div class="background-animation"></div>
<!-- Fonts -->
<link rel="preconnect" href="https://fonts.googleapis.com" />
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
<link
href="https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&family=JetBrains+Mono:wght@400;500&display=swap"
rel="stylesheet" />
</head>
<div class="container">
<!-- Header -->
<header class="header">
<div class="header-content">
<h1 class="title">
<img src="public/Logo.png" alt="Logo" class="title-icon" />
SMTP Tester
</h1>
<p class="subtitle">
Advanced SMTP Configuration & Delivery Testing Utility
</p>
<a
href="https://www.youtube.com/@beyondcloudtechnology"
target="_blank"
rel="noopener noreferrer"
class="youtube-link"
>
<svg class="youtube-icon" viewBox="0 0 24 24" fill="currentColor">
<path
d="M23.498 6.186a3.016 3.016 0 0 0-2.122-2.136C19.505 3.545 12 3.545 12 3.545s-7.505 0-9.377.505A3.017 3.017 0 0 0 .502 6.186C0 8.07 0 12 0 12s0 3.93.502 5.814a3.016 3.016 0 0 0 2.122 2.136c1.871.505 9.376.505 9.376.505s7.505 0 9.377-.505a3.015 3.015 0 0 0 2.122-2.136C24 15.93 24 12 24 12s0-3.93-.502-5.814zM9.545 15.568V8.432L15.818 12l-6.273 3.568z"
/>
</svg>
Watch on YouTube @beyondcloudtechnology
</a>
</div>
</header>
<body>
<!-- Theme Toggle -->
<button class="theme-toggle" id="themeToggle" aria-label="Toggle theme">
🌙
</button>
<!-- Main Content Area -->
<main class="main-content">
<div class="panel">
<div class="panel-header">
<div class="panel-icon">📧</div>
<h2 class="panel-title">Server Configuration</h2>
</div>
<div class="background-animation"></div>
<form id="smtpForm" class="smtp-form">
<div class="form-grid">
<!-- Server Details -->
<div class="form-group">
<label for="host">SMTP Host</label>
<input
type="text"
id="host"
name="host"
placeholder="smtp.example.com"
required
/>
</div>
<div class="form-group">
<label for="port">Port</label>
<input
type="number"
id="port"
name="port"
placeholder="587"
required
/>
</div>
<div class="form-group">
<label for="secure">Encryption</label>
<select id="secure" name="secure">
<option value="false">STARTTLS (587/25)</option>
<option value="true">SSL/TLS (465)</option>
<option value="none">Unencrypted (No TLS)</option>
</select>
</div>
<!-- Auth Details -->
<div class="form-group">
<label for="user">Username / Email</label>
<input
type="text"
id="user"
name="user"
placeholder="user@example.com"
required
/>
</div>
<div class="form-group">
<label for="pass">Password</label>
<div class="password-input-wrapper">
<input
type="password"
id="pass"
name="pass"
placeholder="••••••••"
required
/>
<button
type="button"
class="toggle-password"
onclick="togglePassword()"
>
👁️
</button>
</div>
</div>
<!-- Email Details -->
<div class="form-group">
<label for="from">From Address (Optional)</label>
<input
type="email"
id="from"
name="from"
placeholder="Defaults to Username"
/>
</div>
<div class="form-group">
<label for="to">To Address</label>
<input
type="email"
id="to"
name="to"
placeholder="recipient@example.com"
required
/>
</div>
</div>
<div class="form-actions">
<button type="submit" class="btn btn-primary" id="testBtn">
<span class="btn-text">Test Configuration & Send Email</span>
<div class="loading-spinner hidden"></div>
</button>
<button type="button" class="btn btn-secondary" id="autoTestBtn">
<span class="btn-text">🔍 Auto Discovery Test</span>
<div class="loading-spinner hidden"></div>
</button>
</div>
<!-- Warning for Password Transmission -->
<div class="alert alert-warning">
<span class="alert-icon">⚠️</span>
<p>
<strong>Note:</strong> Per your request, the password used for
this test will be included in the body of the test email.
</p>
</div>
</form>
<!-- Results Section -->
<div id="results" class="results-section hidden">
<h3>Test Results</h3>
<div id="statusMessage" class="status-message"></div>
<pre id="logOutput" class="log-output"></pre>
</div>
</div>
</main>
<!-- Footer -->
<footer class="footer">
<p>&copy; 2025 Beyond Cloud Technology. All rights reserved.</p>
<a
href="https://github.com/DeNNiiInc/Advanced-Smtp-Tester"
target="_blank"
rel="noopener noreferrer"
class="github-link"
>
<svg class="github-icon" viewBox="0 0 24 24" fill="currentColor">
<div class="container">
<!-- Header -->
<header class="header">
<div class="header-content">
<h1 class="title">
<img src="public/Logo.png" alt="Logo" class="title-icon" />
SMTP Tester
</h1>
<p class="subtitle">
Advanced SMTP Configuration & Delivery Testing Utility
</p>
<a href="https://www.youtube.com/@beyondcloudtechnology" target="_blank" rel="noopener noreferrer"
class="youtube-link">
<svg class="youtube-icon" viewBox="0 0 24 24" fill="currentColor">
<path
d="M12 0c-6.626 0-12 5.373-12 12 0 5.302 3.438 9.8 8.207 11.387.599.111.793-.261.793-.577v-2.234c-3.338.726-4.033-1.416-4.033-1.416-.546-1.387-1.333-1.756-1.333-1.756-1.089-.745.083-.729.083-.729 1.205.084 1.839 1.237 1.839 1.237 1.07 1.834 2.807 1.304 3.492.997.107-.775.418-1.305.762-1.604-2.665-.305-5.467-1.334-5.467-5.931 0-1.311.469-2.381 1.236-3.221-.124-.303-.535-1.524.117-3.176 0 0 1.008-.322 3.301 1.23.957-.266 1.983-.399 3.003-.404 1.02.005 2.047.138 3.006.404 2.291-1.552 3.297-1.23 3.297-1.23.653 1.653.242 2.874.118 3.176.77.84 1.235 1.911 1.235 3.221 0 4.609-2.807 5.624-5.479 5.921.43.372.823 1.102.823 2.222v3.293c0 .319.192.694.801.576 4.765-1.589 8.199-6.086 8.199-11.386 0-6.627-5.373-12-12-12z"
/>
d="M23.498 6.186a3.016 3.016 0 0 0-2.122-2.136C19.505 3.545 12 3.545 12 3.545s-7.505 0-9.377.505A3.017 3.017 0 0 0 .502 6.186C0 8.07 0 12 0 12s0 3.93.502 5.814a3.016 3.016 0 0 0 2.122 2.136c1.871.505 9.376.505 9.376.505s7.505 0 9.377-.505a3.015 3.015 0 0 0 2.122-2.136C24 15.93 24 12 24 12s0-3.93-.502-5.814zM9.545 15.568V8.432L15.818 12l-6.273 3.568z" />
</svg>
View on GitHub
Watch on YouTube @beyondcloudtechnology
</a>
</footer>
</div>
</div>
</header>
<script src="public/script.js"></script>
</body>
</html>
<!-- Main Content Area -->
<main class="main-content">
<div class="panel">
<div class="panel-header">
<div class="panel-icon">📧</div>
<h2 class="panel-title">Server Configuration</h2>
</div>
<form id="smtpForm" class="smtp-form">
<!-- Preset Selector -->
<div class="preset-selector">
<label for="presetSelect">⚡ Quick Presets</label>
<select id="presetSelect">
<option value="">Select a preset...</option>
<option value="office365">Microsoft Office 365</option>
<option value="gmail">Google Gmail</option>
<option value="sendgrid">SendGrid</option>
<option value="mailgun">Mailgun</option>
<option value="amazonses">Amazon SES</option>
<option value="custom">💾 Last Used Configuration</option>
</select>
</div>
<div class="form-grid">
<!-- Server Details -->
<div class="form-group">
<label for="host">SMTP Host</label>
<input type="text" id="host" name="host" placeholder="smtp.example.com" required />
</div>
<div class="form-group">
<label for="port">Port</label>
<input type="number" id="port" name="port" placeholder="587" required />
</div>
<div class="form-group">
<label for="secure">Encryption</label>
<select id="secure" name="secure">
<option value="false">STARTTLS (587/25)</option>
<option value="true">SSL/TLS (465)</option>
<option value="none">Unencrypted (No TLS)</option>
</select>
</div>
<!-- Auth Details -->
<div class="form-group">
<label for="user">Username / Email</label>
<input type="text" id="user" name="user" placeholder="user@example.com" required />
</div>
<div class="form-group">
<label for="pass">Password</label>
<div class="password-input-wrapper">
<input type="password" id="pass" name="pass" placeholder="••••••••" required />
<button type="button" class="toggle-password" onclick="togglePassword()">
👁️
</button>
</div>
</div>
<!-- Email Details -->
<div class="form-group">
<label for="from">From Address (Optional)</label>
<input type="email" id="from" name="from" placeholder="Defaults to Username" />
</div>
<div class="form-group">
<label for="to">To Address</label>
<input type="email" id="to" name="to" placeholder="recipient@example.com" required />
</div>
</div>
<div class="form-actions">
<button type="submit" class="btn btn-primary" id="testBtn">
<span class="btn-text">Test Configuration & Send Email</span>
<div class="loading-spinner hidden"></div>
</button>
<button type="button" class="btn btn-secondary" id="autoTestBtn">
<span class="btn-text">🔍 Auto Discovery Test</span>
<div class="loading-spinner hidden"></div>
</button>
</div>
<!-- Warning for Password Transmission -->
<div class="alert alert-warning">
<span class="alert-icon">⚠️</span>
<p>
<strong>Note:</strong> Per your request, the password used for
this test will be included in the body of the test email.
</p>
</div>
</form>
<!-- Results Section -->
<div id="results" class="results-section hidden">
<h3>Test Results</h3>
<div id="statusMessage" class="status-message"></div>
<pre id="logOutput" class="log-output"></pre>
</div>
<!-- History Panel -->
<div class="history-panel" id="historyPanel">
<div class="history-header">
<h3>📋 Test History</h3>
<button class="clear-history-btn" id="clearHistoryBtn">Clear All</button>
</div>
<div id="historyList">
<div class="history-empty">No test history yet. Run a test to see it here!</div>
</div>
</div>
</div>
</main>
<!-- Footer -->
<footer class="footer">
<p>&copy; 2025 Beyond Cloud Technology. All rights reserved.</p>
<a href="https://github.com/DeNNiiInc/Advanced-Smtp-Tester" target="_blank" rel="noopener noreferrer"
class="github-link">
<svg class="github-icon" viewBox="0 0 24 24" fill="currentColor">
<path
d="M12 0c-6.626 0-12 5.373-12 12 0 5.302 3.438 9.8 8.207 11.387.599.111.793-.261.793-.577v-2.234c-3.338.726-4.033-1.416-4.033-1.416-.546-1.387-1.333-1.756-1.333-1.756-1.089-.745.083-.729.083-.729 1.205.084 1.839 1.237 1.839 1.237 1.07 1.834 2.807 1.304 3.492.997.107-.775.418-1.305.762-1.604-2.665-.305-5.467-1.334-5.467-5.931 0-1.311.469-2.381 1.236-3.221-.124-.303-.535-1.524.117-3.176 0 0 1.008-.322 3.301 1.23.957-.266 1.983-.399 3.003-.404 1.02.005 2.047.138 3.006.404 2.291-1.552 3.297-1.23 3.297-1.23.653 1.653.242 2.874.118 3.176.77.84 1.235 1.911 1.235 3.221 0 4.609-2.807 5.624-5.479 5.921.43.372.823 1.102.823 2.222v3.293c0 .319.192.694.801.576 4.765-1.589 8.199-6.086 8.199-11.386 0-6.627-5.373-12-12-12z" />
</svg>
View on GitHub
</a>
</footer>
</div>
<script src="public/db.js"></script>
<script src="public/script.js"></script>
</body>
</html>

5664
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -1,18 +1,27 @@
{
"name": "advanced-smtp-tester",
"version": "1.0.0",
"description": "Advanced Smtp Tester",
"main": "index.js",
"description": "Advanced Smtp Tester - Desktop Application",
"main": "electron-main.js",
"scripts": {
"start": "node server.js",
"electron": "electron .",
"build": "electron-builder build --win --publish never",
"build:dir": "electron-builder build --win --dir",
"package": "electron-packager . \"Advanced-SMTP-Tester\" --platform=win32 --arch=x64 --out=dist --overwrite",
"test": "echo \"Error: no test specified\" && exit 1"
},
"repository": {
"type": "git",
"url": "git+https://github.com/DeNNiiInc/Advanced-Smtp-Tester.git"
},
"keywords": [],
"author": "",
"keywords": [
"smtp",
"email",
"tester",
"desktop"
],
"author": "Beyond Cloud Technology",
"license": "ISC",
"type": "commonjs",
"bugs": {
@@ -24,5 +33,53 @@
"cors": "^2.8.5",
"express": "^5.2.1",
"nodemailer": "^7.0.11"
},
"devDependencies": {
"electron": "^39.2.7",
"electron-builder": "^26.0.12",
"electron-packager": "^17.1.2"
},
"build": {
"appId": "com.beyondcloud.smtptester",
"productName": "Advanced SMTP Tester",
"directories": {
"output": "dist"
},
"files": [
"**/*",
"!dist",
"!node_modules",
"!.git",
"!.gitignore",
"!README.md"
],
"win": {
"target": [
{
"target": "nsis",
"arch": [
"x64"
]
},
{
"target": "portable",
"arch": [
"x64"
]
}
],
"icon": "public/Logo.png",
"artifactName": "${productName}-${version}-${arch}.${ext}"
},
"nsis": {
"oneClick": false,
"allowToChangeInstallationDirectory": true,
"createDesktopShortcut": true,
"createStartMenuShortcut": true,
"shortcutName": "SMTP Tester"
},
"portable": {
"artifactName": "${productName}-${version}-portable.${ext}"
}
}
}
}

199
public/db.js Normal file
View File

@@ -0,0 +1,199 @@
// IndexedDB Helper for SMTP Tester
// Manages persistent storage for test history, settings, and preferences
const DB_NAME = 'SMTPTesterDB';
const DB_VERSION = 1;
const STORES = {
HISTORY: 'testHistory',
SETTINGS: 'settings',
PREFERENCES: 'preferences'
};
class SMTPDatabase {
constructor() {
this.db = null;
}
// Initialize database
async init() {
return new Promise((resolve, reject) => {
const request = indexedDB.open(DB_NAME, DB_VERSION);
request.onerror = () => reject(request.error);
request.onsuccess = () => {
this.db = request.result;
resolve(this.db);
};
request.onupgradeneeded = (event) => {
const db = event.target.result;
// Create test history store
if (!db.objectStoreNames.contains(STORES.HISTORY)) {
const historyStore = db.createObjectStore(STORES.HISTORY, {
keyPath: 'id',
autoIncrement: true
});
historyStore.createIndex('timestamp', 'timestamp', { unique: false });
historyStore.createIndex('host', 'host', { unique: false });
}
// Create settings store
if (!db.objectStoreNames.contains(STORES.SETTINGS)) {
db.createObjectStore(STORES.SETTINGS, { keyPath: 'key' });
}
// Create preferences store
if (!db.objectStoreNames.contains(STORES.PREFERENCES)) {
db.createObjectStore(STORES.PREFERENCES, { keyPath: 'key' });
}
};
});
}
// Save test result to history
async saveTest(testData) {
const transaction = this.db.transaction([STORES.HISTORY], 'readwrite');
const store = transaction.objectStore(STORES.HISTORY);
const record = {
...testData,
timestamp: new Date().toISOString()
};
return new Promise((resolve, reject) => {
const request = store.add(record);
request.onsuccess = () => {
this.cleanupOldHistory(); // Keep only last 50 records
resolve(request.result);
};
request.onerror = () => reject(request.error);
});
}
// Get test history (last N records)
async getHistory(limit = 50) {
const transaction = this.db.transaction([STORES.HISTORY], 'readonly');
const store = transaction.objectStore(STORES.HISTORY);
const index = store.index('timestamp');
return new Promise((resolve, reject) => {
const request = index.openCursor(null, 'prev'); // Reverse order (newest first)
const results = [];
request.onsuccess = (event) => {
const cursor = event.target.result;
if (cursor && results.length < limit) {
results.push(cursor.value);
cursor.continue();
} else {
resolve(results);
}
};
request.onerror = () => reject(request.error);
});
}
// Clean up old history (keep only last 50)
async cleanupOldHistory() {
const transaction = this.db.transaction([STORES.HISTORY], 'readwrite');
const store = transaction.objectStore(STORES.HISTORY);
const index = store.index('timestamp');
return new Promise((resolve, reject) => {
const request = index.openCursor(null, 'prev');
let count = 0;
request.onsuccess = (event) => {
const cursor = event.target.result;
if (cursor) {
count++;
if (count > 50) {
cursor.delete();
}
cursor.continue();
} else {
resolve();
}
};
request.onerror = () => reject(request.error);
});
}
// Save user settings (last used configuration)
async saveSettings(settings) {
const transaction = this.db.transaction([STORES.SETTINGS], 'readwrite');
const store = transaction.objectStore(STORES.SETTINGS);
const record = {
key: 'lastConfig',
...settings,
updatedAt: new Date().toISOString()
};
return new Promise((resolve, reject) => {
const request = store.put(record);
request.onsuccess = () => resolve(request.result);
request.onerror = () => reject(request.error);
});
}
// Get user settings
async getSettings() {
const transaction = this.db.transaction([STORES.SETTINGS], 'readonly');
const store = transaction.objectStore(STORES.SETTINGS);
return new Promise((resolve, reject) => {
const request = store.get('lastConfig');
request.onsuccess = () => resolve(request.result || null);
request.onerror = () => reject(request.error);
});
}
// Save preference (e.g., theme)
async savePreference(key, value) {
const transaction = this.db.transaction([STORES.PREFERENCES], 'readwrite');
const store = transaction.objectStore(STORES.PREFERENCES);
const record = { key, value };
return new Promise((resolve, reject) => {
const request = store.put(record);
request.onsuccess = () => resolve(request.result);
request.onerror = () => reject(request.error);
});
}
// Get preference
async getPreference(key) {
const transaction = this.db.transaction([STORES.PREFERENCES], 'readonly');
const store = transaction.objectStore(STORES.PREFERENCES);
return new Promise((resolve, reject) => {
const request = store.get(key);
request.onsuccess = () => resolve(request.result ? request.result.value : null);
request.onerror = () => reject(request.error);
});
}
// Clear all history
async clearHistory() {
const transaction = this.db.transaction([STORES.HISTORY], 'readwrite');
const store = transaction.objectStore(STORES.HISTORY);
return new Promise((resolve, reject) => {
const request = store.clear();
request.onsuccess = () => resolve();
request.onerror = () => reject(request.error);
});
}
}
// Create singleton instance
const db = new SMTPDatabase();
// Initialize on load
db.init().catch(err => console.error('Failed to initialize database:', err));
// Export for use in other scripts
window.smtpDB = db;

View File

@@ -1,9 +1,250 @@
// ===================================
// SMTP TESTER - ENHANCED SCRIPT
// Features: Presets, Dark Mode, History, Error Tips
// ===================================
// Configuration Presets
const PRESETS = {
office365: {
host: 'smtp.office365.com',
port: '587',
secure: 'false',
name: 'Microsoft Office 365'
},
gmail: {
host: 'smtp.gmail.com',
port: '587',
secure: 'false',
name: 'Google Gmail'
},
sendgrid: {
host: 'smtp.sendgrid.net',
port: '587',
secure: 'false',
name: 'SendGrid'
},
mailgun: {
host: 'smtp.mailgun.org',
port: '587',
secure: 'false',
name: 'Mailgun'
},
amazonses: {
host: 'email-smtp.us-east-1.amazonaws.com',
port: '587',
secure: 'false',
name: 'Amazon SES'
}
};
// Error Messages with Troubleshooting Tips
const ERROR_TIPS = {
'EAUTH': {
title: 'Authentication Failed',
tips: [
'Verify your username and password are correct',
'For Gmail: Enable "Less secure app access" or use an App Password',
'For Office 365: Check if Modern Authentication is required',
'Some providers require OAuth2 instead of password authentication'
]
},
'ECONNECTION': {
title: 'Connection Failed',
tips: [
'Check if the SMTP host address is correct',
'Verify the port number (587 for STARTTLS, 465 for SSL/TLS)',
'Ensure your firewall isn\'t blocking the connection',
'Try switching between STARTTLS and SSL/TLS encryption'
]
},
'ETIMEDOUT': {
title: 'Connection Timeout',
tips: [
'The server took too long to respond',
'Check your internet connection',
'The SMTP server might be down or overloaded',
'Try again in a few moments'
]
},
'ENOTFOUND': {
title: 'Host Not Found',
tips: [
'Double-check the SMTP host address for typos',
'Ensure you have an active internet connection',
'The SMTP server might be temporarily unavailable'
]
},
'DEFAULT': {
title: 'SMTP Error',
tips: [
'Review your SMTP configuration settings',
'Check the error message for specific details',
'Consult your email provider\'s documentation',
'Try using the Auto Discovery feature'
]
}
};
// ===================================
// THEME MANAGEMENT
// ===================================
const themeToggle = document.getElementById('themeToggle');
let currentTheme = 'dark';
async function initTheme() {
// Load saved theme preference
const savedTheme = await window.smtpDB.getPreference('theme');
if (savedTheme) {
currentTheme = savedTheme;
applyTheme(currentTheme);
}
}
function applyTheme(theme) {
if (theme === 'light') {
document.documentElement.setAttribute('data-theme', 'light');
themeToggle.textContent = '☀️';
} else {
document.documentElement.removeAttribute('data-theme');
themeToggle.textContent = '🌙';
}
}
themeToggle.addEventListener('click', async () => {
currentTheme = currentTheme === 'dark' ? 'light' : 'dark';
applyTheme(currentTheme);
await window.smtpDB.savePreference('theme', currentTheme);
});
// ===================================
// PRESET MANAGEMENT
// ===================================
const presetSelect = document.getElementById('presetSelect');
presetSelect.addEventListener('change', async function () {
const presetKey = this.value;
if (!presetKey) return;
if (presetKey === 'custom') {
// Load last used configuration
const settings = await window.smtpDB.getSettings();
if (settings) {
loadConfigToForm(settings);
}
} else if (PRESETS[presetKey]) {
loadConfigToForm(PRESETS[presetKey]);
}
// Reset selector
setTimeout(() => {
this.value = '';
}, 100);
});
function loadConfigToForm(config) {
if (config.host) document.getElementById('host').value = config.host;
if (config.port) document.getElementById('port').value = config.port;
if (config.secure !== undefined) document.getElementById('secure').value = config.secure;
if (config.user) document.getElementById('user').value = config.user;
if (config.pass) document.getElementById('pass').value = config.pass;
if (config.from) document.getElementById('from').value = config.from;
if (config.to) document.getElementById('to').value = config.to;
}
// ===================================
// HISTORY MANAGEMENT
// ===================================
async function loadHistory() {
const history = await window.smtpDB.getHistory();
const historyList = document.getElementById('historyList');
if (history.length === 0) {
historyList.innerHTML = '<div class="history-empty">No test history yet. Run a test to see it here!</div>';
return;
}
historyList.innerHTML = history.map(item => {
const date = new Date(item.timestamp);
const timeStr = date.toLocaleString();
const statusClass = item.success ? 'success' : 'error';
const statusText = item.success ? '✅ Success' : '❌ Failed';
return `
<div class="history-item" data-id="${item.id}">
<div class="history-item-header">
<span class="history-item-host">${item.host}:${item.port}</span>
<span class="history-item-time">${timeStr}</span>
</div>
<div class="history-item-details">
<span class="history-item-status ${statusClass}">${statusText}</span>
<span>${item.secure === 'true' ? 'SSL/TLS' : (item.secure === 'false' ? 'STARTTLS' : 'Unencrypted')}</span>
<span>${item.user}</span>
</div>
</div>
`;
}).join('');
// Add click handlers to load history items
document.querySelectorAll('.history-item').forEach(item => {
item.addEventListener('click', async function () {
const id = parseInt(this.dataset.id);
const history = await window.smtpDB.getHistory();
const historyItem = history.find(h => h.id === id);
if (historyItem) {
loadConfigToForm(historyItem);
}
});
});
}
// Clear history button
document.getElementById('clearHistoryBtn').addEventListener('click', async () => {
if (confirm('Are you sure you want to clear all test history?')) {
await window.smtpDB.clearHistory();
await loadHistory();
}
});
// ===================================
// ERROR HANDLING
// ===================================
function getErrorTips(errorMessage) {
for (const [code, info] of Object.entries(ERROR_TIPS)) {
if (errorMessage.includes(code)) {
return info;
}
}
return ERROR_TIPS.DEFAULT;
}
function displayErrorWithTips(errorMessage, container) {
const tips = getErrorTips(errorMessage);
const tipsHTML = `
<div class="error-tips">
<div class="error-tips-title">💡 ${tips.title}</div>
<ul>
${tips.tips.map(tip => `<li>${tip}</li>`).join('')}
</ul>
</div>
`;
container.innerHTML = errorMessage + tipsHTML;
}
// ===================================
// PASSWORD TOGGLE
// ===================================
function togglePassword() {
const passInput = document.getElementById('pass');
const type = passInput.getAttribute('type') === 'password' ? 'text' : 'password';
passInput.setAttribute('type', type);
}
// ===================================
// FORM SUBMISSION
// ===================================
document.getElementById('smtpForm').addEventListener('submit', async function (e) {
e.preventDefault();
@@ -29,6 +270,13 @@ document.getElementById('smtpForm').addEventListener('submit', async function (e
const formData = new FormData(this);
const data = Object.fromEntries(formData.entries());
// Trim all string values to prevent copy-paste whitespace issues
Object.keys(data).forEach(key => {
if (typeof data[key] === 'string') {
data[key] = data[key].trim();
}
});
try {
const response = await fetch('/api/test-smtp', {
method: 'POST',
@@ -37,8 +285,8 @@ document.getElementById('smtpForm').addEventListener('submit', async function (e
},
body: JSON.stringify(data),
});
if (!response.ok) {
// Handle non-200 responses
const contentType = response.headers.get("content-type");
if (contentType && contentType.includes("application/json")) {
const errorResult = await response.json();
@@ -58,18 +306,48 @@ document.getElementById('smtpForm').addEventListener('submit', async function (e
statusDiv.classList.add('status-success');
statusDiv.textContent = '✅ Success! Email Sent Successfully.';
logOutput.textContent = JSON.stringify(result.details, null, 2);
// Save to history
await window.smtpDB.saveTest({
...data,
success: true,
messageId: result.details.messageId
});
// Save as last used configuration
await window.smtpDB.saveSettings(data);
// Reload history
await loadHistory();
} else {
// This block handles cases where response was 200 OK but success is false (business logic error)
statusDiv.classList.add('status-error');
statusDiv.textContent = '❌ Error: ' + result.message;
logOutput.textContent = result.error || 'Unknown error occurred.';
displayErrorWithTips(result.error || 'Unknown error occurred.', logOutput);
// Save failed test to history
await window.smtpDB.saveTest({
...data,
success: false,
error: result.error
});
await loadHistory();
}
} catch (error) {
resultsDiv.classList.remove('hidden');
statusDiv.classList.add('status-error');
statusDiv.textContent = '❌ Error Caught'; // Changed from "Network Error" to be more accurate
logOutput.textContent = error.message; // Use error.message instead of error.toString()
statusDiv.textContent = '❌ Error Caught';
displayErrorWithTips(error.message, logOutput);
// Save failed test to history
await window.smtpDB.saveTest({
...data,
success: false,
error: error.message
});
await loadHistory();
} finally {
// Reset Button
btn.disabled = false;
@@ -78,7 +356,9 @@ document.getElementById('smtpForm').addEventListener('submit', async function (e
}
});
// Auto Discovery Test Handler
// ===================================
// AUTO DISCOVERY
// ===================================
document.getElementById('autoTestBtn').addEventListener('click', async function () {
const btn = document.getElementById('autoTestBtn');
const spinner = btn.querySelector('.loading-spinner');
@@ -92,6 +372,13 @@ document.getElementById('autoTestBtn').addEventListener('click', async function
const formData = new FormData(form);
const data = Object.fromEntries(formData.entries());
// Trim all string values
Object.keys(data).forEach(key => {
if (typeof data[key] === 'string') {
data[key] = data[key].trim();
}
});
// Only need host, user, pass, from, to for auto test
const autoTestData = {
host: data.host,
@@ -120,6 +407,7 @@ document.getElementById('autoTestBtn').addEventListener('click', async function
},
body: JSON.stringify(autoTestData),
});
if (!response.ok) {
const contentType = response.headers.get("content-type");
if (contentType && contentType.includes("application/json")) {
@@ -165,14 +453,14 @@ document.getElementById('autoTestBtn').addEventListener('click', async function
} else {
statusDiv.classList.add('status-error');
statusDiv.textContent = '❌ Error: ' + result.message;
logOutput.textContent = result.error || 'Unknown error occurred.';
displayErrorWithTips(result.error || 'Unknown error occurred.', logOutput);
}
} catch (error) {
resultsDiv.classList.remove('hidden');
statusDiv.classList.add('status-error');
statusDiv.textContent = '❌ Error Caught';
logOutput.textContent = error.message;
displayErrorWithTips(error.message, logOutput);
} finally {
// Reset Button
btn.disabled = false;
@@ -180,3 +468,24 @@ document.getElementById('autoTestBtn').addEventListener('click', async function
btnText.textContent = '🔍 Auto Discovery Test';
}
});
// ===================================
// INITIALIZATION
// ===================================
window.addEventListener('DOMContentLoaded', async () => {
// Wait for database to initialize
await window.smtpDB.init();
// Initialize theme
await initTheme();
// Load history
await loadHistory();
// Load last used configuration
const settings = await window.smtpDB.getSettings();
if (settings) {
// Optionally auto-load last config
// loadConfigToForm(settings);
}
});

View File

@@ -3,20 +3,30 @@
=================================== */
:root {
/* Colors */
/* Dark Theme (Default) */
--bg-primary: #0f172a;
--bg-secondary: #1e293b;
--bg-glass: rgba(30, 41, 59, 0.7);
--bg-input: rgba(15, 23, 42, 0.6);
--bg-input-focus: rgba(15, 23, 42, 0.8);
--text-primary: #f1f5f9;
--text-secondary: #94a3b8;
--accent-primary: #6366f1; /* Indigo 500 */
--accent-hover: #4f46e5; /* Indigo 600 */
--border-color: rgba(255, 255, 255, 0.1);
--border-color-focus: #6366f1;
--accent-primary: #6366f1;
--accent-hover: #4f46e5;
--accent-glow: rgba(99, 102, 241, 0.5);
--success: #10b981;
--error: #ef4444;
--warning: #f59e0b;
/* Gradients */
--gradient-bg-1: rgba(99, 102, 241, 0.15);
--gradient-bg-2: rgba(139, 92, 246, 0.15);
--gradient-title: linear-gradient(135deg, #fff 0%, #cbd5e1 100%);
/* Spacing & Borders */
--radius-lg: 16px;
--radius-md: 8px;
@@ -28,6 +38,23 @@
--spacing-lg: 2rem;
}
/* Light Theme */
[data-theme="light"] {
--bg-primary: #f8fafc;
--bg-secondary: #ffffff;
--bg-glass: rgba(255, 255, 255, 0.9);
--bg-input: #ffffff;
--bg-input-focus: #ffffff;
--text-primary: #0f172a;
--text-secondary: #64748b;
--border-color: rgba(0, 0, 0, 0.1);
--border-color-focus: #6366f1;
--gradient-bg-1: rgba(99, 102, 241, 0.08);
--gradient-bg-2: rgba(139, 92, 246, 0.08);
--gradient-title: linear-gradient(135deg, #0f172a 0%, #334155 100%);
}
* {
margin: 0;
padding: 0;
@@ -40,6 +67,7 @@ body {
color: var(--text-primary);
min-height: 100vh;
overflow-x: hidden;
transition: background-color 0.3s ease, color 0.3s ease;
}
/* Background Animation */
@@ -49,18 +77,15 @@ body {
left: 0;
width: 100%;
height: 100%;
background: radial-gradient(
circle at 15% 50%,
rgba(99, 102, 241, 0.15) 0%,
transparent 25%
),
radial-gradient(
circle at 85% 30%,
rgba(139, 92, 246, 0.15) 0%,
transparent 25%
);
background: radial-gradient(circle at 15% 50%,
var(--gradient-bg-1) 0%,
transparent 25%),
radial-gradient(circle at 85% 30%,
var(--gradient-bg-2) 0%,
transparent 25%);
z-index: -1;
pointer-events: none;
transition: background 0.3s ease;
}
.container {
@@ -86,7 +111,7 @@ body {
align-items: center;
justify-content: center;
gap: 1rem;
background: linear-gradient(135deg, #fff 0%, #cbd5e1 100%);
background: var(--gradient-title);
-webkit-background-clip: text;
background-clip: text;
-webkit-text-fill-color: transparent;
@@ -138,10 +163,11 @@ body {
background: var(--bg-glass);
-webkit-backdrop-filter: blur(12px);
backdrop-filter: blur(12px);
border: 1px solid rgba(255, 255, 255, 0.1);
border: 1px solid var(--border-color);
border-radius: var(--radius-lg);
padding: var(--spacing-lg);
box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
transition: background 0.3s ease, border-color 0.3s ease;
}
.panel-header {
@@ -184,8 +210,8 @@ label {
input,
select {
background: rgba(15, 23, 42, 0.6);
border: 1px solid rgba(255, 255, 255, 0.1);
background: var(--bg-input);
border: 1px solid var(--border-color);
border-radius: var(--radius-md);
padding: 0.75rem 1rem;
color: var(--text-primary);
@@ -197,9 +223,9 @@ select {
input:focus,
select:focus {
outline: none;
border-color: var(--accent-primary);
border-color: var(--border-color-focus);
box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.2);
background: rgba(15, 23, 42, 0.8);
background: var(--bg-input-focus);
}
/* Password Toggle */
@@ -250,11 +276,9 @@ select:focus {
}
.btn-primary {
background: linear-gradient(
135deg,
var(--accent-primary),
var(--accent-hover)
);
background: linear-gradient(135deg,
var(--accent-primary),
var(--accent-hover));
color: white;
box-shadow: 0 4px 12px var(--accent-glow);
}
@@ -330,6 +354,7 @@ select:focus {
opacity: 0;
transform: translateY(10px);
}
to {
opacity: 1;
transform: translateY(0);
@@ -424,4 +449,217 @@ select:focus {
.github-icon {
width: 18px;
height: 18px;
}/* Theme Toggle Button */
.theme-toggle {
position: fixed;
top: 1.5rem;
right: 1.5rem;
width: 50px;
height: 50px;
border-radius: 50%;
background: var(--bg-glass);
border: 1px solid var(--border-color);
color: var(--text-primary);
cursor: pointer;
display: flex;
align-items: center;
justify-content: center;
font-size: 1.5rem;
transition: all 0.3s ease;
z-index: 1000;
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}
.theme-toggle:hover {
transform: scale(1.1);
box-shadow: 0 6px 16px rgba(0, 0, 0, 0.3);
}
.theme-toggle:active {
transform: scale(0.95);
}
/* Preset Selector */
.preset-selector {
margin-bottom: var(--spacing-md);
padding: var(--spacing-md);
background: rgba(99, 102, 241, 0.05);
border: 1px solid rgba(99, 102, 241, 0.2);
border-radius: var(--radius-md);
}
.preset-selector label {
color: var(--accent-primary);
font-weight: 600;
margin-bottom: 0.5rem;
display: block;
}
.preset-selector select {
width: 100%;
background: var(--bg-input);
border: 1px solid var(--accent-primary);
}
/* History Panel */
.history-panel {
margin-top: var(--spacing-lg);
padding: var(--spacing-md);
background: var(--bg-glass);
border: 1px solid var(--border-color);
border-radius: var(--radius-md);
max-height: 400px;
overflow-y: auto;
}
.history-header {
display: flex;
justify-content: space-between;
align-items: center;
margin-bottom: var(--spacing-sm);
padding-bottom: var(--spacing-sm);
border-bottom: 1px solid var(--border-color);
}
.history-header h3 {
font-size: 1.1rem;
color: var(--text-primary);
}
.clear-history-btn {
padding: 0.4rem 0.8rem;
background: rgba(239, 68, 68, 0.1);
border: 1px solid var(--error);
border-radius: var(--radius-sm);
color: var(--error);
font-size: 0.85rem;
cursor: pointer;
transition: all 0.2s ease;
}
.clear-history-btn:hover {
background: rgba(239, 68, 68, 0.2);
}
.history-item {
padding: var(--spacing-sm);
margin-bottom: var(--spacing-sm);
background: var(--bg-input);
border: 1px solid var(--border-color);
border-radius: var(--radius-sm);
cursor: pointer;
transition: all 0.2s ease;
}
.history-item:hover {
border-color: var(--accent-primary);
transform: translateX(4px);
}
.history-item-header {
display: flex;
justify-content: space-between;
align-items: center;
margin-bottom: 0.5rem;
}
.history-item-host {
font-family: "JetBrains Mono", monospace;
font-size: 0.9rem;
color: var(--text-primary);
font-weight: 600;
}
.history-item-time {
font-size: 0.75rem;
color: var(--text-secondary);
}
.history-item-details {
display: flex;
gap: 1rem;
font-size: 0.8rem;
color: var(--text-secondary);
}
.history-item-status {
padding: 0.2rem 0.5rem;
border-radius: var(--radius-sm);
font-size: 0.75rem;
font-weight: 600;
}
.history-item-status.success {
background: rgba(16, 185, 129, 0.1);
color: var(--success);
}
.history-item-status.error {
background: rgba(239, 68, 68, 0.1);
color: var(--error);
}
.history-empty {
text-align: center;
padding: var(--spacing-lg);
color: var(--text-secondary);
font-style: italic;
}
/* Error Tips */
.error-tips {
margin-top: var(--spacing-sm);
padding: var(--spacing-sm);
background: rgba(239, 68, 68, 0.05);
border-left: 3px solid var(--error);
border-radius: var(--radius-sm);
}
.error-tips-title {
font-weight: 600;
color: var(--error);
margin-bottom: 0.5rem;
font-size: 0.9rem;
}
.error-tips ul {
margin-left: 1.2rem;
color: var(--text-secondary);
font-size: 0.85rem;
}
.error-tips li {
margin-bottom: 0.3rem;
}
.error-tips a {
color: var(--accent-primary);
text-decoration: none;
}
.error-tips a:hover {
text-decoration: underline;
}
/* Scrollbar Styling */
.history-panel::-webkit-scrollbar,
.log-output::-webkit-scrollbar {
width: 8px;
}
.history-panel::-webkit-scrollbar-track,
.log-output::-webkit-scrollbar-track {
background: var(--bg-input);
border-radius: var(--radius-sm);
}
.history-panel::-webkit-scrollbar-thumb,
.log-output::-webkit-scrollbar-thumb {
background: var(--border-color);
border-radius: var(--radius-sm);
}
.history-panel::-webkit-scrollbar-thumb:hover,
.log-output::-webkit-scrollbar-thumb:hover {
background: var(--text-secondary);
}

View File

@@ -27,22 +27,28 @@ app.post('/api/test-smtp', async (req, res) => {
}) for ${user}`
);
// Parse secure setting
const isSecure = secure === true || secure === "true";
const isNone = secure === "none";
// Create Transporter
const transporterConfig = {
host: host,
port: parseInt(port),
secure: secure === true || secure === "true", // true for 465, false for other ports
secure: isSecure, // true for 465, false for other ports
auth: {
user: user,
pass: pass,
},
tls: {
rejectUnauthorized: false, // Default to allowing self-signed
}
};
// Only add TLS settings if secure is not explicitly "none"
if (secure !== "none") {
transporterConfig.tls = {
rejectUnauthorized: false, // Allow self-signed certs for testing flexibility
};
// Handle Unencrypted (Force Cleartext)
if (isNone) {
transporterConfig.ignoreTLS = true;
delete transporterConfig.tls; // Remove TLS config for cleartext
}
try {