"""Render the sample emails for What the Inbox Sees: python make_examples.py (needs Playwright and qrcode). Every brand, person, domain and phone number here is invented. Each email is drawn inside a plain mail client frame, the way the person reading it sees it. """ import base64 import io import json from pathlib import Path import qrcode HERE = Path(__file__).parent OUT = HERE / "examples" COMPANY = "brightwell.co.uk" def qr(url): buf = io.BytesIO() qrcode.make(url, box_size=6, border=2).save(buf, "PNG") return "data:image/png;base64," + base64.b64encode(buf.getvalue()).decode() def picture(inner, width=560): """An email body that is one picture: text drawn inside an image, nothing a text filter can read.""" return f"
{inner}
" EMAILS = { "mfa-qr": { "label": "MFA reset with a QR code", "sender": "it-helpdesk@brightwell-security.help", "name": "Brightwell IT Service Desk", "subject": "Action required: re-register your MFA by 17:00 today", "body": picture(f"""
Brightwell IT

Your multi-factor authentication expires today

To keep access to email and Teams, scan the code below with your phone and sign in again. Accounts not re-registered by 17:00 will be locked.

IT Service Desk · Do not reply to this message

"""), }, "callback": { "label": "Call to cancel a renewal", "sender": "billing@novashield-renewals.com", "name": "NovaShield Billing", "subject": "Your NovaShield Total Protection renewal receipt #NS-88412", "body": picture("""
NovaShield

Thank you for renewing NovaShield Total Protection (3 devices, 2 years).

Amount charged€399.99
PaymentCard ending 4417

Did not authorise this purchase? To cancel and receive a full refund, call our billing team within 24 hours: +44 20 3890 1147

"""), }, "gift-cards": { "label": "The boss needs gift cards", "sender": "martin.okoro.ceo@gmail.com", "name": "Martin Okoro", "subject": "Quick favour", "body": """

Hi, are you at your desk?

I'm in back-to-back meetings with investors and need a favour. I want to surprise a few clients today with gift cards. Can you pick up 6 Apple gift cards of €200 each and send me photos of the codes on the back? I'll reimburse you this afternoon. Keep it between us for now, it's a surprise.

Thanks
Martin
Sent from my phone

""", }, "bank-change": { "label": "Supplier's new bank details", "sender": "accounts@nordkraft-fittings.no", "name": "Nordkraft Fittings AS", "subject": "Updated bank details for future payments", "body": """

Dear customer,

Please note that following our annual audit, our bank account has changed with immediate effect. All payments, including the outstanding invoice INV-2304, should now be made to:

Account name: Nordkraft Fittings AS
IBAN: GB29 LOYD 3095 1123 4560 18
BIC: LOYDGB2L

Please update your records and confirm by reply once done. Payments to the old account can no longer be received.

Kind regards,
Accounts department
Nordkraft Fittings AS

""", }, "newsletter": { "label": "A real newsletter", "sender": "hello@fernhillbooks.com", "name": "Fernhill Books", "subject": "Five books for a rainy weekend", "body": picture("""
Fernhill Books

Five books for a rainy weekend

This week our booksellers picked five novels you can finish by Sunday night, from a Welsh coastal mystery to a very funny book about a failing bakery.

See the picks

You're receiving this because you joined our mailing list at the shop. Unsubscribe any time.

"""), }, "it-notice": { "label": "A real IT notice", "sender": "it@brightwell.co.uk", "name": "Brightwell IT", "subject": "Wi-Fi maintenance on Saturday morning", "body": """

Hi all,

The office Wi-Fi will be down on Saturday between 07:00 and 09:00 while we replace two access points on the second floor. Wired connections and the VPN are not affected. Nothing for you to do.

Questions: ask in #it-help.

Thanks,
Priya, IT

""", }, } def frame(e): return f"""
Inbox · you@{COMPANY}
{e["subject"]}
{e["name"]} <{e["sender"]}>
to me · 09:14
{e["body"]}
""" def main(): from playwright.sync_api import sync_playwright OUT.mkdir(exist_ok=True) with sync_playwright() as p: browser = p.chromium.launch() page = browser.new_page(viewport={"width": 920, "height": 900}, device_scale_factor=1.25) for name, e in EMAILS.items(): page.set_content(frame(e)) page.wait_for_timeout(100) page.locator("body > div").screenshot(path=OUT / f"{name}.png") browser.close() (HERE / "examples.json").write_text(json.dumps( {"company": COMPANY, "emails": {k: {"label": e["label"], "sender": e["sender"]} for k, e in EMAILS.items()}}, indent=2) + "\n") print(sorted(p.name for p in OUT.iterdir())) if __name__ == "__main__": main()