1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
export function parse(email: Email) {
const name = email.from.split(" <")[0];
const bot = name.includes("[bot]");
const title = email.subject;
const chunks = email.text.split("--").map((t) => t.trim());
const footer = chunks.pop();
const description = chunks.join("--");
const [url] = footer.match(/https?:\/\/\S+/g);
const [reason] = footer.match(/You are receiving this because.+/g);
return {
title,
description,
url,
name,
bot,
reason,
};
}