Mailchannels not working on Cloudflare Pages SvelteKit app

I have consulted the guides and other posts to make sure I have it set correctly, but I’m not getting any email from the contact form. Here is my middleware file:

import mailchannelsPlugin from "@cloudflare/pages-plugin-mailchannels"

export const onRequest = (request: Request) => mailchannelsPlugin({
  personalizations: [
    {
      to: [{ name: "AdPrompt Contact Form Submission", email: "[email protected]" }],
    },
  ],
  from: { name: "Enquiry", email: "Test" },
  respondWith: () =>
    new Response(null, {
      status: 200,
      statusText: "Thank you for your enquiry. We will be in touch shortly."
    }),
});

Here is my form:

<form data-static-form-name="contact-form" class="grid gap-4 mb-12 w-full md:max-w-[50vw] m-auto md:mb-0 [&_input:focus]:ring-2 [&_input:focus]:ring-secondary [&_textarea:focus]:ring-2 [&_textarea:focus]:ring-secondary">
      <input class="input input-bordered w-full col-span-2 md:col-span-1 min-w-[200px]" placeholder="First Name*" required />
      <input class="input input-bordered w-full col-span-2 md:col-span-1 min-w-[200px]" placeholder="Last Name" />
      <input class="input input-bordered w-full col-span-2 md:col-span-1 min-w-[200px]" placeholder="Email*" required />
      <input class="input input-bordered w-full col-span-2 md:col-span-1 min-w-[200px]" placeholder="Website" />
      <textarea class="textarea textarea-bordered w-full col-span-2" rows="10" placeholder="Write your message here" />
      <button type="submit" class="hover:bg-green-700 btn btn-block col-span-2">Send Message</button>
    </form>

Any direction or help would be greatly appreciated! :slight_smile:

1 Like