Email

This is a detailed reference for email-related types in Stack Auth. If you're looking for a more high-level overview, please refer to our guide on the email system.

On this page:


SendEmailOptions

Options for sending emails via the sendEmail method on StackServerApp.

Table of Contents

An array of user IDs that will receive the email. All users must exist in your Stack Auth project.

Type
userIds: string[]
Example
{
  userIds: ['user-1', 'user-2', 'user-3'],
  // ... other options
}

Optional theme ID to apply to the email. Use null for no theme, false to use the default theme, or a string ID for a specific theme.

Type
themeId?: string | null | false
Example
{
  themeId: 'corporate-theme-id',
  // or
  themeId: null, // no theme
  // or  
  themeId: false, // default theme
  // ... other options
}

Optional email subject line. If using a template, this overrides the template's default subject.

Type
subject?: string
Example
{
  subject: 'Welcome to our platform!',
  // ... other options
}

Optional notification category name for user preferences. Users can opt in or out of specific categories through their account settings.

Type
notificationCategoryName?: string
Example
{
  notificationCategoryName: 'product_updates',
  // ... other options
}

Custom HTML content for the email. Use this option when you want to send a custom HTML email instead of using a template. Cannot be used together with templateId or variables.

Type
html?: string
Example
{
  userIds: ['user-1'],
  html: '<h1>Welcome!</h1><p>Thanks for joining us.</p>',
  subject: 'Welcome to our platform'
}

ID of the email template to use. Use this option when you want to send a template-based email with variables. Cannot be used together with html.

Type
templateId?: string
Example
{
  userIds: ['user-1'],
  templateId: 'welcome-template',
  variables: {
    userName: 'John Doe',
    activationUrl: 'https://app.com/activate/token123'
  }
}

Optional variables to substitute in the template. Only used when templateId is provided.

Type
variables?: Record<string, any>
Example
{
  templateId: 'welcome-template',
  variables: {
    userName: 'John Doe',
    activationUrl: 'https://app.com/activate/token123',
    supportEmail: 'support@yourapp.com'
  }
}

Stack Auth AI

Documentation assistant

Experimental: AI responses may not always be accurate—please verify important details.

For the most accurate information, please join our Discord or email us.

How can I help?

Ask me about Stack Auth while you browse the docs.