summaryrefslogtreecommitdiff
path: root/website/src/actions
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
parentbde6f2a25328dd3d48afe9f67a961a323b0e6221 (diff)
fixes SMTP client config in website
Diffstat (limited to 'website/src/actions')
-rw-r--r--website/src/actions/otp/send-otp.ts20
-rw-r--r--website/src/actions/sendmail.ts28
2 files changed, 16 insertions, 32 deletions
diff --git a/website/src/actions/otp/send-otp.ts b/website/src/actions/otp/send-otp.ts
index 23f8dc0..6f017af 100644
--- a/website/src/actions/otp/send-otp.ts
+++ b/website/src/actions/otp/send-otp.ts
@@ -1,14 +1,8 @@
import crypto from "node:crypto";
-import nodemailer from "nodemailer";
import { z } from "astro/zod";
import { defineAction } from "astro:actions";
import { db, Otp } from "astro:db";
-import {
- SMTP_HOST,
- SMTP_PASSWORD,
- SMTP_PORT,
- SMTP_USER,
-} from "astro:env/server";
+import { transporter } from "../sendmail";
export default defineAction({
input: z.object({
@@ -49,15 +43,3 @@ to do anything.`,
validUntil: Date.now() + 1000 * 60 * 5,
});
}
-
-const transporter = nodemailer.createTransport({
- host: SMTP_HOST,
- port: SMTP_PORT,
- secure: false,
- authMethod: "PLAIN",
- auth: {
- type: "login",
- user: SMTP_USER,
- pass: SMTP_PASSWORD,
- },
-});
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,
},
});