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

@ -54,7 +54,7 @@ app.use(compression());
app.use((req, res, next) => {
const isAuthBillingRoute = req.path.startsWith('/v1/signup') ||
req.path.startsWith('/v1/recover') ||
req.path.startsWith('/v1/billing') ||
req.path.startsWith('/v1/billing');
if (isAuthBillingRoute) {
res.setHeader("Access-Control-Allow-Origin", "https://docfast.dev");
@ -184,12 +184,17 @@ app.get("/favicon.ico", (_req, res) => {
res.sendFile(path.join(__dirname, "../public/favicon.svg"));
});
app.use(express.static(path.join(__dirname, "../public"), {
maxAge: "1d",
etag: true,
setHeaders: (res) => {
res.setHeader('Cache-Control', 'public, max-age=86400');
// Static asset cache headers middleware
app.use((req, res, next) => {
if (/\.(css|js|png|jpg|jpeg|gif|ico|svg|woff|woff2|ttf|eot)$/.test(req.path)) { console.log("CACHE HIT:", req.path);
res.setHeader('Cache-Control', 'public, max-age=604800, immutable');
}
next();
});
app.use(express.static(path.join(__dirname, "../public"), {
etag: true,
cacheControl: false,
}));
// Docs page (clean URL)

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.`,