Simple email worker

Hi all I have a simple website on Pages and I'd like to send emails from the content form to myself. I've been looking at Email Workers and trying to work out if this is a viable option. The documentation doesn't seem very clear (to me). Does anyone have any example code to take the contents of a form and send it via an Email Worker? Any help would be much appreciated.
4 Replies
JustinNoel
JustinNoel13mo ago
maybe Consider using a free zoho email account for this. Even their free account allows you to create an incoming webhook. Then when the form is filled out, your worker would trigger the webhook, and then zoho would send an email to whomever needs to receive the contact info. https://www.zoho.com/mail/help/dev-platform/webhook.html
Zoho
Configure webhooks to integrate external applications - Zoho Mail
Set up incoming and outgoing webhooks in Zoho Mail and the external application you want to integrate Zoho Mail with.
JustinNoel
JustinNoel13mo ago
Here's how I trigger my webhook:
await fetch(c.env.ZOHO_EMAIL_WEBHOOK, {
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({
subject: "Noel Voice Contact Form",
message: `
<html>
<body>
<p>Name: ${formData.full_name}</p>
<p>Email: ${formData.email}</p>
<p>Phone:${formData.phone}</p>
<p>Message: ${formData.message}</p>
</body>
</html>
`,
}),
});
await fetch(c.env.ZOHO_EMAIL_WEBHOOK, {
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({
subject: "Noel Voice Contact Form",
message: `
<html>
<body>
<p>Name: ${formData.full_name}</p>
<p>Email: ${formData.email}</p>
<p>Phone:${formData.phone}</p>
<p>Message: ${formData.message}</p>
</body>
</html>
`,
}),
});
And it then sends out an email like:
No description
Roger
RogerOP13mo ago
Thanks @JustinNoel I'll give that a try. @JustinNoel . I've got this working now. Thanks again for your help
JustinNoel
JustinNoel13mo ago
@Jacob | Pages RE: Zoho
Want results from more Discord servers?
Add your server