import staticFormsPlugin from "@cloudflare/pages-plugin-static-forms"; import { EmailMessage } from "cloudflare:email"; export const onRequest: PagesFunction = staticFormsPlugin({ respondWith: async ({ formData }) => { const fullName = formData.get("name"); const organisation = formData.get("org") ?? "Unknown Organisation"; const email = formData.get("email"); const mobile = formData.get("mobile") ?? "Unknown Mobile"; const message = formData.get("message"); // Must have some kind of identifiable information for me to actually care about them. if ((fullName || email) && message) { // const emailMessage = createMimeMessage(); // emailMessage.setSender({ // name: "Michael Pivato Contact Form", // addr: "contact@michaelpivato.dev", // }); // emailMessage.setRecipient("contact@michaelpivato.dev"); // emailMessage.setSubject(`Message from ${fullName ?? email}`); // emailMessage.addMessage({ // contentType: "text/plain", // data: `You've received a new message from ${fullName ?? email}. // Full Name: ${formatEmptyString(fullName)} // Organisation: ${formatEmptyString(organisation)} // Email: ${formatEmptyString(email)} // Mobile: ${formatEmptyString(mobile)} // Message: // ${message} // `, // }); const rawEmailMessage = `---- From: Michael Pivato Contact Form To: Michael Pivato s ?? "Not Specified";