export default {
async email(message, env, ctx) {
// Extract the local part and domain of the email address
const [localPart, domain] = message.to.split('@');
// List of existing custom addresses (anonymized)
const customAddresses = {
'alias1': 'recipient1@example.com',
'alias2': 'recipient2@example.com',
'support': 'support@example.com',
};
// Only proceed if the local part contains a '+'
if (localPart.includes('+')) {
// Extract the base address (portion before the '+')
const baseAddress = localPart.split('+')[0];
// Check if the base address is in the custom addresses list
const destination = customAddresses[baseAddress];
if (destination) {
// Forward to the appropriate destination
await message.forward(destination);
} else {
// Reject if base address is not recognized
message.setReject(`No such address: ${baseAddress}@${domain}`);
}
}
}
}
export default {
async email(message, env, ctx) {
// Extract the local part and domain of the email address
const [localPart, domain] = message.to.split('@');
// List of existing custom addresses (anonymized)
const customAddresses = {
'alias1': 'recipient1@example.com',
'alias2': 'recipient2@example.com',
'support': 'support@example.com',
};
// Only proceed if the local part contains a '+'
if (localPart.includes('+')) {
// Extract the base address (portion before the '+')
const baseAddress = localPart.split('+')[0];
// Check if the base address is in the custom addresses list
const destination = customAddresses[baseAddress];
if (destination) {
// Forward to the appropriate destination
await message.forward(destination);
} else {
// Reject if base address is not recognized
message.setReject(`No such address: ${baseAddress}@${domain}`);
}
}
}
}