zank.it
01/14/2024, 2:50 PMjs
import mailChannelsPlugin from "@cloudflare/pages-plugin-mailchannels";
export const onRequest: PagesFunction = (context) => {
var data = context?.data; // <-- That's just a test
return mailChannelsPlugin({
personalizations: [
{
to: [{ name: "Giulio Zanchetta", email: "giulio.zanchetta@majestico.it" }],
dkim_domain: "majestico.it",
dkim_selector: "mailchannels",
dkim_private_key: context.env.DKIM_PRIVATE_KEY,
},
],
from: {
name: `${data?.name}`, // <-- Here I want the actual name inserted in the form
email: "no-reply@majestico.it",
},
respondWith: () =>
new Response(null, {
status: 302,
headers: { Location: "/thank-you" },
}),
})(context);
};