Help with email workers

Hello, where i can find docs about email workers? Or examples I want to get: Email from and to Email Subject and Text e.t.c
8 Replies
D Trombett
D Trombett2mo ago
Cloudflare Docs
Email Workers | Cloudflare Email Routing docs
With Email Workers you can leverage the power of Cloudflare Workers to implement any logic you need to process your emails and create complex rules. These rules determine what happens when you receive an email.
Towa
TowaOP2mo ago
i know this page but i dont see variables and examples
D Trombett
D Trombett2mo ago
Ouch I was pretty sure I sent this too... The reference is available here
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.
D Trombett
D Trombett2mo ago
Also, there is a small example and another one is available here
Cloudflare Docs
Reply to emails from Workers | Cloudflare Email Routing docs
You can reply to incoming emails with another new message and implement smart auto-responders programmatically, adding any content and context in the main body of the message. Think of a customer support email automatically generating a ticket and returning the link to the sender, an out-of-office reply with instructions when you are on vacation...
Towa
TowaOP2mo ago
export default {
async email(message, env, ctx) {
const telegramToken = "token";
const chatId = "id";

switch (message.to) {
const rawContent = JSON.stringify(message.raw);
const headersContent = JSON.stringify(message.headers);
const text = `${rawContent} ${headersContent}`;
await fetch(`https://api.telegram.org/bot${telegramToken}/sendMessage`, {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify({
chat_id: chatId,
text: text
})
});
break;

default:

message.setReject("Unknown address");
}
}
}
export default {
async email(message, env, ctx) {
const telegramToken = "token";
const chatId = "id";

switch (message.to) {
const rawContent = JSON.stringify(message.raw);
const headersContent = JSON.stringify(message.headers);
const text = `${rawContent} ${headersContent}`;
await fetch(`https://api.telegram.org/bot${telegramToken}/sendMessage`, {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify({
chat_id: chatId,
text: text
})
});
break;

default:

message.setReject("Unknown address");
}
}
}
why this code sending in telegram this content
No description
Towa
TowaOP2mo ago
i sent message with subject and with text how to get it
D Trombett
D Trombett2mo ago
message.raw is a stream, not the content itself
Towa
TowaOP2mo ago
where i can find how to get content?
Want results from more Discord servers?
Add your server