Email

This guide explains how to create HTML email templates using UIx components and send emails from your application.

Email Component System

The saas.common.ui.email namespace provides a set of UIx components specifically designed for creating consistent HTML emails. These components are inspired by React Emailarrow-up-right but implemented with ClojureScript and UIx.

Available Components

The email component library includes:

  • html - Root wrapper for email content

  • head - Contains head elements like styles and meta tags

  • body - Wrapper for all email content

  • container - Centers content with proper width constraints

  • heading - A block of heading text (h1-h6)

  • text - Paragraph text with consistent styling

  • button - A link styled as a button

  • link - Styled hyperlink

  • img - Image component optimized for email clients

  • row - Horizontal layout container

  • column - Column within a row

  • section - Content section

  • preview - Sets inbox preview text

  • hr - Horizontal rule divider

  • code-inline - Displays code snippets with cross-client support

Creating Email Templates

To create an email template:

  1. Import the necessary components:

  1. Define your email template using UIx components:

  1. Convert the UIx components to HTML:

Styling Components

Components accept style maps similar to React's style prop:

For margin utilities, use :m, :mt, :mr, :mb, :ml, :mx, or :my:

Sending Emails

Use the saas.email namespace to send emails:

The email-sender is typically injected via the system's dependency injection:

Email Configuration

The system uses Resendarrow-up-right as the email service provider. Configuration is handled via the :services/email Integrant component:

For local development, a mock email sender is used that logs email contents instead of sending actual emails.

Extracting Plain Text

For better deliverability, include both HTML and plain text versions of your email:

Example Email Templates

The library includes pre-built templates:

  1. login-code-email - For sending login verification codes with magic links

  2. verification-email - For account verification (onboarding, password reset)

Example usage:

Last updated