diff --git a/src/index.tsx b/src/index.tsx index bb74f4c..b832bd3 100644 --- a/src/index.tsx +++ b/src/index.tsx @@ -45,12 +45,11 @@ export const emailServer = new SMTPServer({ (async () => { const email = await mailparser.simpleParser(stream); const { entry } = Entry({ - title: email.subject, - author: email.from.text, - // FIXME: https://github.com/DefinitelyTyped/DefinitelyTyped/pull/43234 / typeof email.html !== "boolean" => email.html !== false - ...(typeof email.html === "boolean" - ? { html: false, content: email.text ?? "" } - : { content: email.html }) + title: email.subject ?? "", + author: email.from?.text ?? "", + ...(typeof email.html === "string" + ? { content: email.html } + : { html: false, content: email.text ?? "" }) }); for (const { address } of session.envelope.rcptTo) { const match = address.match(/^(\w+)@kill-the-newsletter.com$/); diff --git a/src/test.ts b/src/test.ts index 34b84cf..60aa7af 100644 --- a/src/test.ts +++ b/src/test.ts @@ -80,6 +80,17 @@ describe("receive email", () => { html: "

HTML content

" }); }); + + test("missing from", async () => { + const identifier = await createFeed(); + await emailClient.sendMail({ + to: `${identifier}@kill-the-newsletter.com`, + subject: "New Message", + html: "

HTML content

" + }); + const feed = await getFeed(identifier); + expect(feed).toMatch("HTML content"); + }); }); afterAll(() => {