redirect all mail from *@sagbot.com to contact@sagbot.com without creating a loop

Is there a way to redirect all mails coming from *@sagbot.com to contact@sagbot.com without creating a loop? like this?
export default {
async email(message, env, ctx) {
if (message.to != "contact@sagbot.com") {
message.forward("contact@sagbot.com")
} else {
// send the email, normally
}
}
}
export default {
async email(message, env, ctx) {
if (message.to != "contact@sagbot.com") {
message.forward("contact@sagbot.com")
} else {
// send the email, normally
}
}
}
1 Reply
Chaika
Chaika4mo ago
When you use CF Email Routing, it takes over the MX servers. It wouldn't know what origin to send it to also you're not awaiting message.forward, failing to do so would make the forward be canceled and never work eitherway