Repository navigation
Closed
Labels
Description
Which Cloudflare product(s) does this pertain to?
Email Routing, Workers
Subject Matter
Better examples, better error documentation
Content Location
https://developers.cloudflare.com/email-routing/email-workers/reply-email-workers/
Additional information
Please give:
- Examples we can copy and paste (the current one relies on a fictional
createTicket()function) - Example errors we can debug from (since the logging experience is a nightmare)
I have a simple "hello world" that 1/2 works (set-up as a wildcard catchall):
import { EmailMessage } from "cloudflare:email";
import { createMimeMessage } from "mimetext";
export default {
async email(message, env, ctx) {
const incomingMessageId = message.headers.get("Message-Id");
const incomingReferences = message.headers.get("References") || '';
const subject = message.headers.get("Subject");
const msg = createMimeMessage();
msg.setHeader("In-Reply-To", incomingMessageId);
const updatedReferences = `${incomingReferences} ${incomingMessageId}`.trim();
msg.setHeader("References", updatedReferences);
msg.setSender({ addr: message.to });
msg.setRecipient(message.from);
msg.setSubject(`Re: ${subject}`);
msg.addMessage({
contentType: 'text/plain',
data: `🐶 Hello! We have received your message (${new Date().toString()}).`
});
const replyMessage = new EmailMessage(
message.to,
message.from,
msg.asRaw()
);
await message.reply(replyMessage);
}
}- I can send an email to this catch-all worker, and it replies the first time.
- When i reply to the reply (a "nested reply"), the error gets thrown: "original email is not repliable" with absolutely no context, or more information on how to debug.
- I've tried all different variations, like not setting the
Referencesheader, trying different formats.. It's like this header is not being read right by Cloudflare or something
{
"outcome": "exception",
"scriptName": "**redacted**",
"diagnosticsChannelEvents": [],
"exceptions": [
{
"name": "Error",
"message": "original email is not repliable",
"timestamp": 1706802189551
}
],
"logs": [],
"eventTimestamp": 1706802189512,
"event": {
"rawSize": 7445,
"rcptTo": "**redacted**",
"mailFrom": "**redacted**"
},
"id": 1
}
Reacted by Jordan Coeyman, Dovid Gefen, libreom, Marius Berge Eide, Ni Jannasch, Andrew Jazbec and yechezkel deren
Activity
acoyfellow commentedon Feb 20, 2024
Surprised i'm the only concerned citizen here.. This is what's preventing me from building an email bot. Is that not a main use case for email workers?
Edit: @deadlypants1973 is it possible to at least acknowledge this, so i can plan accordingly?
acoyfellow commentedon Mar 11, 2024
I'm baffled I can't get a response on this topic anywhere. Going on weeks of absolutely no response from official support ticket with Cloudflare, either.
@deadlypants1973 can we at least acklowgedge this issue?
edevil commentedon Mar 15, 2024
Hey @acoyfellow. We don't allow replying to what we already consider to be a reply, this is to prevent reply loops.
In essence an email cannot be replied to when:
Hope this clears things up.
acoyfellow commentedon Mar 15, 2024
@edevil thank you for the response.
Is that anywhere in the docs? That would have been hugely helpful to see last month.
edevil commentedon Mar 15, 2024
I looked at https://developers.cloudflare.com/email-routing/email-workers/reply-email-workers/ and couldn't find this particular information, so I'm guessing the
other internal conditions are not metpart alludes to this.acoyfellow commentedon Mar 15, 2024
Ok, well I think that listing out those internal conditions would be an ideal addition to those docs.
acoyfellow commentedon Mar 17, 2024
I still can't get past this issue..
Seems to have no effect, or there are other internal limitations
acoyfellow commentedon Mar 17, 2024
So I did just find this:
So.. This sounds like what I'm trying to accomplish is just not allowed / not a feature of Email Workers at this point, even though I got some conflicting info from Discord
I was able to build a "hello world email bot" by utilzing a third party email server like mailgun. It's unfortunate we can't open up the use cases here, I guess that would be too good to be true. I love workers.
edevil commentedon Mar 18, 2024
These conditions are relative to the email you are trying to reply to, not the one you are sending.
edevil commentedon Mar 18, 2024
You can definitely reply to emails from your Cloudflare domain using a worker, provided the conditions stated above are true. That part of the documentation predates the "Replying from workers" functionality.
acoyfellow commentedon Mar 18, 2024
Would you be able to provide an example of what I'm trying to accomplish then?
I want to see how to reply to a reply, a nested reply.
edevil commentedon Mar 18, 2024
You cannot reply to a reply. As I stated also above we actively prevent you from replying to what we consider is already a reply, this is to prevent reply loops.
acoyfellow commentedon Mar 18, 2024
That's what my conclusion was - I'm sure my wording and understanding has made this confusing.
Thanks for the clarity @edevil, that's what I consider to be "too bad". I would love to be able to create a bot that can handle back-and-forth dialog with just workers.
Zain-ul-din commentedon Oct 7, 2024
Uncaught Error: No such module "mimetext".
imported from "worker.js"