feat: add SMTP auth support for K3s migration
All checks were successful
Build & Deploy to Staging / Build & Deploy to Staging (push) Successful in 11m3s
Promote to Production / Deploy to Production (push) Successful in 3m23s

- Support SMTP_USER/SMTP_PASS env vars for authenticated SMTP
- Support SMTP_FROM env var for configurable sender address
- Auto-detect secure mode for port 465
- Backwards compatible: falls back to unauthenticated local relay
This commit is contained in:
OpenClaw Deployer 2026-02-18 12:47:33 +00:00
parent 02b2408772
commit 0902e1e437
9 changed files with 148 additions and 129 deletions

View file

@ -1,20 +1,33 @@
import nodemailer from "nodemailer";
import logger from "./logger.js";
const transporter = nodemailer.createTransport({
host: process.env.SMTP_HOST || "host.docker.internal",
port: Number(process.env.SMTP_PORT || 25),
secure: false,
const smtpUser = process.env.SMTP_USER;
const smtpPass = process.env.SMTP_PASS;
const smtpHost = process.env.SMTP_HOST || "host.docker.internal";
const smtpPort = Number(process.env.SMTP_PORT || 25);
const smtpFrom = process.env.SMTP_FROM || "DocFast <noreply@docfast.dev>";
const smtpSecure = smtpPort === 465;
const transportConfig: any = {
host: smtpHost,
port: smtpPort,
secure: smtpSecure,
connectionTimeout: 5000,
greetingTimeout: 5000,
socketTimeout: 10000,
tls: { rejectUnauthorized: false },
});
};
if (smtpUser && smtpPass) {
transportConfig.auth = { user: smtpUser, pass: smtpPass };
}
const transporter = nodemailer.createTransport(transportConfig);
export async function sendVerificationEmail(email: string, code: string): Promise<boolean> {
try {
const info = await transporter.sendMail({
from: "DocFast <noreply@docfast.dev>",
from: smtpFrom,
to: email,
subject: "DocFast - Verify your email",
text: `Your DocFast verification code is: ${code}\n\nThis code expires in 15 minutes.\n\nIf you didn't request this, ignore this email.`,