This commit is contained in:
geoffsee
2025-05-22 23:14:01 -04:00
commit 33679583af
242 changed files with 15090 additions and 0 deletions

View File

@@ -0,0 +1,41 @@
import { WorkerEntrypoint } from "cloudflare:workers";
import { createMimeMessage } from "mimetext";
import { EmailMessage } from "cloudflare:email";
export default class EmailWorker extends WorkerEntrypoint {
async fetch(req, env, ctx) {
return new Response(undefined, { status: 200 });
}
async sendMail({
plaintextMessage = `You must have wondered where I've been.`,
to,
}) {
const msg = createMimeMessage();
msg.setSender({
name: "New Website Contact",
addr: "contact@seemueller.io",
});
console.log("Recipient:", to);
// msg.setRecipient(to);
msg.setRecipient(to);
msg.setSubject("New Contact Request: Website");
msg.addMessage({
contentType: "text/plain",
data: plaintextMessage,
});
try {
const message = new EmailMessage(
"contact@seemueller.io",
"geoff@seemueller.io",
msg.asRaw(),
);
await this.env.SEB.send(message);
} catch (e) {
return new Response(e.message, { status: 500 });
}
return new Response("Message Sent");
}
}

View File

@@ -0,0 +1,14 @@
main="email_worker.js"
name = "email-service-rpc"
compatibility_date = "2024-12-20"
node_compat = true
[dev]
port = 3002
[placement]
mode = "smart"
send_email = [
{name = "SEB", destination_address = "contact@seemueller.io"},
]