Email
Research
Email engineering guide

Calling a send-email API safely from JavaScript

Frontend JavaScript should submit a validated intent to your backend; provider tokens, mailbox credentials, authorization decisions, and final sends belong on a trusted server.

Research surface only. This guide documents architecture and evaluation criteria; it does not describe a released DewEngine connector.
01
Boundary

Keep provider credentials out of browser code

Expose a product endpoint authenticated as the current user. The backend verifies workspace membership, connected-account ownership, sender permission, and policy before creating a send command.

02
Client request

Send structured content with an idempotency key

Submit connected account ID, recipients, subject, body alternatives, attachment references, reply context, and a client-generated idempotency key. Upload large binaries separately and reference secured attachment IDs.

  • Authenticated same-origin request
  • CSRF protection where cookies are used
  • Schema validation
  • Stable idempotency key
03
Backend execution

Return a command state, not a fabricated success

Persist the request, enqueue provider execution, and return a command or message ID. The browser can receive a signed webhook-derived update or poll that resource until it reaches a documented terminal state.

04
User experience

Preserve draft and retry intent

Disable duplicate submission while the same idempotency key is active, show provider validation errors beside the relevant field, and retain the unsent draft when authentication or quota issues require user action.

  • Pending state
  • Field-level validation
  • Reconnect action
  • Accessible final status
Questions

Before you build.

Can I call Gmail or Microsoft Graph directly from a browser?+

Some OAuth flows technically support browser clients, but a multi-tenant SaaS should not expose long-lived mailbox credentials or trust the browser for workspace authorization and send policy. Route sends through the backend.

Why does the JavaScript request need an idempotency key?+

Users double-click, networks retry, and pages reload. The key lets the server return the original command instead of creating another message.

Can I use DewEngine's email connectors today?+

Not yet. Gmail, Microsoft Graph, and IMAP/SMTP connectors are planned. This guide documents the intended architecture and the provider requirements a production release must satisfy.

Build with us

Does this match the workflow your users need?

DewEngine is in development. Real use cases decide what ships first.

Share your use case