ENF News Bot
Automated News Bot
- Joined
- Apr 15, 2022
- Messages
- 2,591
Email Sending is now in public beta. Send transactional emails directly from Workers (
Send an email from a Worker in a few lines of code:
src/index.jsjs
src/index.tsts
Email Service also integrates with the Agents SDK, giving your agents a native
Start sending and receiving emails from Workers and agents today. Email Sending is available on the Workers paid plan. Refer to the Email Service documentation to get started.
Continue reading...
env.EMAIL.send()) or the REST API, with support for HTML, plain text, attachments, inline images, and custom headers. Email Sending joins Email Routing ↗︎ under the new Cloudflare Email Service — a single service for sending and receiving email on the Cloudflare developer platform.Send an email from a Worker in a few lines of code:
src/index.jsjs
Code:
export default {
async fetch(request, env) {
const response = await env.EMAIL.send({
from: "notifications@yourdomain.com",
to: "user@example.com",
subject: "Order confirmed",
html: "<h1>Your order has been confirmed</h1>",
text: "Your order has been confirmed.",
});
return Response.json({ messageId: response.messageId });
},
};
Code:
export default {
async fetch(request, env): Promise<Response> {
const response = await env.EMAIL.send({
from: "notifications@yourdomain.com",
to: "user@example.com",
subject: "Order confirmed",
html: "<h1>Your order has been confirmed</h1>",
text: "Your order has been confirmed.",
});
return Response.json({ messageId: response.messageId });
},
} satisfies ExportedHandler<Env>;
Email Service also integrates with the Agents SDK, giving your agents a native
onEmail hook to receive, process, and reply to emails. Combined with the new Email MCP server ↗︎ and Wrangler CLI email commands, any agent can send email regardless of where it runs.Start sending and receiving emails from Workers and agents today. Email Sending is available on the Workers paid plan. Refer to the Email Service documentation to get started.
Continue reading...