Email response
What is the behavior when an email worker throws an exception or error? In one case my email sender did not get a response. Am I rejecting the message by thrown exceptions from a worker?
setReject method on the ForwardableEmailMessage object, passing a reason string as an argument. This will return a permanent SMTP error back to the connecting client, including the given reason.setReject to reject the message with a meaningful error message.This is an AI generated response, it may not be 100% accurate. Please validate the output. You can ask followups by replying to this message or mentioning me.
setRejectsetRejectForwardableEmailMessageexport default {
async email(message, env, ctx) {
try {
// Your email processing logic here
} catch (error) {
message.setReject("Error processing email: " + error.message);
}
},
};