Email workers return codes?

Good evening,

When I use email workers, all messages that go to workers show as “dropped” in my email routing summary on the email routing overview page.

Is there a way in workers to return something to the routing page to indicate what actually happened?

i.e. set a return code to say that I rejected vs forwarded a message?

Functionally my worker script is working well, but it would be nice to still be able to view useful stats on the overview page.

3 Likes

Hi, same behaviour here, all my emails going through Email Worker are identified as “Dropped” even if they were delivered.
Can it be corrected ? Or am I doing something wrong ?

I’m seeing this as well. All messages are “Dropped” in “Email Routing summary” even with a Email worker like this:

export default {
  async email(message, env, ctx) {
    await message.forward("[email protected]");
  }
}
1 Like

same here I made a very simple one to many forwarder.
Everything is working but status is always Dropped
github

/** Copyright (c) 2024 Ronan Le Meillat
 * This software is released under the MIT License.
 * https://opensource.org/licenses/MIT
 * 
 * This is a simple email forwarder for Cloudflare Workers.
 * It forwards emails to a list of recipients.
 * The list of recipients is defined in the environment variable RECIPIENTS.
 * Each recipient is separated by a pipe character "|".
 */
export interface Env {
	RECIPIENTS: string;
}

function getRecipients(flatString:string) {
	return flatString.split("|");
  }

export default {
	async email(message: ForwardableEmailMessage, env:Env, ctx: ExecutionContext) {
		const recipients = getRecipients(env.RECIPIENTS);
		const promised = [] as Promise<void>[];
		recipients.forEach((recipient) => {
		  promised.push(message.forward(recipient));
		  console.log(`Email forwarded to: ${recipient}`);
		});
		await Promise.allSettled(promised);
	  }
};

All Mail currently handled by Workers will show as “Dropped”, regardless of it being forwaded or not. That is normal. If your worker was erroring, it would show as Delivery Failed, ex:


Only mail forwarded by the normal route forward action is shown as “forwarded”

You can also Tail your workers to see any errors, and overall error analytics on the workers overview page.

1 Like