Which tools should I use to send an email via a form with cloudflare and sendgrid?

I have been tring to send emails from a form using sendgrid and cloudflare. At first, I had tried to do this without cloudflare workers. I could do it on a localhost, but on a cloudhost hosted page, I got a 405 error, and was recommended to this page https://developers.cloudflare.com/pages/functions/ I have been trying to use cloudflare workers, but I have been really thrown off on where to go from here. Should I be using something like the runtime api for email workers, https://developers.cloudflare.com/email-routing/email-workers/runtime-api/ I am pretty sure it's that, but is the fetch api relevant? https://developers.cloudflare.com/workers/runtime-apis/handlers/fetch/ and with sendgrid, would it be better to use the mailsend api "https://api.sendgrid.com/v3/" https://www.twilio.com/docs/sendgrid/api-reference/mail-send or the mail api for node.js https://www.twilio.com/docs/sendgrid/for-developers/sending-email/quickstart-nodejs or am I completely wrong where I am looking? I guess the question is with what tool should I use to send an email via a form?
Cloudflare Docs
Functions | Cloudflare Pages docs
Pages Functions allows you to build full-stack applications by executing code on the Cloudflare network with Cloudflare Workers. With Functions, you can introduce application aspects such as authenticating, handling form submissions, or working with middleware. Workers runtime features are configurable on Pages Functions, including compatibility...
Cloudflare Docs
Runtime API | Cloudflare Email Routing docs
An EmailEvent is the event type to programmatically process your emails with a Worker. You can reject, forward, or drop emails according to the logic you construct in your Worker.
Cloudflare Docs
Fetch Handler | Cloudflare Workers docs
Incoming HTTP requests to a Worker are passed to the fetch() handler as a Request object. To respond to the request with a response, return a Response object:
Mail Send API Overview | SendGrid Docs | Twilio
A high-level overview of the Mail Send endpoint in the SendGrid v3 Web API.
1 Reply
Chaika
Chaika2mo ago
You could use Email Workers Sending API to send form submissions to a verified address: https://developers.cloudflare.com/email-routing/email-workers/send-email-workers/ Won't work with Pages Functions though, would have to be its own Worker It'd work in the Fetch API yea
or the mail api for node.js
Workers aren't node.js (although they have some nodejs compat, still no node networking and such), and Workers are size constrained. So best to stay to simple fetch apis, or libs made for serverless functions/browsers
Want results from more Discord servers?
Add your server