anycoder-e881a3d1 / index.html
farkmuslims's picture
Upload folder using huggingface_hub
1119af3 verified
Raw History Blame Contribute Delete
27.5 kB
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>ProMassMailer | SMTP Sender</title>
<!-- Icons -->
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
<!-- Fonts -->
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@300;400;600;700&display=swap" rel="stylesheet">
<style>
:root {
--primary-color: #4f46e5;
--primary-hover: #4338ca;
--primary-light: #eef2ff;
--danger-color: #ef4444;
--success-color: #10b981;
--text-main: #1f2937;
--text-muted: #6b7280;
--border-color: #e5e7eb;
--bg-body: #f3f4f6;
--card-bg: #ffffff;
--shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
}
* {
box-sizing: border-box;
margin: 0;
padding: 0;
}
body {
font-family: 'Inter', sans-serif;
background-color: var(--bg-body);
color: var(--text-main);
line-height: 1.6;
padding: 20px;
}
/* Header & Footer */
header {
text-align: center;
margin-bottom: 40px;
}
h1 {
font-size: 2.5rem;
font-weight: 800;
color: var(--text-main);
margin-bottom: 10px;
}
.subtitle {
color: var(--text-muted);
font-size: 1.1rem;
}
.footer-link {
display: inline-block;
margin-top: 40px;
color: var(--primary-color);
text-decoration: none;
font-size: 0.9rem;
font-weight: 600;
}
.footer-link:hover {
text-decoration: underline;
}
/* Layout */
.container {
max-width: 1200px;
margin: 0 auto;
display: grid;
grid-template-columns: 350px 1fr;
gap: 30px;
}
@media (max-width: 968px) {
.container {
grid-template-columns: 1fr;
}
}
/* Cards */
.card {
background: var(--card-bg);
border-radius: 16px;
box-shadow: var(--shadow);
padding: 25px;
transition: transform 0.2s ease;
}
.card-header {
display: flex;
align-items: center;
margin-bottom: 20px;
border-bottom: 1px solid var(--border-color);
padding-bottom: 15px;
}
.card-icon {
background: var(--primary-light);
color: var(--primary-color);
padding: 10px;
border-radius: 10px;
margin-right: 15px;
font-size: 1.5rem;
}
.card-title {
font-size: 1.25rem;
font-weight: 700;
}
/* Form Elements */
.form-group {
margin-bottom: 20px;
}
label {
display: block;
margin-bottom: 8px;
font-weight: 600;
font-size: 0.9rem;
color: var(--text-main);
}
.input-group {
position: relative;
}
.input-group i {
position: absolute;
left: 15px;
top: 50%;
transform: translateY(-50%);
color: var(--text-muted);
}
input, textarea, select {
width: 100%;
padding: 12px 12px 12px 45px;
border: 1px solid var(--border-color);
border-radius: 8px;
font-family: inherit;
font-size: 1rem;
transition: all 0.3s ease;
background-color: #f9fafb;
}
input:focus, textarea:focus, select:focus {
outline: none;
border-color: var(--primary-color);
box-shadow: 0 0 0 3px var(--primary-light);
background-color: #fff;
}
textarea {
resize: vertical;
min-height: 150px;
}
.checkbox-group {
display: flex;
align-items: center;
margin-top: 10px;
}
.checkbox-group input {
width: auto;
margin-right: 10px;
accent-color: var(--primary-color);
height: 18px;
width: 18px;
}
.checkbox-group label {
margin-bottom: 0;
font-weight: 400;
cursor: pointer;
}
.toggle-switch {
position: relative;
display: inline-block;
width: 50px;
height: 24px;
margin-left: 10px;
}
.toggle-switch input {
opacity: 0;
width: 0;
height: 0;
}
.slider {
position: absolute;
cursor: pointer;
top: 0;
left: 0;
right: 0;
bottom: 0;
background-color: #ccc;
transition: .4s;
border-radius: 34px;
}
.slider:before {
position: absolute;
content: "";
height: 16px;
width: 16px;
left: 4px;
bottom: 4px;
background-color: white;
transition: .4s;
border-radius: 50%;
}
input:checked + .slider {
background-color: var(--primary-color);
}
input:checked + .slider:before {
transform: translateX(26px);
}
/* Action Buttons */
.btn {
width: 100%;
padding: 14px;
border: none;
border-radius: 8px;
font-size: 1rem;
font-weight: 600;
cursor: pointer;
transition: all 0.3s ease;
display: flex;
justify-content: center;
align-items: center;
gap: 10px;
}
.btn-primary {
background-color: var(--primary-color);
color: white;
box-shadow: 0 4px 14px 0 rgba(79, 70, 229, 0.39);
}
.btn-primary:hover {
background-color: var(--primary-hover);
transform: translateY(-1px);
}
.btn-primary:disabled {
background-color: #a5a7dc;
cursor: not-allowed;
transform: none;
}
.btn-danger {
background-color: white;
color: var(--danger-color);
border: 1px solid var(--danger-color);
margin-top: 10px;
}
.btn-danger:hover {
background-color: #fef2f2;
}
/* Progress & Logs */
.status-bar {
margin-top: 20px;
height: 6px;
background-color: var(--border-color);
border-radius: 3px;
overflow: hidden;
display: none;
}
.progress-fill {
height: 100%;
width: 0%;
background: linear-gradient(90deg, var(--primary-color), #818cf8);
transition: width 0.3s ease;
}
.logs-container {
margin-top: 30px;
height: 300px;
overflow-y: auto;
background-color: #1e293b;
border-radius: 8px;
padding: 15px;
font-family: 'Courier New', Courier, monospace;
font-size: 0.85rem;
color: #e2e8f0;
}
.log-entry {
margin-bottom: 6px;
border-bottom: 1px solid #334155;
padding-bottom: 4px;
}
.log-time {
color: #94a3b8;
margin-right: 10px;
}
.log-success { color: #4ade80; }
.log-error { color: #f87171; }
.log-info { color: #60a5fa; }
.stats-grid {
display: grid;
grid-template-columns: 1fr 1fr 1fr;
gap: 15px;
margin-bottom: 20px;
}
.stat-box {
background: var(--bg-body);
padding: 15px;
border-radius: 8px;
text-align: center;
}
.stat-value {
font-size: 1.5rem;
font-weight: 700;
color: var(--text-main);
}
.stat-label {
font-size: 0.85rem;
color: var(--text-muted);
}
</style>
</head>
<body>
<header>
<h1><i class="fa-solid fa-paper-plane"></i> ProMassMailer</h1>
<p class="subtitle">Secure SMTP Mass Email Sender Interface</p>
<a href="https://huggingface.co/spaces/akhaliq/anycoder" target="_blank" class="footer-link">
Built with anycoder
</a>
</header>
<div class="container">
<!-- Left Column: Configuration -->
<div class="left-panel">
<div class="card">
<div class="card-header">
<div class="card-icon"><i class="fa-solid fa-gear"></i></div>
<div class="card-title">SMTP Configuration</div>
</div>
<form id="smtpConfigForm">
<div class="form-group">
<label for="smtpHost">SMTP Host</label>
<div class="input-group">
<i class="fa-solid fa-server"></i>
<input type="text" id="smtpHost" placeholder="smtp.gmail.com" required value="smtp.gmail.com">
</div>
</div>
<div class="form-group">
<label for="smtpPort">Port</label>
<div class="input-group">
<i class="fa-solid fa-satellite-dish"></i>
<input type="number" id="smtpPort" placeholder="587" required value="587">
</div>
</div>
<div class="form-group">
<label for="smtpEmail">Sender Email</label>
<div class="input-group">
<i class="fa-solid fa-envelope"></i>
<input type="email" id="smtpEmail" placeholder="sender@example.com" required>
</div>
</div>
<div class="form-group">
<label for="smtpPass">App Password</label>
<div class="input-group">
<i class="fa-solid fa-key"></i>
<input type="password" id="smtpPass" placeholder="••••••••" required>
</div>
<small style="color: var(--text-muted); margin-top: 5px; display:block;">
<i class="fa-solid fa-circle-info"></i> Use an App Password for Gmail/Outlook.
</small>
</div>
<div class="form-group">
<label>Connection Security</label>
<div class="checkbox-group">
<div class="toggle-switch">
<input type="checkbox" id="smtpUseTls" checked>
<span class="slider"></span>
</div>
<label for="smtpUseTls">Use TLS Encryption</label>
</div>
</div>
<hr style="border: 0; border-top: 1px solid var(--border-color); margin: 25px 0;">
<div class="form-group">
<label for="senderName">From Name (Optional)</label>
<input type="text" id="senderName" placeholder="e.g. Marketing Team">
</div>
<div class="form-group">
<label for="subject">Email Subject</label>
<input type="text" id="subject" placeholder="Subject line goes here..." required>
</div>
<div class="form-group">
<label for="emailBody">Email Body (HTML Supported)</label>
<textarea id="emailBody" placeholder="<h1>Hello!</h1><p>This is a mass email.</p>" required>
Dear User,
We are excited to announce our new features...
Best regards,
The Team
</textarea>
</div>
<button type="button" id="btnConnectTest" class="btn" style="background-color: #f3f4f6; color: #374151;">
<i class="fa-solid fa-paper-plane"></i> Test Connection
</button>
</form>
</div>
<div class="card" style="margin-top: 20px;">
<div class="card-header">
<div class="card-icon"><i class="fa-solid fa-list"></i></div>
<div class="card-title">Campaign Stats</div>
</div>
<div class="stats-grid">
<div class="stat-box">
<div class="stat-value" id="statTotal">0</div>
<div class="stat-label">Total Recipients</div>
</div>
<div class="stat-box">
<div class="stat-value" id="statSuccess" style="color: var(--success-color)">0</div>
<div class="stat-label">Sent Successfully</div>
</div>
<div class="stat-box">
<div class="stat-value" id="statFailed" style="color: var(--danger-color)">0</div>
<div class="stat-label">Failed</div>
</div>
</div>
</div>
</div>
<!-- Right Column: Recipients & Action -->
<div class="right-panel">
<div class="card">
<div class="card-header">
<div class="card-icon"><i class="fa-solid fa-users"></i></div>
<div class="card-title">Recipient List</div>
</div>
<div class="form-group">
<label for="recipients">Enter Emails (Comma or New Line separated)</label>
<textarea id="recipients" placeholder="user1@example.com, user2@example.com" required style="min-height: 200px;"></textarea>
</div>
<div class="form-group">
<div class="checkbox-group">
<input type="checkbox" id="dryRunMode">
<label for="dryRunMode">Dry Run Mode (Simulate sending without connecting to server)</label>
</div>
<p style="font-size: 0.8rem; color: var(--text-muted); margin-top: 5px;">
Dry run allows you to test your template logic and list parsing without using your SMTP quota.
</p>
</div>
<div class="status-bar" id="statusBar">
<div class="progress-fill" id="progressFill"></div>
</div>
<div style="display: flex; gap: 15px; margin-top: 20px;">
<button type="button" id="btnSend" class="btn btn-primary">
<i class="fa-solid fa-paper-plane"></i> Start Campaign
</button>
<button type="button" id="btnClearLogs" class="btn" style="background-color: #e5e7eb; color: #374151;">
<i class="fa-solid fa-trash"></i> Clear Logs
</button>
</div>
<button type="button" id="btnAbort" class="btn btn-danger" style="display: none;">
<i class="fa-solid fa-stop"></i> Stop Campaign
</button>
</div>
<div class="card" style="margin-top: 20px;">
<div class="card-header">
<div class="card-icon"><i class="fa-solid fa-terminal"></i></div>
<div class="card-title">Live Activity Log</div>
</div>
<div class="logs-container" id="logsContainer">
<div class="log-entry">
<span class="log-time">[System]</span> Ready to configure and send.
</div>
</div>
</div>
</div>
</div>
<!-- SMTP.js Library -->
<script type="module">
import { EmailSender } from 'https://unpkg.com/smtpjs@3.0.1/dist/smtpjs.js';
// DOM Elements
const els = {
smtpHost: document.getElementById('smtpHost'),
smtpPort: document.getElementById('smtpPort'),
smtpEmail: document.getElementById('smtpEmail'),
smtpPass: document.getElementById('smtpPass'),
smtpUseTls: document.getElementById('smtpUseTls'),
senderName: document.getElementById('senderName'),
subject: document.getElementById('subject'),
emailBody: document.getElementById('emailBody'),
recipients: document.getElementById('recipients'),
btnConnectTest: document.getElementById('btnConnectTest'),
btnSend: document.getElementById('btnSend'),
btnAbort: document.getElementById('btnAbort'),
btnClearLogs: document.getElementById('btnClearLogs'),
statusBar: document.getElementById('statusBar'),
progressFill: document.getElementById('progressFill'),
logsContainer: document.getElementById('logsContainer'),
statTotal: document.getElementById('statTotal'),
statSuccess: document.getElementById('statSuccess'),
statFailed: document.getElementById('statFailed'),
dryRunMode: document.getElementById('dryRunMode')
};
// State
let isSending = false;
let abortSend = false;
let stats = { total: 0, success: 0, failed: 0 };
let emailList = [];
let senderInstance = null;
// Helper Functions
const log = (message, type = 'info') => {
const now = new Date();
const timeString = now.toLocaleTimeString();
const colorClass = type === 'success' ? 'log-success' : type === 'error' ? 'log-error' : 'log-info';
const entry = document.createElement('div');
entry.className = 'log-entry';
entry.innerHTML = `<span class="log-time">[${timeString}]</span> <span class="${colorClass}">${message}</span>`;
els.logsContainer.appendChild(entry);
els.logsContainer.scrollTop = els.logsContainer.scrollHeight;
};
const updateStats = () => {
els.statTotal.innerText = stats.total;
els.statSuccess.innerText = stats.success;
els.statFailed.innerText = stats.failed;
};
const parseEmails = () => {
const raw = els.recipients.value;
// Regex to match basic email patterns
const emailRegex = /[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}/g;
const matches = raw.match(emailRegex);
if (!matches) {
alert("No valid email addresses found in the list.");
return [];
}
// Remove duplicates
return [...new Set(matches)];
};
const getSmtpConfig = () => {
return {
host: els.smtpHost.value,
port: parseInt(els.smtpPort.value),
useTLS: els.smtpUseTls.checked,
user: els.smtpEmail.value,
pass: els.smtpPass.value
};
};
// SMTP Connection Logic
els.btnConnectTest.addEventListener('click', async () => {
const config = getSmtpConfig();
if (!config.user || !config.pass || !config.host) {
alert("Please fill in all SMTP fields.");
return;
}
els.btnConnectTest.disabled = true;
els.btnConnectTest.innerHTML = '<i class="fa-solid fa-spinner fa-spin"></i> Testing...';
try {
// Initialize SMTPJS Sender
senderInstance = new EmailSender(
config.host,
config.port,
config.user,
config.pass,
config.useTLS
);
// Test send to self
const testResult = await senderInstance.send(
config.user, // From
config.user, // To
"Test Connection", // Subject
"If you see this, your SMTP settings are correct." // Body
);
if (testResult.success) {
log("SMTP Connection Successful! Credentials validated.", "success");
alert("Connection Successful! You are ready to send emails.");
} else {
throw new Error(testResult.message || "Unknown connection error");
}
} catch (error) {
log(`Connection Failed: ${error.message}`, "error");
alert(`Connection Failed: ${error.message}`);
senderInstance = null;
} finally {
els.btnConnectTest.disabled = false;
els.btnConnectTest.innerHTML = '<i class="fa-solid fa-paper-plane"></i> Test Connection';
}
});
// Send Campaign Logic
els.btnSend.addEventListener('click', () => {
emailList = parseEmails();
if (emailList.length === 0) {
log("No valid recipients found. Aborting.", "error");
return;
}
if (!senderInstance && !els.dryRunMode.checked) {
alert("Please Test the Connection first, or enable Dry Run Mode.");
return;
}
// Reset State
isSending = true;
abortSend = false;
stats = { total: emailList.length, success: 0, failed: 0 };
updateStats();
// UI Updates
els.btnSend.style.display = 'none';
els.btnAbort.style.display = 'flex';
els.statusBar.style.display = 'block';
els.recipients.disabled = true;
log(`Starting campaign with ${stats.total} recipients...`, "info");
let currentCount = 0;
const batchSize = 5; // Process in small batches to avoid freezing UI
const processBatch = () => {
if (abortSend) {
log("Campaign aborted by user.", "error");
finishCampaign();
return;
}
const batch = emailList.slice(currentCount, currentCount + batchSize);
batch.forEach(email => {
if (abortSend) return;
const progressPercent = ((currentCount / stats.total) * 100);
els.progressFill.style.width = `${progressPercent}%`;
if (els.dryRunMode.checked) {
// SIMULATION MODE
setTimeout(() => {
if(Math.random() > 0.1) { // 90% success rate simulation
stats.success++;
log(`[SIMULATION] Sent to ${email}`, "success");
} else {
stats.failed++;
log(`[SIMULATION] Failed for ${email}: Random Network Error`, "error");
}
currentCount++;
updateStats();
if (currentCount < stats.total) {
processBatch();
} else {
finishCampaign();
}
}, 200); // Fake delay
} else {
// REAL MODE
const fromName = els.senderName.value || els.smtpEmail.value;
const subject = els.subject.value;
const body = els.emailBody.value;
log(`Sending to ${email}...`, "info");
senderInstance.send(
els.smtpEmail.value,
email,
subject,
body
).then(result => {
if (result.success) {
stats.success++;
log(`Sent successfully to ${email}`, "success");
} else {
stats.failed++;
log(`Failed for ${email}: ${result.message}`, "error");
}
currentCount++;
updateStats();
if (currentCount < stats.total) {
processBatch();
} else {
finishCampaign();
}
}).catch(err => {
stats.failed++;
log(`Error for ${email}: ${err.message}`, "error");
currentCount++;
updateStats();
if (currentCount < stats.total) {
processBatch();
} else {
finishCampaign();
}
});
}
});
if (batch.length === 0 && currentCount >= stats.total) {
finishCampaign();
}
};
processBatch();
});
const finishCampaign = () => {
isSending = false;
els.btnSend.style.display = 'flex';
els.btnAbort.style.display = 'none';
els.statusBar.style.display = 'none';
els.progressFill.style.width = '100%';
els.recipients.disabled = false;
log(`Campaign Finished. Sent: ${stats.success}, Failed: ${stats.failed}`, "info");
};
els.btnAbort.addEventListener('click', () => {
abortSend = true;
els.btnAbort.innerHTML = '<i class="fa-solid fa-spinner fa-spin"></i> Stopping...';
});
els.btnClearLogs.addEventListener('click', () => {
els.logsContainer.innerHTML = '';
log("Logs cleared.", "info");
});
// Initial Log
log("Application initialized. Please configure SMTP settings.", "info");
</script>
</body>
</html>