Changeset 834bcc3 in Klonkt for src/config/mailer.js
- Timestamp:
- 06/23/2026 06:14:27 PM (3 months ago)
- Branches:
- main
- Children:
- d774679
- Parents:
- bb42dfb
- File:
-
- 1 edited
-
src/config/mailer.js (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/config/mailer.js
rbb42dfb r834bcc3 1 // E-mail versturen (wachtwoord-reset, nieuwsbrief, notify). Optioneel: alleen actief2 // als SMTP is ingesteld — via Beheer → Instellingen (app_settings) OF env-vars.1 // Send email (password reset, newsletter, notify). Optional: only active 2 // when SMTP is configured — via Admin → Settings (app_settings) OR env vars. 3 3 // 4 // Config -bron (in deze volgorde): app_settings (ingesteld in de UI), andersenv:4 // Config source (in this order): app_settings (set via the UI), otherwise env: 5 5 // SMTP_HOST, SMTP_PORT (default 587), SMTP_USER, SMTP_PASS, SMTP_FROM (default = USER) 6 // N iet ingesteld → versturen valt terug op CLI (reset-admin) / wordt overgeslagen.6 // Not configured → sending falls back to CLI (reset-admin) / is skipped. 7 7 8 8 import nodemailer from 'nodemailer'; … … 23 23 } 24 24 25 // Status voor de UI (zonder het wachtwoord te lekken).25 // Status for the UI (without leaking the password). 26 26 export function mailerStatus() { 27 27 const c = cfg(); … … 33 33 from: c.from, 34 34 passSet: !!c.pass, 35 // bron: handig om te tonen dat env nog actief is35 // source: useful to show that env vars are still active 36 36 fromEnv: !getSetting('smtp_host', '') && !!process.env.SMTP_HOST, 37 37 }; 38 38 } 39 39 40 // Transport cachen, maar herbouwen zodra de config wijzigt (UI-edit zonder herstart).40 // Cache the transport, but rebuild it whenever the config changes (UI edit without restart). 41 41 let _transport = null, _key = null; 42 42 function transport() { … … 47 47 host: c.host, 48 48 port: c.port, 49 secure: c.port === 465, // 465 = implici eteTLS; 587 = STARTTLS49 secure: c.port === 465, // 465 = implicit TLS; 587 = STARTTLS 50 50 auth: { user: c.user, pass: c.pass }, 51 51 }); … … 56 56 57 57 export async function sendMail({ to, subject, text, html }) { 58 if (!mailerConfigured()) throw new Error('SMTP n iet geconfigureerd');58 if (!mailerConfigured()) throw new Error('SMTP not configured'); 59 59 const c = cfg(); 60 60 return transport().sendMail({ from: c.from, to, subject, text, html });
Note:
See TracChangeset
for help on using the changeset viewer.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)