Email
Research
Email engineering guide

Sending mail with the Gmail API

Gmail sending requires a valid user grant, an RFC-compliant MIME message encoded for the API, an authorized sender identity, and application-level idempotency.

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

Choose send-only access when it is enough

The gmail.send scope can authorize sending without general mailbox reading. Draft management, replies using stored context, or mailbox synchronization may require additional scopes and a different Google verification burden.

02
Message construction

Create MIME before calling messages.send

Build valid From, recipients, subject, body alternatives, and attachment parts, then base64url-encode the complete raw message. Use the connected account or a Gmail-configured alias as the sender.

  • RFC message headers
  • UTF-8 subject and body
  • Multipart alternatives
  • Attachment types and size budget
03
Reply context

Preserve threading deliberately

For a reply, include the appropriate Gmail thread ID and standards-based reply headers. Matching subject alone is insufficient; validate the parent message and participants before constructing reply-all recipients.

04
Execution

Protect against duplicate sends

Persist an application idempotency key and final content hash before the provider call. Store Gmail's returned message ID, reconcile the Sent label if needed, and distinguish provider acceptance from delivery or engagement.

  • Pre-send authorization check
  • Idempotency record
  • Gmail message and thread IDs
  • Actionable quota and auth errors
Questions

Before you build.

Does Gmail API accept ordinary JSON body text as an email?+

No. The send operation expects a base64url-encoded raw Internet message, normally constructed as MIME by a mail library.

Is gmail.send enough to read the Sent folder?+

No. Send-only access does not grant general mailbox reads. Request broader access only if the product genuinely needs it and can meet the added requirements.

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