Outline

At it’s core, PretzelBox is an inbox for your domain so building an extensible, rules based email handling protocol is essential to its success.

In general, leveraging AWS’s famous Shared Responsibility Model, PretzelBox relies on AWS SES for email delivery, email identity management, and the initial processing of inbound emails while handling further functional processing through a mix of Serverless technologies like S3, Eventbridge, Step Functions, Lambdas, and a custom DSL.

In this blog post, we will delve into the last aspect above, i.e., the initial processing of inbound emails.

High Level Schematic

As you can see from the below schematic, AWS SES handles email receipt and storage into a PretzelBox owned S3 bucket. PretzelBox takes over from there, using AWS Eventbridge to trigger a step function to orchestrate how emails are handled.

It is worth knowing that AWS SES is also responsible for flagging the email as SPAM or containing a virus. As an inbox service, we don’t delete or hide emails marked as SPAM or as having a virus but give the client the relevant flags to help it decide what to do with those emails

pb-inbound-emails.png

Each of the parts, namely email receipt, storage into S3, firing off an event via Eventbridge, creating Step Functions to orchestrate further processing can be the subject of their own blog posts but this high level overview should suffice for now.

PretzelBox’s Responsibility

Here, I will explain in a little more detail how PretzelBox is able to turn your domain’s email inbox into a full fledged CMS.

Lambda 1: Extract Metadata

The first step in the step function is to extract the metadata associated with the email i.e., things like the TO and CC addresses, subject line, spam/virus classification.

Actually, the section label Extract Metadata is a little misleading. It implies that the lambda is acting as a reader of the email.

In fact, it also applies some rules on the extracted metadata to make emails more functional, something like an IFTTT driven by your emails.

To achieve that, it puts a copy of the metadata into different sub-directories which can then trigger further Eventbridge actions

Example: Blogs

As a PretzelBox user, you could decide to treat your PretzelBox as a blog, i.e., all emails sent to (say) [email protected] are going to appear on your blog.

IF to_email = [email protected] THEN use email content on your-domain.com/blog