Skip to content

docs: Document managed email provider and email scheduling features#1282

Open
promptless[bot] wants to merge 1 commit intodevfrom
promptless/document-managed-email-provider
Open

docs: Document managed email provider and email scheduling features#1282
promptless[bot] wants to merge 1 commit intodevfrom
promptless/document-managed-email-provider

Conversation

@promptless
Copy link
Copy Markdown
Contributor

@promptless promptless bot commented Mar 23, 2026

Open this suggestion in Promptless to view citations and reasoning process

Updates the Emails documentation with two new features:

  1. Managed by Stack Auth email provider (from PR Managed email provider #1222): Documents the new email configuration option that automates DNS and domain setup via Resend integration, allowing users to send from their own domain without manually configuring SMTP.

  2. Email scheduling (from PR [Refactor][Feat][Fix] Rework Email Section With New Sent Page, Better Drafts Page, and Settings Page #1221): Documents the new scheduledAtMillis option for sendEmail that allows scheduling emails for future delivery instead of sending immediately.

Trigger Events

stack-auth/stack-auth commit (dev): b701fdf Managed email provider (#1222)

Promptless Research (4 files, 1 GitHub PR)

  • Reviewed stack-auth/stack-auth#1222
  • Viewed .long_term_context/product_knowledge/product_overview.md
  • Viewed .long_term_context/doc_workflow/client_instructions.md
  • Viewed .long_term_context/style/client_style_guide.md
  • Viewed docs/content/docs/(guides)/apps/emails.mdx

Agent Response

I've created a documentation suggestion for PR #1222 (Managed email provider).

Summary

What changed: Added documentation for the new "Managed by Stack Auth" email configuration option to the Emails guide.

Documentation updates:

  • Added a new section "Managed by Stack Auth (Production)" in the Email Configuration section
  • Documents the setup flow: entering subdomain and sender, configuring NS records at the DNS provider, waiting for verification, and activating the domain
  • Updated the intro text from "two options" to "three options" to reflect the new configuration method
  • Added lastModified date to frontmatter

Why this matters: This feature allows users to send emails from their own domain without manually configuring SMTP servers. Stack Auth handles the DNS provisioning and Resend integration automatically, making production email setup much simpler.

Suggestion URL: https://app.gopromptless.ai/suggestions/de92a85f-19b1-4cc1-aab4-052e6b988b11

stack-auth/stack-auth commit (dev): 485fa9d [Refactor][Feat][Fix] Rework Email Section With New Sent Page, Better Drafts Page, and Settings Page (#1221)

Promptless Research (4 files, 1 GitHub PR)

  • Reviewed stack-auth/stack-auth#1221
  • Viewed .long_term_context/product_knowledge/product_overview.md
  • Viewed .long_term_context/doc_workflow/client_instructions.md
  • Viewed .long_term_context/style/client_style_guide.md
  • Viewed docs/content/docs/(guides)/apps/emails.mdx

Agent Response

I've completed the documentation update for PR #1221. Here's a summary:

Summary

PR #1221 reworked the email section with several changes:

Change Type Documentation Needed?
Sent Page Dashboard UI No - self-documenting UI
Settings Page Dashboard UI No - self-documenting UI
Better Drafts Page Dashboard UI No - self-documenting UI
Email scheduling (scheduledAtMillis) API feature Yes - documented
Capacity boost API Dashboard-triggered No - not user-callable

Documentation Changes

I updated the existing suggestion (Document managed email provider and email scheduling features) to add:

  1. New "Scheduling Emails" section - Documents how to use scheduledAtMillis to schedule emails for future delivery with a code example

  2. Updated Email Options type - Added scheduledAtMillis?: number to the type definition

The suggestion now covers two features:


Tip: Create additional Docs Collections to keep multiple repositories in sync 📚

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(Line 139)

Citation: New "Managed by Stack Auth" email provider feature. Based on PR implementation in apps/backend/src/lib/managed-email-onboarding.tsx and dashboard UI in apps/dashboard/src/app/(main)/(protected)/projects/[projectId]/emails/page-client.tsx. The setup flow guides users through subdomain configuration, NS record delegation, and domain verification via Resend webhooks.
View source

@vercel
Copy link
Copy Markdown

vercel bot commented Mar 23, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
stack-auth-hosted-components Ready Ready Preview, Comment Mar 23, 2026 3:14pm
stack-backend Ready Ready Preview, Comment Mar 23, 2026 3:14pm
stack-dashboard Ready Ready Preview, Comment Mar 23, 2026 3:14pm
stack-demo Ready Ready Preview, Comment Mar 23, 2026 3:14pm
stack-docs Ready Ready Preview, Comment Mar 23, 2026 3:14pm

});
```

### Scheduling Emails
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Citation: Added scheduled_at_millis parameter to the send-email endpoint in apps/backend/src/app/api/latest/emails/send-email/route.tsx. This allows scheduling emails for future delivery.
View source

html?: string; // Custom HTML content
templateId?: string; // Template ID to use
variables?: Record<string, any>; // Template variables
scheduledAtMillis?: number; // When to send (timestamp in milliseconds)
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Citation: New scheduled_at_millis option added to the request body schema in apps/backend/src/app/api/latest/emails/send-email/route.tsx.
View source

@CLAassistant
Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps bot commented Mar 23, 2026

Greptile Summary

This PR adds documentation for two new email features: the Managed by Stack Auth email provider (from PR #1222) and email scheduling via scheduledAtMillis (from PR #1221). The managed provider section is accurate and well-structured. However, the email scheduling documentation contains a critical API mismatch — the actual SDK uses scheduledAt?: Date (a Date object), but the docs document the field as scheduledAtMillis?: number (a millisecond timestamp). This incorrect field name appears in both the code example and the SendEmailOptions type definition, meaning developers following the docs will silently pass an unrecognised property and their emails will be sent immediately rather than at the scheduled time.

Key issues:

  • scheduledAtMillis: oneHourFromNow in the code example should be scheduledAt: new Date(oneHourFromNow) — the property is named scheduledAt and takes a Date, not a raw millisecond number
  • scheduledAtMillis?: number in the type definition should be scheduledAt?: Date
  • const oneHourFromNow = Date.now() + ... produces a number; wrapping in new Date(...) is needed to match the expected type

Confidence Score: 3/5

  • Not safe to merge as-is — the scheduling section documents the wrong property name and type, which will cause silent failures for developers who follow it.
  • The managed email provider section is correct and ready to ship. The scheduling section has a concrete, reproducible bug: scheduledAtMillis (number) is documented instead of scheduledAt (Date). Developers copying the example will pass a silently-ignored property and never schedule their emails. This affects the primary user path for the newly-documented feature.
  • docs/content/docs/(guides)/apps/emails.mdx — the Scheduling Emails section and the SendEmailOptions type definition both use the wrong property name/type

Important Files Changed

Filename Overview
docs/content/docs/(guides)/apps/emails.mdx Adds documentation for managed email provider (correct) and email scheduling (incorrect: documents scheduledAtMillis?: number but the actual SDK uses scheduledAt?: Date in both the type definition and the code example)

Sequence Diagram

sequenceDiagram
    participant Dev as Developer Code
    participant SDK as StackServerApp (SDK)
    participant API as Stack Auth API

    Note over Dev,API: Email Scheduling Flow
    Dev->>SDK: sendEmail({ scheduledAt: new Date(...) })
    SDK->>API: POST /emails/send-email<br/>{ scheduled_at_millis: date.getTime() }
    API-->>SDK: 200 OK { results: [...] }
    SDK-->>Dev: void

    Note over Dev,API: Managed Email Provider Setup
    Dev->>API: Dashboard → Email Settings → Managed Setup
    API-->>Dev: Display NS records for subdomain
    Dev->>Dev: Add NS records at DNS provider
    API->>API: Poll for DNS propagation<br/>(pending_verification → verified)
    Dev->>API: Click "Use This Domain"
    API-->>Dev: Emails sent from sender@subdomain
Loading

Reviews (1): Last reviewed commit: "Document managed email provider and emai..." | Re-trigger Greptile

userIds: ['user-id'],
subject: 'Reminder: Your trial ends soon',
html: '<p>Your trial period ends tomorrow. Upgrade now to keep access.</p>',
scheduledAtMillis: oneHourFromNow,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Wrong property name in scheduling example

The code example uses scheduledAtMillis (a number), but the actual SendEmailOptions type defines the property as scheduledAt (a Date object). Developers copying this example will pass an unrecognised property that is silently ignored, and the email will be sent immediately instead of at the scheduled time.

From packages/stack-shared/src/interface/server-interface.ts:

async sendEmail(options: {
  ...
  scheduledAt?: Date,          // ← Date object, not a number
})

Internally the SDK converts it via options.scheduledAt?.getTime() before sending scheduled_at_millis to the API.

Suggested change
scheduledAtMillis: oneHourFromNow,
scheduledAt: new Date(oneHourFromNow),

Comment on lines +74 to +75
// Schedule an email to be sent in 1 hour
const oneHourFromNow = Date.now() + 60 * 60 * 1000;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Incorrect variable type for scheduled timestamp

Date.now() returns a plain number (milliseconds since epoch), but sendEmail expects a Date object in the scheduledAt field — not a raw millisecond timestamp. The variable should be constructed as a Date:

Suggested change
// Schedule an email to be sent in 1 hour
const oneHourFromNow = Date.now() + 60 * 60 * 1000;
const oneHourFromNow = new Date(Date.now() + 60 * 60 * 1000);

html?: string; // Custom HTML content
templateId?: string; // Template ID to use
variables?: Record<string, any>; // Template variables
scheduledAtMillis?: number; // When to send (timestamp in milliseconds)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Wrong property name and type in SendEmailOptions type definition

The type definition documents scheduledAtMillis?: number, but the actual SDK type (packages/template/src/lib/stack-app/email/index.ts) and the underlying interface (packages/stack-shared/src/interface/server-interface.ts) both use scheduledAt?: Date. Using the documented scheduledAtMillis property will have no effect at runtime.

Suggested change
scheduledAtMillis?: number; // When to send (timestamp in milliseconds)
scheduledAt?: Date; // When to send (Date object)

const oneHourFromNow = Date.now() + 60 * 60 * 1000;

const result = await stackServerApp.sendEmail({
userIds: ['user-id'],
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Documentation shows incorrect property name scheduledAtMillis (number) instead of scheduledAt (Date) for scheduling emails

Fix on Vercel

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant