import nodemailer from "nodemailer"; const host = process.env.SMTP_HOST; const port = parseInt(process.env.SMTP_PORT || "25", 10); const user = process.env.SMTP_USER; const pass = process.env.SMTP_PASS; const from = process.env.SMTP_FROM || "JobsBoard "; const to = process.env.SMTP_TEST_TO || user; if (!host || !user || !pass) { console.error("Missing SMTP_HOST / SMTP_USER / SMTP_PASS in the environment."); process.exit(1); } const transporter = nodemailer.createTransport({ host, port, secure: port === 465 || port === 10465, requireTLS: true, auth: { user, pass }, // Local relays such as Proton Mail Bridge present self-signed certs. tls: { rejectUnauthorized: false }, }); try { const info = await transporter.sendMail({ from, to, subject: "JobsBoard SMTP relay test", text: "If you received this, the Proton Mail Bridge SMTP relay is working.", html: "

If you received this, the Proton Mail Bridge SMTP relay is working.

", }); console.log("SMTP test email sent:", info.messageId); process.exit(0); } catch (err) { console.error("SMTP test failed:", err.message); process.exit(1); }