Help with email workers

I just started exploring email routing and email workers look amazing. However, I am struggling to get it working. I need to use email workers to forward the email data to a webhook URL. I need to post the plain text (or HTML content) of the email but I am struggling to get it. Can anyone help how can I get the email plain text content or the HTML from the message object?

export default {
  async email(message, env, ctx) {
    const webhookUrl = '';
    const webhookPayload = JSON.stringify({
      subject: message.headers.get('subject'),
      mail_from: message.from,
      plain_body: message.content // Need help here

    try {
      const response = await fetch(webhookUrl, {
        method: 'POST',
        headers: {
          'Content-Type': 'application/json',
        body: webhookPayload,

      if (response.ok) {
        console.log('Webhook request successful');
      } else {
        console.error('Webhook request failed:', response.status);
    } catch (error) {
      console.error('Error sending webhook request:', error);

I have the same issue. Did you find a solution?


Is it possible to use Cloudflare to catch all the emails for an entire domain (any email address) and forward them to a webhook?

Basically I need to send a POST request to https// every time that an email is received, so that my Rails application can process the incoming emails.