Ignore:
Timestamp:
06/19/2026 08:29:28 AM (3 months ago)
Author:
roboburr <roboburr@…>
Branches:
main
Children:
7eb35ae
Parents:
977f65d
Message:

feat: SMTP configurable via Admin → Settings (app_settings, env fallback) + test email

  • config/mailer.js: reads SMTP from app_settings (smtp_host/port/user/pass/from), with env as fallback; transport rebuilds automatically on change (no restart needed); mailerStatus() for the UI (without leaking the password).
  • admin-settings: POST /smtp (save; password only updated when a new value is given; clear) + POST /smtp/test (test email). GET includes smtp status.
  • admin-settings.ejs: Email (SMTP) card with host/port/user/pass/from + save/ clear + test-email button (only shown when configured).

Once SMTP is filled in, newsletter sending, show-notify and double opt-in work.

Co-Authored-By: Claude <noreply@…>

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/views/pages/admin-settings.ejs

    r977f65d rca507ef  
    110110    <% if (typeof premiumEnabled !== 'undefined' && premiumEnabled && !(premium && premium.premium)) { %>
    111111      <p class="set-help" style="margin-top:.7rem; color:var(--accent)">Premium-laag staat aan zonder Patreon — de Google-knop blijft verborgen tot premium ontgrendeld is.</p>
     112    <% } %>
     113  </section>
     114
     115  <%# E-mail / SMTP — nodig voor nieuwsbrief versturen, notify-mails en wachtwoord-reset. %>
     116  <section class="set-card" style="margin-top:1rem">
     117    <h2>E-mail (SMTP)</h2>
     118    <p class="set-help">Nodig om de <strong>nieuwsbrief te versturen</strong>, <strong>show-notify</strong>-mails te sturen en wachtwoord-reset per mail te laten werken. Vul de gegevens van je mailprovider in (bv. je hostingmail, Gmail-app-wachtwoord, Brevo, Mailgun…).
     119      <% if (smtp && smtp.configured) { %><br><strong>Status: ingesteld&nbsp;✓</strong><% if (smtp.fromEnv) { %> <small>(via .env)</small><% } %><% } else { %><br>Nog niet ingesteld — versturen werkt nog niet.<% } %></p>
     120
     121    <form method="post" action="/admin/settings/smtp" class="set-form">
     122      <label><span>SMTP-host</span>
     123        <input type="text" name="smtp_host" value="<%= smtp ? smtp.host : '' %>" placeholder="smtp.jouwprovider.nl" autocomplete="off">
     124      </label>
     125      <label><span>Poort <small style="font-weight:400">— 587 (STARTTLS) of 465 (SSL)</small></span>
     126        <input type="text" name="smtp_port" value="<%= (smtp && smtp.port) ? smtp.port : '' %>" placeholder="587" autocomplete="off" inputmode="numeric">
     127      </label>
     128      <label><span>Gebruikersnaam</span>
     129        <input type="text" name="smtp_user" value="<%= smtp ? smtp.user : '' %>" placeholder="jij@jouwprovider.nl" autocomplete="off">
     130      </label>
     131      <label><span>Wachtwoord <% if (smtp && smtp.passSet) { %><small style="font-weight:400">— ingesteld; leeg laten = ongewijzigd</small><% } %></span>
     132        <input type="password" name="smtp_pass" placeholder="<%= (smtp && smtp.passSet) ? '•••••••• (ingesteld)' : 'app-wachtwoord' %>" autocomplete="off">
     133      </label>
     134      <label><span>Afzender <small style="font-weight:400">— optioneel; standaard = gebruikersnaam</small></span>
     135        <input type="text" name="smtp_from" value="<%= smtp ? smtp.from : '' %>" placeholder="Jouw Naam &lt;jij@jouwprovider.nl&gt;" autocomplete="off">
     136      </label>
     137      <div class="set-actions">
     138        <button type="submit" class="btn btn-primary">SMTP opslaan</button>
     139        <% if (smtp && (smtp.host || smtp.passSet)) { %>
     140          <button type="submit" name="clear" value="1" class="btn" formnovalidate>Wissen</button>
     141        <% } %>
     142      </div>
     143    </form>
     144
     145    <% if (smtp && smtp.configured) { %>
     146      <form method="post" action="/admin/settings/smtp/test" class="set-form" style="margin-top:.8rem">
     147        <label><span>Testmail sturen naar</span>
     148          <input type="email" name="to" placeholder="jij@email.nl" autocomplete="off">
     149        </label>
     150        <div class="set-actions"><button type="submit" class="btn">✉ Testmail sturen</button></div>
     151      </form>
    112152    <% } %>
    113153  </section>
Note: See TracChangeset for help on using the changeset viewer.