|
- <!DOCTYPE html>
- <html>
- <head>
- <meta http-equiv="X-UA-Compatible" content="IE=9" />
- <title>MassMailer</title>
- <HTA:APPLICATION ID="MassMailer" APPLICATIONNAME="MassMailer" BORDER="thick" SCROLL="yes" SINGLEINSTANCE="yes" />
- <style type="text/css">
- body { margin: 0; font: 15px Segoe UI, Arial, sans-serif; color: #243145; background: #f4f6f8; }
- header { background: #17324e; color: #fff; padding: 22px 28px; }
- h1 { margin: 0; font-size: 24px; }
- header p { margin: 7px 0 0; color: #d2dfec; }
- main { padding: 24px 28px; }
- .notice { padding: 14px 17px; background: #fff7e3; border-left: 4px solid #ca8f13; margin-bottom: 22px; }
- .cards { display: table; width: 100%; border-spacing: 10px; margin-left: -10px; }
- .card { display: table-cell; width: 25%; background: white; padding: 18px; border: 1px solid #dbe1e7; }
- .number { display: block; margin-top: 8px; font-size: 28px; color: #17324e; }
- .details { background: white; padding: 18px; border: 1px solid #dbe1e7; line-height: 1.7; }
- .details strong { display: inline-block; width: 135px; }
- button { background: #176b9b; color: white; border: 0; padding: 9px 16px; cursor: pointer; margin-top: 17px; }
- button:disabled { background: #a7b3bd; cursor: default; }
- .panel { background: white; padding: 18px; border: 1px solid #dbe1e7; margin-top: 18px; }
- .panel h2 { margin: 0 0 12px; font-size: 19px; }
- .field { display: block; margin: 12px 0; }
- .field input, .field select { display: block; width: 95%; max-width: 640px; padding: 7px; margin-top: 4px; }
- table { border-collapse: collapse; width: 100%; margin-top: 15px; }
- th, td { border-bottom: 1px solid #e4e8ec; padding: 7px; text-align: left; }
- .bad { color: #9c2929; }
- .good { color: #235e37; }
- #error { color: #9c2929; white-space: pre-wrap; margin-top: 12px; }
- #templatePreview, #campaignPreview { width: 100%; height: 440px; border: 1px solid #dbe1e7; background: white; margin-top: 12px; }
- </style>
- <script language="JScript" src="src/contacts.js"></script>
- <script language="JScript" type="text/javascript">
- var pendingCsvText = null;
- var pendingPreview = null;
- var pendingSource = "";
- var pendingPath = "";
- var pendingCampaignReview = null;
- var campaignTestAccepted = false;
-
- function projectRoot() {
- var path = decodeURIComponent(window.location.pathname);
- if (path.charAt(0) === "/" && path.charAt(2) === ":") path = path.substring(1);
- path = path.replace(/\//g, "\\");
- return new ActiveXObject("Scripting.FileSystemObject").GetParentFolderName(path);
- }
- function readSettings(filePath) {
- var stream = new ActiveXObject("ADODB.Stream");
- stream.Type = 2;
- stream.Charset = "utf-8";
- stream.Open();
- stream.LoadFromFile(filePath);
- var data = stream.ReadText();
- stream.Close();
- var result = {};
- var lines = data.replace(/\r\n?/g, "\n").split("\n");
- for (var i = 0; i < lines.length; i++) {
- var line = lines[i].replace(/^\s+|\s+$/g, "");
- if (!line || line.charAt(0) === "#" || line.charAt(0) === ";") continue;
- var equalAt = line.indexOf("=");
- if (equalAt > 0) result[line.substring(0, equalAt).replace(/\s/g, "").toUpperCase()] =
- line.substring(equalAt + 1).replace(/^\s+|\s+$/g, "");
- }
- return result;
- }
- function countRows(db, tableName) {
- var rows = db.Execute("SELECT COUNT(*) AS N FROM [" + tableName + "]");
- var result = rows.Fields("N").Value;
- rows.Close();
- return result;
- }
- function openDatabase() {
- var fs = new ActiveXObject("Scripting.FileSystemObject");
- var root = projectRoot();
- var config = readSettings(fs.BuildPath(root, "config.ini"));
- var dbPath = config.DB_PATH;
- if (fs.GetDriveName(dbPath) === "") dbPath = fs.BuildPath(root, dbPath);
- dbPath = fs.GetAbsolutePathName(dbPath);
- var db = new ActiveXObject("ADODB.Connection");
- db.Open("Provider=" + config.DB_PROVIDER + ";Data Source=" + dbPath + ";");
- return { db: db, config: config, path: dbPath };
- }
- function refreshStatus() {
- var db = null;
- try {
- var opened = openDatabase();
- db = opened.db;
- document.getElementById("contacts").innerText = countRows(db, "Contact");
- document.getElementById("suppressed").innerText = countRows(db, "Suppression");
- document.getElementById("templates").innerText = countRows(db, "TemplateVersion");
- document.getElementById("campaigns").innerText = countRows(db, "Campaign");
- document.getElementById("database").innerText = opened.path;
- document.getElementById("provider").innerText = opened.config.DB_PROVIDER;
- document.getElementById("interval").innerText = opened.config.QUEUE_INTERVAL + " seconds";
- document.getElementById("testTo").innerText = opened.config.SMTP_TEST_TO || "Not configured";
- document.getElementById("error").innerText = "";
- refreshTemplates();
- refreshCampaigns();
- } catch (error) {
- document.getElementById("error").innerText = "Status refresh failed: " + error.message;
- } finally {
- if (db !== null && db.State === 1) db.Close();
- }
- }
- function readCsvFile(path) {
- var fs = new ActiveXObject("Scripting.FileSystemObject");
- if (!fs.FileExists(path)) throw new Error("CSV file not found: " + path);
- if (fs.GetFile(path).Size > 2097152) throw new Error("CSV exceeds the 2 MB import limit");
- var stream = new ActiveXObject("ADODB.Stream");
- stream.Type = 2;
- stream.Charset = "utf-8";
- stream.Open();
- stream.LoadFromFile(path);
- var text = stream.ReadText();
- stream.Close();
- return text;
- }
- function emailLookup(db, tableName) {
- var found = {};
- var rows = db.Execute("SELECT [EmailKey] FROM [" + tableName + "]");
- while (!rows.EOF) {
- found[String(rows.Fields("EmailKey").Value).toLowerCase()] = true;
- rows.MoveNext();
- }
- rows.Close();
- return found;
- }
- function renderPreview(preview) {
- document.getElementById("previewCount").innerText = preview.accepted.length +
- " ready, " + preview.rejected.length + " rejected";
- var body = document.getElementById("previewBody");
- while (body.firstChild) body.removeChild(body.firstChild);
- var items = preview.accepted.concat(preview.rejected);
- items.sort(function (a, b) { return a.line - b.line; });
- for (var i = 0; i < items.length; i++) {
- var tr = document.createElement("tr");
- var values = [items[i].line, items[i].email, items[i].businessName,
- items[i].source, items[i].reason || "Ready"];
- for (var j = 0; j < values.length; j++) {
- var td = document.createElement("td");
- td.innerText = values[j];
- if (j === 4) td.className = items[i].reason ? "bad" : "good";
- tr.appendChild(td);
- }
- body.appendChild(tr);
- }
- document.getElementById("commitImport").disabled = preview.accepted.length === 0;
- }
- function previewContacts() {
- var db = null;
- document.getElementById("importMessage").innerText = "";
- document.getElementById("commitImport").disabled = true;
- try {
- var path = document.getElementById("csvPath").value;
- pendingPath = path;
- pendingSource = document.getElementById("sourceFallback").value.replace(/^\s+|\s+$/g, "");
- pendingCsvText = readCsvFile(path);
- var opened = openDatabase();
- db = opened.db;
- pendingPreview = MassMailerContacts.preview(pendingCsvText, pendingSource,
- emailLookup(db, "Contact"), emailLookup(db, "Suppression"));
- renderPreview(pendingPreview);
- } catch (error) {
- pendingPreview = null;
- document.getElementById("importMessage").innerText = error.message;
- } finally {
- if (db !== null && db.State === 1) db.Close();
- }
- }
- function utcNowSql() {
- return "DateAdd('n'," + new Date().getTimezoneOffset() + ",Now())";
- }
- function importOne(db, row) {
- var dateSql = utcNowSql();
- if (row.acquiredAt) {
- dateSql = "DateSerial(" + Number(row.acquiredAt.substring(0, 4)) + "," +
- Number(row.acquiredAt.substring(5, 7)) + "," +
- Number(row.acquiredAt.substring(8, 10)) + ")";
- }
- var cmd = new ActiveXObject("ADODB.Command");
- cmd.ActiveConnection = db;
- cmd.CommandText = "INSERT INTO [Contact] ([EmailOriginal],[EmailKey],[BusinessName]," +
- "[SourceReference],[AcquiredAtUtc],[Country],[EligibilityBasis],[CreatedAtUtc]) " +
- "VALUES (?,?,?,? ," + dateSql + ",'US','public_listing'," + utcNowSql() + ")";
- cmd.Parameters.Append(cmd.CreateParameter("email", 202, 1, 254, row.email));
- cmd.Parameters.Append(cmd.CreateParameter("key", 202, 1, 254, row.emailKey));
- cmd.Parameters.Append(cmd.CreateParameter("business", 202, 1, 200, row.businessName));
- cmd.Parameters.Append(cmd.CreateParameter("source", 203, 1, Math.max(1, row.source.length), row.source));
- cmd.Execute();
- }
- function commitContacts() {
- if (!pendingPreview || !pendingPreview.accepted.length) return;
- var db = null, inTransaction = false, succeeded = false;
- try {
- if (document.getElementById("csvPath").value !== pendingPath)
- throw new Error("CSV file selection changed. Preview it again.");
- if (document.getElementById("sourceFallback").value.replace(/^\s+|\s+$/g, "") !== pendingSource)
- throw new Error("Source reference changed. Preview the CSV again.");
- var opened = openDatabase();
- db = opened.db;
- var current = MassMailerContacts.preview(pendingCsvText, pendingSource,
- emailLookup(db, "Contact"), emailLookup(db, "Suppression"));
- if (current.accepted.length !== pendingPreview.accepted.length ||
- current.rejected.length !== pendingPreview.rejected.length)
- throw new Error("Contacts or suppressions changed. Preview the CSV again.");
- for (var check = 0; check < current.accepted.length; check++) {
- if (current.accepted[check].emailKey !== pendingPreview.accepted[check].emailKey)
- throw new Error("Contacts changed. Preview the CSV again.");
- }
- db.BeginTrans();
- inTransaction = true;
- for (var i = 0; i < current.accepted.length; i++) importOne(db, current.accepted[i]);
- db.CommitTrans();
- inTransaction = false;
- document.getElementById("importMessage").innerText =
- "Imported " + current.accepted.length + " contacts. Rejected rows were not saved.";
- pendingPreview = null;
- document.getElementById("commitImport").disabled = true;
- succeeded = true;
- } catch (error) {
- if (inTransaction) db.RollbackTrans();
- document.getElementById("importMessage").innerText = "Import failed: " + error.message;
- } finally {
- if (db !== null && db.State === 1) db.Close();
- if (succeeded) refreshStatus();
- }
- }
- function addSuppression() {
- var db = null, succeeded = false;
- try {
- var email = document.getElementById("suppressEmail").value.replace(/^\s+|\s+$/g, "");
- if (!MassMailerContacts.isEmail(email)) throw new Error("Enter a valid email address");
- var key = MassMailerContacts.emailKey(email);
- var reason = document.getElementById("suppressReason").value;
- var evidence = document.getElementById("suppressEvidence").value.replace(/^\s+|\s+$/g, "");
- var opened = openDatabase();
- db = opened.db;
- if (emailLookup(db, "Suppression")[key]) throw new Error("Address is already suppressed");
- var cmd = new ActiveXObject("ADODB.Command");
- cmd.ActiveConnection = db;
- cmd.CommandText = "INSERT INTO [Suppression] ([EmailKey],[Reason],[RecordedAtUtc]," +
- "[EvidenceReference]) VALUES (?, ?, " + utcNowSql() + ", ?)";
- cmd.Parameters.Append(cmd.CreateParameter("email", 202, 1, 254, key));
- cmd.Parameters.Append(cmd.CreateParameter("reason", 202, 1, 40, reason));
- cmd.Parameters.Append(cmd.CreateParameter("evidence", 203, 1, Math.max(1, evidence.length), evidence));
- cmd.Execute();
- document.getElementById("suppressMessage").innerText = "Suppressed " + key;
- document.getElementById("suppressEmail").value = "";
- succeeded = true;
- } catch (error) {
- document.getElementById("suppressMessage").innerText = "Suppression failed: " + error.message;
- } finally {
- if (db !== null && db.State === 1) db.Close();
- if (succeeded) refreshStatus();
- }
- }
- function powerShellHost() {
- var fs = new ActiveXObject("Scripting.FileSystemObject");
- var shell = new ActiveXObject("WScript.Shell");
- var root = shell.ExpandEnvironmentStrings("%SystemRoot%");
- var settings = readSettings(fs.BuildPath(projectRoot(), "config.ini"));
- var folder = (settings.DB_BITNESS || "").toLowerCase() === "x64" ? "System32" :
- (fs.FolderExists(root + "\\SysWOW64") ? "SysWOW64" : "System32");
- return root + "\\" + folder + "\\WindowsPowerShell\\v1.0\\powershell.exe";
- }
- function quoted(value) { return '"' + value + '"'; }
- function configurePassword() {
- try {
- var fs = new ActiveXObject("Scripting.FileSystemObject");
- var script = fs.BuildPath(projectRoot(), "tools\\set-smtp-password.ps1");
- var command = quoted(powerShellHost()) + " -NoProfile -ExecutionPolicy Bypass -File " + quoted(script);
- var status = new ActiveXObject("WScript.Shell").Run(command, 1, true);
- document.getElementById("transportMessage").innerText = status === 0 ?
- "SMTP password setup completed." : "SMTP password setup failed. Review the console error.";
- } catch (error) {
- document.getElementById("transportMessage").innerText = "Setup failed: " + error.message;
- }
- }
- function sendInternalTest() {
- try {
- var fs = new ActiveXObject("Scripting.FileSystemObject");
- var root = projectRoot();
- var settings = readSettings(fs.BuildPath(root, "config.ini"));
- if (!settings.SMTP_TEST_TO) throw new Error("Set SMTP_TEST_TO in config.ini first");
- if (!window.confirm("Send one internal SMTP test to " + settings.SMTP_TEST_TO + "?")) return;
- var script = fs.BuildPath(root, "tools\\test-smtp-message.ps1");
- var command = quoted(powerShellHost()) + " -NoProfile -ExecutionPolicy Bypass -File " +
- quoted(script) + " -Send";
- var process = new ActiveXObject("WScript.Shell").Exec(command);
- var output = process.StdOut.ReadAll();
- var errors = process.StdErr.ReadAll();
- document.getElementById("transportMessage").innerText =
- (process.ExitCode === 0 ? "" : "Test failed. ") + output + errors;
- } catch (error) {
- document.getElementById("transportMessage").innerText = "Test failed: " + error.message;
- }
- }
- function refreshTemplates() {
- var db = null;
- try {
- db = openDatabase().db;
- var rows = db.Execute("SELECT [Id],[TemplateName],[VersionNumber] FROM [TemplateVersion] WHERE [ValidationStatus]='validated' ORDER BY [Id] DESC");
- var select = document.getElementById("templateVersion");
- var campaignSelect = document.getElementById("campaignTemplateVersion");
- while (select.options.length) select.remove(0);
- while (campaignSelect.options.length) campaignSelect.remove(0);
- while (!rows.EOF) {
- var value = String(rows.Fields("Id").Value);
- var label = String(rows.Fields("TemplateName").Value) + " — version " +
- String(rows.Fields("VersionNumber").Value);
- var option = document.createElement("option");
- option.value = value;
- option.text = label;
- select.add(option);
- var campaignOption = document.createElement("option");
- campaignOption.value = value;
- campaignOption.text = label;
- campaignSelect.add(campaignOption);
- rows.MoveNext();
- }
- rows.Close();
- invalidateCampaignReview();
- } catch (error) {
- document.getElementById("templateMessage").innerText = "Template list failed: " + error.message;
- } finally {
- if (db !== null && db.State === 1) db.Close();
- }
- }
- function runTemplateTool(scriptName, args) {
- var fs = new ActiveXObject("Scripting.FileSystemObject");
- var script = fs.BuildPath(projectRoot(), "tools\\" + scriptName);
- var command = quoted(powerShellHost()) + " -NoProfile -ExecutionPolicy Bypass -File " +
- quoted(script) + " " + args;
- var process = new ActiveXObject("WScript.Shell").Exec(command);
- var output = process.StdOut.ReadAll();
- var errors = process.StdErr.ReadAll();
- if (process.ExitCode !== 0) throw new Error((output + errors).replace(/^\s+|\s+$/g, ""));
- return output.replace(/^\s+|\s+$/g, "");
- }
- function importTemplate() {
- try {
- var path = document.getElementById("templatePath").value;
- if (!path || path.indexOf('"') !== -1) throw new Error("Select a template file");
- var result = runTemplateTool("import-template.ps1", "-Path " + quoted(path));
- document.getElementById("templateMessage").innerText = result;
- refreshTemplates();
- refreshStatus();
- } catch (error) {
- document.getElementById("templateMessage").innerText = "Import failed: " + error.message;
- }
- }
- function previewTemplate() {
- try {
- var id = document.getElementById("templateVersion").value;
- if (!/^[1-9][0-9]*$/.test(id)) throw new Error("Select an imported template");
- var file = runTemplateTool("preview-template.ps1", "-TemplateId " + id);
- document.getElementById("templatePreview").src = file;
- document.getElementById("templateMessage").innerText =
- "Showing the imported snapshot. This preview does not include the campaign footer yet.";
- } catch (error) {
- document.getElementById("templateMessage").innerText = "Preview failed: " + error.message;
- }
- }
- function refreshCampaigns() {
- var db = null;
- try {
- db = openDatabase().db;
- var rows = db.Execute("SELECT [Id],[Name],[Status] FROM [Campaign] ORDER BY [Id] DESC");
- var body = document.getElementById("campaignBody");
- while (body.firstChild) body.removeChild(body.firstChild);
- while (!rows.EOF) {
- var tr = document.createElement("tr");
- var values = [rows.Fields("Id").Value, rows.Fields("Name").Value,
- rows.Fields("Status").Value];
- for (var i = 0; i < values.length; i++) {
- var td = document.createElement("td");
- td.innerText = String(values[i]);
- tr.appendChild(td);
- }
- body.appendChild(tr);
- rows.MoveNext();
- }
- rows.Close();
- } catch (error) {
- document.getElementById("campaignMessage").innerText = "Campaign list failed: " + error.message;
- } finally {
- if (db !== null && db.State === 1) db.Close();
- }
- }
- function invalidateCampaignReview() {
- pendingCampaignReview = null;
- campaignTestAccepted = false;
- document.getElementById("sendCampaignTest").disabled = true;
- document.getElementById("approveCampaign").disabled = true;
- document.getElementById("confirmReceived").checked = false;
- document.getElementById("confirmReceived").disabled = true;
- document.getElementById("campaignReview").innerText = "";
- document.getElementById("campaignPreview").src = "about:blank";
- }
- function campaignRequest() {
- return {
- Name: document.getElementById("campaignName").value,
- Subject: document.getElementById("campaignSubject").value,
- TemplateId: document.getElementById("campaignTemplateVersion").value,
- ReviewToken: pendingCampaignReview ? pendingCampaignReview.Token : "",
- TestReceived: document.getElementById("confirmReceived").checked
- };
- }
- function withCampaignRequest(scriptName, extraArgs) {
- var fs = new ActiveXObject("Scripting.FileSystemObject");
- var folder = fs.BuildPath(projectRoot(), "temp");
- if (!fs.FolderExists(folder)) fs.CreateFolder(folder);
- var path = fs.BuildPath(folder, fs.GetTempName());
- var stream = new ActiveXObject("ADODB.Stream");
- try {
- stream.Type = 2;
- stream.Charset = "utf-8";
- stream.Open();
- stream.WriteText(JSON.stringify(campaignRequest()));
- stream.SaveToFile(path, 2);
- stream.Close();
- return runTemplateTool(scriptName, "-RequestPath " + quoted(path) + (extraArgs || ""));
- } finally {
- if (stream.State === 1) stream.Close();
- if (fs.FileExists(path)) fs.DeleteFile(path);
- }
- }
- function reviewCampaign() {
- invalidateCampaignReview();
- try {
- var data = JSON.parse(withCampaignRequest("review-campaign.ps1", ""));
- pendingCampaignReview = data;
- document.getElementById("campaignReview").innerText =
- data.Count + " eligible recipients. From: " + data.From + ". Reply-to: " +
- data.ReplyTo + ". Postal address: " + data.PostalAddress +
- ". Template: " + data.TemplateName + " v" + data.TemplateVersion +
- ". Subject: " + data.Subject + ".";
- document.getElementById("campaignPreview").src = data.PreviewPath;
- document.getElementById("sendCampaignTest").disabled = false;
- document.getElementById("campaignMessage").innerText =
- "Review the full message, then send it to the internal test inbox.";
- } catch (error) {
- document.getElementById("campaignMessage").innerText = "Review failed: " + error.message;
- }
- }
- function sendReviewedCampaignTest() {
- if (!pendingCampaignReview) return;
- if (!window.confirm("Send this campaign test to " + pendingCampaignReview.TestTo + "?")) return;
- try {
- var result = withCampaignRequest("send-campaign-test.ps1", " -Send");
- campaignTestAccepted = true;
- document.getElementById("confirmReceived").disabled = false;
- document.getElementById("campaignMessage").innerText = result;
- } catch (error) {
- document.getElementById("campaignMessage").innerText = "Campaign test failed: " + error.message;
- }
- }
- function updateApprovalButton() {
- document.getElementById("approveCampaign").disabled =
- !pendingCampaignReview || !campaignTestAccepted ||
- !document.getElementById("confirmReceived").checked;
- }
- function approveReviewedCampaign() {
- if (!pendingCampaignReview || !campaignTestAccepted ||
- !document.getElementById("confirmReceived").checked) return;
- if (!window.confirm("Approve " + pendingCampaignReview.Count +
- " recipients? The campaign will remain paused.")) return;
- try {
- var result = withCampaignRequest("approve-campaign.ps1", "");
- document.getElementById("campaignMessage").innerText = result;
- invalidateCampaignReview();
- refreshStatus();
- } catch (error) {
- document.getElementById("campaignMessage").innerText = "Approval failed: " + error.message;
- }
- }
- </script>
- </head>
- <body onload="refreshStatus()">
- <header><h1>MassMailer</h1><p>9 x 12 postcard marketing campaign workspace</p></header>
- <main>
- <div class="notice"><strong>Campaign sending is disabled in this build.</strong> The SMTP test sends one message only when you press its button.</div>
- <div class="cards">
- <div class="card">Contacts<span class="number" id="contacts">—</span></div>
- <div class="card">Suppressed<span class="number" id="suppressed">—</span></div>
- <div class="card">Templates<span class="number" id="templates">—</span></div>
- <div class="card">Campaigns<span class="number" id="campaigns">—</span></div>
- </div>
- <div class="details">
- <div><strong>Database</strong><span id="database">Checking…</span></div>
- <div><strong>Provider</strong><span id="provider">Checking…</span></div>
- <div><strong>Send interval</strong><span id="interval">Checking…</span></div>
- <div><strong>Internal test to</strong><span id="testTo">Checking…</span></div>
- <div><strong>Send state</strong>Disabled</div>
- <button onclick="refreshStatus()">Refresh status</button>
- <div id="error"></div>
- </div>
- <div class="panel">
- <h2>SMTP setup and internal test</h2>
- <p>The password entry opens a local console and stores a protected value in the MDB. The test sends one HTML message with an inline image to the configured test inbox.</p>
- <button onclick="configurePassword()">Set or rotate SMTP password</button>
- <button onclick="sendInternalTest()">Send one internal test</button>
- <div id="transportMessage"></div>
- </div>
- <div class="panel">
- <h2>Import business contacts</h2>
- <p>UTF-8 CSV needs an <code>email</code> header. Optional headers: <code>business_name</code>, <code>source_reference</code>, and <code>acquired_at</code> (YYYY-MM-DD). Every accepted row needs a source reference.</p>
- <label class="field">CSV file <input id="csvPath" type="file" accept=".csv" /></label>
- <label class="field">Source URL or reference for rows without one
- <input id="sourceFallback" type="text" maxlength="2048" /></label>
- <button onclick="previewContacts()">Preview import</button>
- <button id="commitImport" onclick="commitContacts()" disabled="disabled">Import ready contacts</button>
- <div id="importMessage"></div>
- <p id="previewCount"></p>
- <table><thead><tr><th>CSV row</th><th>Email</th><th>Business</th><th>Source</th><th>Result</th></tr></thead>
- <tbody id="previewBody"></tbody></table>
- </div>
- <div class="panel">
- <h2>HTML templates</h2>
- <p>Choose a well-formed HTML file inside the configured template folder. Images must use relative PNG, JPEG, or GIF paths. Imports create a new version and copy image bytes into the database.</p>
- <label class="field">Template file <input id="templatePath" type="file" accept=".html,.htm" /></label>
- <button onclick="importTemplate()">Import template version</button>
- <label class="field">Imported version <select id="templateVersion"></select></label>
- <button onclick="previewTemplate()">Preview selected version</button>
- <div id="templateMessage"></div>
- <iframe id="templatePreview" APPLICATION="no" title="Template preview"></iframe>
- </div>
- <div class="panel">
- <h2>Review and approve a campaign</h2>
- <p>Approval captures currently eligible contacts and the selected template version. It requires a complete postal address in config.ini, a campaign-specific internal test, and your confirmation that you received it. Approved campaigns stay paused until dispatch controls are built.</p>
- <label class="field">Campaign name <input id="campaignName" type="text" maxlength="200" oninput="invalidateCampaignReview()" /></label>
- <label class="field">Email subject <input id="campaignSubject" type="text" maxlength="240" oninput="invalidateCampaignReview()" /></label>
- <label class="field">Template version <select id="campaignTemplateVersion" onchange="invalidateCampaignReview()"></select></label>
- <button onclick="reviewCampaign()">Review message and recipients</button>
- <div id="campaignReview"></div>
- <iframe id="campaignPreview" APPLICATION="no" title="Full campaign preview"></iframe>
- <button id="sendCampaignTest" onclick="sendReviewedCampaignTest()" disabled="disabled">Send reviewed message to internal test inbox</button>
- <label class="field"><input id="confirmReceived" type="checkbox" disabled="disabled" onchange="updateApprovalButton()" style="display:inline;width:auto" /> I received and checked the campaign test message.</label>
- <button id="approveCampaign" onclick="approveReviewedCampaign()" disabled="disabled">Approve campaign (paused)</button>
- <div id="campaignMessage"></div>
- <table><thead><tr><th>ID</th><th>Campaign</th><th>Status</th></tr></thead><tbody id="campaignBody"></tbody></table>
- </div>
- <div class="panel">
- <h2>Suppress an address</h2>
- <p>Add unsubscribe replies here before the next send. Suppression applies across all campaigns.</p>
- <label class="field">Email address <input id="suppressEmail" type="text" maxlength="254" /></label>
- <label class="field">Reason <select id="suppressReason"><option value="opt-out">Opt-out reply</option><option value="manual">Manual</option><option value="bounce">Hard bounce</option><option value="complaint">Complaint</option></select></label>
- <label class="field">Evidence or note <input id="suppressEvidence" type="text" maxlength="2048" /></label>
- <button onclick="addSuppression()">Suppress address</button>
- <div id="suppressMessage"></div>
- </div>
- </main>
- </body>
- </html>
|