Email Workers wrong message ID

I want to reply with the email workers to incoming email. When sending email to my worker with gmail everything works. But when sending with outlook (businesses or normal) an error ocurs that the In-Reply-To message ID is not the same as the message. There is no change in the code and the message ID is directly passed from the incoming email to the reply. Why does this work with gmail and not outlook? Code:
import { EmailMessage } from 'cloudflare:email';
import { createMimeMessage } from 'mimetext';

async function webhook(message) {
await fetch('https://discord.com/api/webhooks/xxx', {
method: 'post',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({
username: 'webhook',
content: `${message}`,
}),
});
}

export default {
async email(message, env, ctx) {
const messageID = message.headers.get('Message-ID');
const messageText = `Hello

This is an automated reply to your email.`;

await webhook(`ID: ${messageID} Received email from ${message.from} to ${message.to}`);
try {
await message.forward('[email protected]');
await webhook(`ID: ${messageID} Forwarded email from ${message.from}`);
} catch (e) {
await webhook(`ID: ${messageID} Failed to forward email from ${message.from} with error ${e}`);
}
const msg = createMimeMessage();
msg.setHeader('In-Reply-To', message.headers.get('Message-ID'));
msg.setSender({ name: 'no-reply', addr: '[email protected]' });
msg.setRecipient(message.from);
msg.setSubject('Probable typo in email address');
msg.addMessage({
contentType: 'text/plain',
data: `${messageText}`,
});

var replyMessage = new EmailMessage('[email protected]', message.from, msg.asRaw());
try {
await message.reply(replyMessage);
await webhook(`ID: ${messageID} Replied to email from ${message.from} to ${message.to}`);
} catch (e) {
await webhook(`ID: ${messageID} Failed to reply to email from ${message.from} with error ${e}`);
}
},
};
import { EmailMessage } from 'cloudflare:email';
import { createMimeMessage } from 'mimetext';

async function webhook(message) {
await fetch('https://discord.com/api/webhooks/xxx', {
method: 'post',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({
username: 'webhook',
content: `${message}`,
}),
});
}

export default {
async email(message, env, ctx) {
const messageID = message.headers.get('Message-ID');
const messageText = `Hello

This is an automated reply to your email.`;

await webhook(`ID: ${messageID} Received email from ${message.from} to ${message.to}`);
try {
await message.forward('[email protected]');
await webhook(`ID: ${messageID} Forwarded email from ${message.from}`);
} catch (e) {
await webhook(`ID: ${messageID} Failed to forward email from ${message.from} with error ${e}`);
}
const msg = createMimeMessage();
msg.setHeader('In-Reply-To', message.headers.get('Message-ID'));
msg.setSender({ name: 'no-reply', addr: '[email protected]' });
msg.setRecipient(message.from);
msg.setSubject('Probable typo in email address');
msg.addMessage({
contentType: 'text/plain',
data: `${messageText}`,
});

var replyMessage = new EmailMessage('[email protected]', message.from, msg.asRaw());
try {
await message.reply(replyMessage);
await webhook(`ID: ${messageID} Replied to email from ${message.from} to ${message.to}`);
} catch (e) {
await webhook(`ID: ${messageID} Failed to reply to email from ${message.from} with error ${e}`);
}
},
};
No description
0 Replies
No replies yetBe the first to reply to this messageJoin
Want results from more Discord servers?
Add your server