summaryrefslogtreecommitdiff
path: root/website/src/actions/sendmail.ts
diff options
context:
space:
mode:
authorJoe Carstairs <me@joeac.net>2026-01-08 21:13:38 +0000
committerJoe Carstairs <me@joeac.net>2026-01-08 21:13:38 +0000
commit48ca4c2a03df35b8d5d7555ac1f288f3daabc890 (patch)
tree90100b81e7f29136420b68d7850924cc0c5ea946 /website/src/actions/sendmail.ts
parentbde6f2a25328dd3d48afe9f67a961a323b0e6221 (diff)
fixes SMTP client config in website
Diffstat (limited to 'website/src/actions/sendmail.ts')
-rw-r--r--website/src/actions/sendmail.ts28
1 files changed, 15 insertions, 13 deletions
diff --git a/website/src/actions/sendmail.ts b/website/src/actions/sendmail.ts
index bb7d2eb..d68ec95 100644
--- a/website/src/actions/sendmail.ts
+++ b/website/src/actions/sendmail.ts
@@ -3,11 +3,12 @@ import { defineAction } from "astro:actions";
import nodemailer from "nodemailer";
import {
MAX_DAILY_EMAILS,
- SMTP_HOST,
- SMTP_PASSWORD,
- SMTP_PORT,
- SMTP_USE_TLS,
- SMTP_USER,
+ LOCAL_SMTP_HOST,
+ LOCAL_SMTP_PASSWORD,
+ LOCAL_SMTP_PORT,
+ LOCAL_SMTP_USER,
+ CONTACT_MAILBOX,
+ LOCAL_SMTP_ENVELOPE_FROM,
} from "astro:env/server";
import { and, db, eq, gte, SendmailToken, SentEmails } from "astro:db";
@@ -66,9 +67,9 @@ async function sendmail({
}
const info = await transporter.sendMail({
- from: `"Joe Carstairs" <me@joeac.net>`,
- to: `"Joe Carstairs" <me@joeac.net>`,
- subject: "joeac.net: a visitor left a message",
+ from: LOCAL_SMTP_ENVELOPE_FROM,
+ to: CONTACT_MAILBOX,
+ subject: `joeac.net: ${name} left a message`,
text: `${name} <${email}> sent you a message:\n\n\n${message}`,
});
await db
@@ -78,14 +79,15 @@ async function sendmail({
console.log("Sent an email to Joe. Message ID: ", info.messageId);
}
-const transporter = nodemailer.createTransport({
- host: SMTP_HOST,
- port: SMTP_PORT,
+export const transporter = nodemailer.createTransport({
+ host: LOCAL_SMTP_HOST,
+ from: LOCAL_SMTP_ENVELOPE_FROM,
+ port: LOCAL_SMTP_PORT,
secure: false,
authMethod: "PLAIN",
auth: {
type: "login",
- user: SMTP_USER,
- pass: SMTP_PASSWORD,
+ user: LOCAL_SMTP_USER,
+ pass: LOCAL_SMTP_PASSWORD,
},
});