Issue: Email Reply Chain Handling Failure

Issue: Email Reply Chain Handling Failure Description When using the Workers Email service to handle email communications, the service fails to process replies to auto-generated responses. While the initial auto-reply functionality works as expected, any subsequent replies from users to these auto-generated emails result in an internal error. The worker throws an internal error when processing reply emails. The error occurs at Object.email (index.js:13934:5) with an "internal error" message. The specific error details are not accessible. Reproduction Steps 1. Configure a Workers Email handler (e.g., [email protected]) 2. Send an initial email to [email protected] 3. Receive an auto-reply from the Worker 4. Reply to the auto-reply email 5. Worker fails to process the reply with an internal error Code Example
import { EmailMessage } from 'cloudflare:email';
import { createMimeMessage } from 'mimetext';

export default {
async email(message: any, env: Env, ctx: ExecutionContext) {
const msg = createMimeMessage();
msg.setHeader('In-Reply-To', message.headers.get('Message-ID'));
msg.setSender({ name: 'Thank you for your contact', addr: message.to });
msg.setRecipient(message.from);
msg.setSubject('Email Routing Auto-reply');
msg.addMessage({
contentType: 'text/plain',
data: `We got your message, your ticket number is ${self.crypto.randomUUID()}`,
});
console.log({
sender: message.to,
recipient: message.from,
});

const replyMessage = new EmailMessage(message.to, message.from, msg.asRaw());

await message.reply(replyMessage);
},
};
import { EmailMessage } from 'cloudflare:email';
import { createMimeMessage } from 'mimetext';

export default {
async email(message: any, env: Env, ctx: ExecutionContext) {
const msg = createMimeMessage();
msg.setHeader('In-Reply-To', message.headers.get('Message-ID'));
msg.setSender({ name: 'Thank you for your contact', addr: message.to });
msg.setRecipient(message.from);
msg.setSubject('Email Routing Auto-reply');
msg.addMessage({
contentType: 'text/plain',
data: `We got your message, your ticket number is ${self.crypto.randomUUID()}`,
});
console.log({
sender: message.to,
recipient: message.from,
});

const replyMessage = new EmailMessage(message.to, message.from, msg.asRaw());

await message.reply(replyMessage);
},
};
3 Replies
Mayne
MayneOP5w ago
When an incoming email contains references (such as those in reply emails), the message.reply() method consistently throws an internal error. This makes it impossible to maintain email conversations as the Worker cannot process any referenced emails. Simplest reproduction step: Forward any email to worker, it is unable to reply normally.
cansheetflyer
cansheetflyer3w ago
I can reproduce this even with a new email that I send, without forwarding ... I get the same cryptic "internal error"
EvilDelta
EvilDelta2w ago
I get the same error with a send_email binding. But sometimes it works (1 in 10 emails)

Did you find this page helpful?