Shaf Lab

Programmable email

Sending or receiving email from an application or edge function.

Programmable email is sending or receiving mail from an application or an edge function, rather than from a person at a desk. You might send a login code, a receipt, or a notification, or you might accept inbound mail and turn it into a ticket. The work is less about composing prose and more about deliverability, identity, and a clear path for failures.

Send through a dedicated provider or a platform binding, with a domain you have authenticated. Put the send on a queue or a workflow so a traffic spike or a retry does not happen on the user's request. Keep templates in version control, and never put secrets in a message you would not want forwarded.

Inbound mail needs the same care: verify the sender, parse only what you need, and do not execute anything that arrived in the body. Treat attachments as untrusted uploads. If a function can both read mail and call other tools, the combination is a useful agent — and a useful attack surface.

Start with one transactional message you can measure: delivered, bounced, or complained. Once that path is boring, you can add more types.