Email actions

Send product mail from a backend operation.

Add email as an outcome of a named action for invitations, confirmations, alerts, and workflow messages.

Prepare mail delivery first

Complete mail server configuration and send a disposable message through the intended domain before attaching delivery to a product operation. Verify DNS, TLS, relay policy, sender identity, storage, and retry behavior independently.

Define a narrow action contract

Accept only the product inputs the caller should control, such as a record public ID and validated message data. Resolve recipients and sensitive context from server-owned records when possible. Do not accept an arbitrary relay host, sender, template path, or unrestricted recipient list from an untrusted client.

  1. Create or select a template and render it with disposable data.
  2. Define an action input schema and reject missing, malformed, or oversized values.
  3. Authorize Execute separately from permission to read the referenced record.
  4. Add the mail outcome and queue the message through the server-side mail path.
  5. Invoke the action as the real application role and retain its response.

Verify queueing, delivery, and failure separately

  • The action returns the documented result and creates the expected queued/outbox record.
  • The worker delivers to a disposable inbox and records success.
  • After a temporary SMTP failure, the message stays in the queue for another attempt.
  • A permanent invalid recipient reaches a bounded failure state.
  • An unauthorized caller cannot execute the action or read another user’s message context.
Mail delivery is at-least-once, not exactly-once. A crash after SMTP acceptance but before success is recorded can produce a duplicate. Make templates and product flows tolerant of retries; do not send irreversible secrets through an unbounded retry path.

Operate the workflow

Monitor queue age, attempts, last error, delivery latency, and domain-level failures. Redact credentials and message bodies from ordinary logs. Provide a controlled way to stop retries, inspect a failed item, and replay only after the cause is understood.

Keep sending server-side

Accept validated input

Build the message from action input and application records after request validation.

Use templates

Keep repeatable message structure out of frontend code.

Queue outgoing mail

Hand messages to Daptin’s outgoing processing path for delivery and retry.

Protect the operation

Apply action permissions so only intended callers can trigger mail.

Connect mail to a real product operation.