{"id":86,"date":"2026-04-13T18:05:48","date_gmt":"2026-04-13T18:05:48","guid":{"rendered":"https:\/\/cashchat.se\/dir\/?page_id=86"},"modified":"2026-04-13T18:05:48","modified_gmt":"2026-04-13T18:05:48","slug":"subscribe","status":"publish","type":"page","link":"https:\/\/cashchat.se\/dir\/subscribe\/","title":{"rendered":"Subscribe"},"content":{"rendered":"\n<!DOCTYPE html>\n<html lang=\"en\">\n<head>\n  <meta charset=\"UTF-8\">\n  <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0, user-scalable=yes\">\n  <title>Mailing List Manager | Secure Bulk Email Platform<\/title>\n  <!-- Bootstrap 5 + Icons + Fonts -->\n  <link href=\"https:\/\/cdn.jsdelivr.net\/npm\/bootstrap@5.3.0-alpha1\/dist\/css\/bootstrap.min.css\" rel=\"stylesheet\">\n  <link rel=\"stylesheet\" href=\"https:\/\/cdnjs.cloudflare.com\/ajax\/libs\/font-awesome\/6.0.0-beta3\/css\/all.min.css\">\n  <style>\n    body {\n      background: #f4f7fc;\n      font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto;\n    }\n    .card-shadow {\n      border-radius: 1.25rem;\n      box-shadow: 0 12px 28px rgba(0,0,0,0.05), 0 0 1px rgba(0,0,0,0.1);\n      transition: all 0.2s ease;\n    }\n    .admin-card {\n      background: white;\n      border: none;\n    }\n    .login-overlay {\n      background: rgba(0,0,0,0.03);\n    }\n    .table-responsive-custom {\n      overflow-x: auto;\n    }\n    .btn-sm-rounded {\n      border-radius: 40px;\n    }\n    footer {\n      font-size: 0.85rem;\n      border-top: 1px solid #dee2e6;\n    }\n    .spam-safe-badge {\n      background: #e3f7ec;\n      color: #1e7b48;\n      font-size: 0.75rem;\n      font-weight: 500;\n    }\n    @media (max-width: 768px) {\n      .container { padding-left: 1rem; padding-right: 1rem; }\n      h1 { font-size: 1.8rem; }\n    }\n  <\/style>\n<\/head>\n<body>\n\n<div class=\"container py-4 py-md-5\">\n  <!-- Header & Brand -->\n  <div class=\"d-flex flex-wrap justify-content-between align-items-center mb-4\">\n    <div>\n      <h1 class=\"display-6 fw-bold\"><i class=\"fas fa-envelope-open-text text-primary me-2\"><\/i>MailFlow<span class=\"fw-light\"> Manager<\/span><\/h1>\n      <p class=\"text-muted\">GDPR-ready \u2022 Smart delivery \u2022 Never-spam architecture<\/p>\n    <\/div>\n    <div>\n      <span class=\"badge spam-safe-badge p-2\"><i class=\"fas fa-shield-alt me-1\"><\/i> SPF\/DKIM ready | Anti-spam headers<\/span>\n    <\/div>\n  <\/div>\n\n  <!-- Public Subscription & Unsubscribe Cards (visible always) -->\n  <div class=\"row g-4 mb-5\">\n    <div class=\"col-md-6\">\n      <div class=\"card card-shadow h-100 border-0\">\n        <div class=\"card-body p-4\">\n          <h4 class=\"card-title\"><i class=\"fas fa-user-plus text-success me-2\"><\/i>Join Newsletter<\/h4>\n          <p class=\"card-text text-secondary\">Get updates &#038; offers. No spam, unsubscribe anytime.<\/p>\n          <form id=\"subscribeForm\">\n            <div class=\"mb-3\">\n              <label class=\"form-label\">Email address<\/label>\n              <input type=\"email\" class=\"form-control\" id=\"subEmail\" placeholder=\"name@example.com\" required>\n            <\/div>\n            <div class=\"mb-3\">\n              <label class=\"form-label\">Full name (optional)<\/label>\n              <input type=\"text\" class=\"form-control\" id=\"subName\" placeholder=\"Alex Johnson\">\n            <\/div>\n            <button type=\"submit\" class=\"btn btn-success w-100\"><i class=\"fas fa-bell me-2\"><\/i>Subscribe<\/button>\n          <\/form>\n          <div id=\"subMsg\" class=\"mt-3 small\"><\/div>\n        <\/div>\n      <\/div>\n    <\/div>\n    <div class=\"col-md-6\">\n      <div class=\"card card-shadow h-100 border-0\">\n        <div class=\"card-body p-4\">\n          <h4 class=\"card-title\"><i class=\"fas fa-user-slash text-danger me-2\"><\/i>Unsubscribe instantly<\/h4>\n          <p class=\"card-text text-secondary\">Remove your email from our records immediately.<\/p>\n          <form id=\"unsubPublicForm\">\n            <div class=\"mb-3\">\n              <label class=\"form-label\">Email to unsubscribe<\/label>\n              <input type=\"email\" class=\"form-control\" id=\"unsubEmail\" placeholder=\"member@example.com\" required>\n            <\/div>\n            <button type=\"submit\" class=\"btn btn-outline-danger w-100\"><i class=\"fas fa-trash-alt me-2\"><\/i>Unsubscribe<\/button>\n          <\/form>\n          <div id=\"unsubMsg\" class=\"mt-3 small\"><\/div>\n        <\/div>\n      <\/div>\n    <\/div>\n  <\/div>\n\n  <!-- Admin Section: Hidden until login using specific credentials -->\n  <div id=\"adminSection\" style=\"display: none;\">\n    <div class=\"d-flex justify-content-between align-items-center mb-3 flex-wrap\">\n      <h3 class=\"fw-semibold\"><i class=\"fas fa-lock-open me-2 text-warning\"><\/i>Admin Dashboard \u2013 Community Hub<\/h3>\n      <button id=\"logoutBtn\" class=\"btn btn-sm btn-outline-secondary\"><i class=\"fas fa-sign-out-alt me-1\"><\/i>Logout<\/button>\n    <\/div>\n    <!-- Tabs \/ Action row -->\n    <div class=\"row g-4\">\n      <!-- Left: Contact management -->\n      <div class=\"col-lg-8\">\n        <div class=\"card card-shadow admin-card mb-4\">\n          <div class=\"card-header bg-white border-0 pt-4 pb-0\">\n            <h5><i class=\"fas fa-users me-2\"><\/i>Community Members (<span id=\"contactCount\">0<\/span>)<\/h5>\n            <hr class=\"mt-2\">\n          <\/div>\n          <div class=\"card-body\">\n            <div class=\"d-flex flex-wrap gap-2 mb-3\">\n              <input type=\"file\" id=\"csvUpload\" accept=\".csv\" class=\"form-control w-auto d-inline-block\" style=\"max-width: 260px;\">\n              <button id=\"uploadCsvBtn\" class=\"btn btn-sm btn-primary\"><i class=\"fas fa-upload\"><\/i> Upload CSV<\/button>\n              <button id=\"downloadExcelBtn\" class=\"btn btn-sm btn-success\"><i class=\"fas fa-file-excel\"><\/i> Excel<\/button>\n              <button id=\"downloadPdfBtn\" class=\"btn btn-sm btn-danger\"><i class=\"fas fa-file-pdf\"><\/i> PDF<\/button>\n            <\/div>\n            <div class=\"table-responsive-custom\">\n              <table class=\"table table-hover align-middle\" id=\"contactsTable\">\n                <thead class=\"table-light\">\n                  <tr><th>#<\/th><th>Email<\/th><th>Name<\/th><th>Joined (Date)<\/th><th>Action<\/th><\/tr>\n                <\/thead>\n                <tbody id=\"contactsTbody\">\n                  <tr><td colspan=\"5\" class=\"text-center text-muted\">Loading contacts&#8230;<\/td><\/tr>\n                <\/tbody>\n              <\/table>\n            <\/div>\n          <\/div>\n        <\/div>\n      <\/div>\n      <!-- Right: Email sender + best practices -->\n      <div class=\"col-lg-4\">\n        <div class=\"card card-shadow admin-card mb-4\">\n          <div class=\"card-body\">\n            <h5><i class=\"fas fa-paper-plane me-2 text-primary\"><\/i>Broadcast Email<\/h5>\n            <p class=\"small text-muted\">Sends to ALL community members. Includes unsubscribe link &#038; spam-safe headers.<\/p>\n            <form id=\"sendEmailForm\">\n              <div class=\"mb-2\">\n                <label class=\"form-label\">Subject<\/label>\n                <input type=\"text\" id=\"emailSubject\" class=\"form-control\" placeholder=\"Amazing update...\" required>\n              <\/div>\n              <div class=\"mb-2\">\n                <label class=\"form-label\">Message (HTML supported)<\/label>\n                <textarea id=\"emailBody\" rows=\"5\" class=\"form-control\" placeholder=\"<p>Hello {name}, here&#8217;s your content&#8230;<\/p>&#8221; required><\/textarea>\n                <div class=\"form-text\">Use <code>{name}<\/code> to personalize. Unsubscribe link auto-injected.<\/div>\n              <\/div>\n              <button type=\"submit\" class=\"btn btn-dark w-100 mt-2\"><i class=\"fas fa-envelope\"><\/i> Send Campaign<\/button>\n            <\/form>\n            <div id=\"sendStatus\" class=\"mt-2 small fw-semibold\"><\/div>\n          <\/div>\n        <\/div>\n        <div class=\"card card-shadow bg-light border-0\">\n          <div class=\"card-body\">\n            <i class=\"fas fa-chart-line me-1\"><\/i> <strong>Anti-spam Guarantee<\/strong>\n            <ul class=\"small mt-2 ps-3 mb-0\">\n              <li>\u2714 List-Unsubscribe header + one-click link<\/li>\n              <li>\u2714 DKIM\/SPF ready (configure SMTP)<\/li>\n              <li>\u2714 Personalization &#038; plain-text fallback<\/li>\n              <li>\u2714 Permission-based (opt-in only)<\/li>\n            <\/ul>\n          <\/div>\n        <\/div>\n      <\/div>\n    <\/div>\n  <\/div>\n\n  <!-- Login Card (initially visible, hidden after admin login) -->\n  <div id=\"loginCard\" class=\"row justify-content-center mt-4\">\n    <div class=\"col-md-6 col-lg-5\">\n      <div class=\"card card-shadow border-0\">\n        <div class=\"card-body p-4\">\n          <div class=\"text-center mb-3\"><i class=\"fas fa-user-shield fa-2x text-secondary\"><\/i><\/div>\n          <h5 class=\"text-center fw-semibold\">Administrator Access<\/h5>\n          <p class=\"text-center text-muted small\">Restricted area \u2014 data section hidden<\/p>\n          <form id=\"adminLoginForm\">\n            <div class=\"mb-3\">\n              <label class=\"form-label\">Email<\/label>\n              <input type=\"email\" class=\"form-control\" id=\"loginEmail\" value=\"adaseltd@gmail.com\" readonly disabled>\n              <input type=\"hidden\" id=\"loginEmailHidden\" value=\"adaseltd@gmail.com\">\n            <\/div>\n            <div class=\"mb-3\">\n              <label class=\"form-label\">Password<\/label>\n              <input type=\"password\" class=\"form-control\" id=\"loginPassword\" placeholder=\"\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022\">\n            <\/div>\n            <button type=\"submit\" class=\"btn btn-primary w-100\"><i class=\"fas fa-key me-2\"><\/i>Unlock Dashboard<\/button>\n            <div id=\"loginError\" class=\"text-danger small mt-2 text-center\"><\/div>\n          <\/form>\n        <\/div>\n      <\/div>\n    <\/div>\n  <\/div>\n<\/div>\n\n<footer class=\"text-center text-muted py-4 mt-3\">\n  <small>\u00a9 MailFlow Manager \u2014 authenticated mailing list. All emails include unsubscribe mechanism. No spam tolerance.<\/small>\n<\/footer>\n\n<script src=\"https:\/\/cdn.jsdelivr.net\/npm\/bootstrap@5.3.0-alpha1\/dist\/js\/bootstrap.bundle.min.js\"><\/script>\n<script>\n  \/\/ ---------- Frontend logic ----------\n  let isAdmin = false;\n\n  \/\/ DOM elements\n  const loginCard = document.getElementById('loginCard');\n  const adminSection = document.getElementById('adminSection');\n  const loginForm = document.getElementById('adminLoginForm');\n  const loginErrorSpan = document.getElementById('loginError');\n  const logoutBtn = document.getElementById('logoutBtn');\n  const subscribeForm = document.getElementById('subscribeForm');\n  const unsubPublicForm = document.getElementById('unsubPublicForm');\n  const contactsTbody = document.getElementById('contactsTbody');\n  const contactCountSpan = document.getElementById('contactCount');\n  const uploadCsvBtn = document.getElementById('uploadCsvBtn');\n  const csvFileInput = document.getElementById('csvUpload');\n  const downloadExcelBtn = document.getElementById('downloadExcelBtn');\n  const downloadPdfBtn = document.getElementById('downloadPdfBtn');\n  const sendEmailForm = document.getElementById('sendEmailForm');\n  const sendStatusDiv = document.getElementById('sendStatus');\n\n  \/\/ Helper toast-like alerts\n  function showMsg(element, msg, isError = false) {\n    if(element) {\n      element.innerHTML = `<div class=\"alert alert-${isError ? 'danger' : 'success'} alert-dismissible fade show py-2 mt-2\" role=\"alert\">${msg}<button type=\"button\" class=\"btn-close btn-sm\" data-bs-dismiss=\"alert\"><\/button><\/div>`;\n      setTimeout(() => { if(element.innerHTML) element.innerHTML = ''; }, 4000);\n    }\n  }\n\n  \/\/ check session status\n  async function checkAuth() {\n    try {\n      const res = await fetch('\/api\/check-auth', { credentials: 'include' });\n      const data = await res.json();\n      if (data.authenticated) {\n        isAdmin = true;\n        loginCard.style.display = 'none';\n        adminSection.style.display = 'block';\n        loadContacts();\n      } else {\n        isAdmin = false;\n        loginCard.style.display = 'block';\n        adminSection.style.display = 'none';\n      }\n    } catch(e) { console.error(e); }\n  }\n\n  \/\/ load contacts for admin table\n  async function loadContacts() {\n    if(!isAdmin) return;\n    try {\n      const res = await fetch('\/api\/contacts', { credentials: 'include' });\n      if(res.status === 401) { logout(); return; }\n      const contacts = await res.json();\n      contactCountSpan.innerText = contacts.length;\n      if(contacts.length === 0) {\n        contactsTbody.innerHTML = '<tr><td colspan=\"5\" class=\"text-center text-muted\">No members yet. Upload CSV or use subscription form.<\/td><\/tr>';\n        return;\n      }\n      let html = '';\n      contacts.forEach((c, idx) => {\n        const joinDate = c.createdAt ? new Date(c.createdAt).toLocaleDateString() : 'Unknown';\n        html += `<tr>\n          <td>${idx+1}<\/td>\n          <td>${escapeHtml(c.email)}<\/td>\n          <td>${escapeHtml(c.name || '\u2014')}<\/td>\n          <td>${joinDate}<\/td>\n          <td><button class=\"btn btn-sm btn-outline-danger remove-contact\" data-id=\"${c.id}\"><i class=\"fas fa-user-minus\"><\/i> Unsub<\/button><\/td>\n        <\/tr>`;\n      });\n      contactsTbody.innerHTML = html;\n      document.querySelectorAll('.remove-contact').forEach(btn => {\n        btn.addEventListener('click', async (e) => {\n          const id = btn.getAttribute('data-id');\n          if(confirm('Remove this contact from mailing list?')) {\n            await fetch(`\/api\/contacts\/${id}`, { method: 'DELETE', credentials: 'include' });\n            loadContacts();\n          }\n        });\n      });\n    } catch(err) { console.error(err); contactsTbody.innerHTML = '<tr><td colspan=\"5\" class=\"text-danger\">Error loading contacts<\/td><\/tr>'; }\n  }\n\n  function escapeHtml(str) { if(!str) return ''; return str.replace(\/[&<>]\/g, function(m){if(m==='&') return '&amp;'; if(m==='<') return '&lt;'; if(m==='>') return '&gt;'; return m;});}\n\n  \/\/ login\n  loginForm.addEventListener('submit', async (e) => {\n    e.preventDefault();\n    const email = 'adaseltd@gmail.com';\n    const password = document.getElementById('loginPassword').value;\n    try {\n      const res = await fetch('\/api\/login', {\n        method: 'POST',\n        headers: { 'Content-Type': 'application\/json' },\n        body: JSON.stringify({ email, password }),\n        credentials: 'include'\n      });\n      const data = await res.json();\n      if(data.success) {\n        isAdmin = true;\n        loginCard.style.display = 'none';\n        adminSection.style.display = 'block';\n        loadContacts();\n      } else {\n        loginErrorSpan.innerText = 'Invalid credentials. Access denied.';\n      }\n    } catch(err) { loginErrorSpan.innerText = 'Server error'; }\n  });\n\n  async function logout() {\n    await fetch('\/api\/logout', { method: 'POST', credentials: 'include' });\n    isAdmin = false;\n    loginCard.style.display = 'block';\n    adminSection.style.display = 'none';\n    document.getElementById('loginPassword').value = '';\n    loginErrorSpan.innerText = '';\n  }\n  logoutBtn.addEventListener('click', logout);\n\n  \/\/ public subscribe\n  subscribeForm.addEventListener('submit', async (e) => {\n    e.preventDefault();\n    const email = document.getElementById('subEmail').value.trim();\n    const name = document.getElementById('subName').value.trim();\n    if(!email) return;\n    try {\n      const res = await fetch('\/api\/subscribe', {\n        method: 'POST',\n        headers: { 'Content-Type': 'application\/json' },\n        body: JSON.stringify({ email, name }),\n        credentials: 'include'\n      });\n      const data = await res.json();\n      const msgDiv = document.getElementById('subMsg');\n      if(res.ok) showMsg(msgDiv, data.message || 'Subscribed successfully!', false);\n      else showMsg(msgDiv, data.error || 'Subscription failed', true);\n      document.getElementById('subEmail').value = '';\n      document.getElementById('subName').value = '';\n      if(isAdmin) loadContacts();\n    } catch(e) { showMsg(document.getElementById('subMsg'), 'Network error', true); }\n  });\n\n  \/\/ public unsubscribe\n  unsubPublicForm.addEventListener('submit', async (e) => {\n    e.preventDefault();\n    const email = document.getElementById('unsubEmail').value.trim();\n    if(!email) return;\n    try {\n      const res = await fetch('\/api\/unsubscribe', {\n        method: 'POST',\n        headers: { 'Content-Type': 'application\/json' },\n        body: JSON.stringify({ email }),\n        credentials: 'include'\n      });\n      const data = await res.json();\n      const msgDiv = document.getElementById('unsubMsg');\n      if(res.ok) showMsg(msgDiv, data.message || 'Removed from list.', false);\n      else showMsg(msgDiv, data.error || 'Email not found', true);\n      document.getElementById('unsubEmail').value = '';\n      if(isAdmin) loadContacts();\n    } catch(e) { showMsg(document.getElementById('unsubMsg'), 'Error', true); }\n  });\n\n  \/\/ upload CSV\n  uploadCsvBtn.addEventListener('click', async () => {\n    const file = csvFileInput.files[0];\n    if(!file) { alert('Please select a CSV file'); return; }\n    const formData = new FormData();\n    formData.append('csvfile', file);\n    try {\n      const res = await fetch('\/api\/contacts\/upload', { method: 'POST', body: formData, credentials: 'include' });\n      const data = await res.json();\n      if(res.ok) { alert(`Uploaded: ${data.added} new members`); loadContacts(); }\n      else alert(data.error || 'Upload failed');\n    } catch(e) { alert('Upload error'); }\n    csvFileInput.value = '';\n  });\n\n  \/\/ download excel\n  downloadExcelBtn.addEventListener('click', async () => {\n    window.open('\/api\/download\/contacts\/excel', '_blank');\n  });\n  downloadPdfBtn.addEventListener('click', async () => {\n    window.open('\/api\/download\/contacts\/pdf', '_blank');\n  });\n\n  \/\/ send email campaign\n  sendEmailForm.addEventListener('submit', async (e) => {\n    e.preventDefault();\n    const subject = document.getElementById('emailSubject').value.trim();\n    const htmlContent = document.getElementById('emailBody').value;\n    if(!subject || !htmlContent) { alert('Subject and message required'); return; }\n    sendStatusDiv.innerHTML = '<span class=\"text-info\"><i class=\"fas fa-spinner fa-pulse\"><\/i> Sending emails...<\/span>';\n    try {\n      const res = await fetch('\/api\/send-email', {\n        method: 'POST',\n        headers: { 'Content-Type': 'application\/json' },\n        body: JSON.stringify({ subject, htmlContent }),\n        credentials: 'include'\n      });\n      const data = await res.json();\n      if(res.ok) sendStatusDiv.innerHTML = `<span class=\"text-success\">\u2705 ${data.message} (${data.sentCount} sent)<\/span>`;\n      else sendStatusDiv.innerHTML = `<span class=\"text-danger\">\u274c ${data.error}<\/span>`;\n    } catch(e) { sendStatusDiv.innerHTML = `<span class=\"text-danger\">Network error<\/span>`; }\n    setTimeout(()=>{ sendStatusDiv.innerHTML = ''; }, 5000);\n  });\n\n  \/\/ init session check & reload contacts on admin visible\n  checkAuth();\n  setInterval(() => { if(isAdmin) loadContacts(); }, 30000);\n<\/script>\n<\/body>\n<\/html>\n\n<!-- BACKEND (Node.js + Express) -->\n<!-- To run this full app, save as server.js and run: npm install express express-session multer csv-parser nodemailer exceljs pdfkit fs-extra -->\n<!-- Ensure you have proper SMTP settings for real email sending (configure .env) -->\n<script type=\"text\/javascript\">\n\/\/ This is a meta backend section. The actual backend code is below in the final answer's full implementation.\n\/\/ In the final answer the full server code will be included.\n<\/script>\n","protected":false},"excerpt":{"rendered":"<p>Mailing List Manager | Secure Bulk Email Platform MailFlow Manager GDPR-ready \u2022 Smart delivery \u2022 Never-spam architecture SPF\/DKIM ready | Anti-spam headers Join Newsletter Get updates &#038; offers. No spam, unsubscribe anytime. Email address Full name (optional) Subscribe Unsubscribe instantly Remove your email from our records immediately. Email to unsubscribe Unsubscribe Admin Dashboard \u2013 Community [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"pagelayer_contact_templates":[],"_pagelayer_content":"","footnotes":""},"class_list":["post-86","page","type-page","status-publish","hentry"],"_links":{"self":[{"href":"https:\/\/cashchat.se\/dir\/wp-json\/wp\/v2\/pages\/86","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/cashchat.se\/dir\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/cashchat.se\/dir\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/cashchat.se\/dir\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/cashchat.se\/dir\/wp-json\/wp\/v2\/comments?post=86"}],"version-history":[{"count":1,"href":"https:\/\/cashchat.se\/dir\/wp-json\/wp\/v2\/pages\/86\/revisions"}],"predecessor-version":[{"id":87,"href":"https:\/\/cashchat.se\/dir\/wp-json\/wp\/v2\/pages\/86\/revisions\/87"}],"wp:attachment":[{"href":"https:\/\/cashchat.se\/dir\/wp-json\/wp\/v2\/media?parent=86"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}