Email worker: EmailEvent parsing body?

Hi,

I’d like to create an email worker that receives the email, parse its body and publish it using a rest API, for instance to re-implement the “mail to topic” feature of discourse.

the EmailMessage seems to offer only a raw content, is there an example to parse the body, eg check the html part, of if there is an attachment or anything more high level than the raw stream?

1 Like

the documentation:

https://developers.cloudflare.com/workers/runtime-apis/email-event/

Did you have any success with this?

There’s an example of parsing the email body here, by an employee, using the postal-mime library: email_worker_parser/src/index.js at main · edevil/email_worker_parser · GitHub

The postal-mime module API has changed, and it now includes built-in support for Cloudflare Email Workers. You can read about using it to parse emails from here: https://docs.emailengine.app/how-to-parse-emails-with-cloudflare-email-workers/

2 Likes

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.