CerberusEmail

Cross-client-tested responsive email components for Phoenix, built on the Cerberus email framework.

Table-based layout with MSO/Outlook conditional comments and mobile stacking via media queries. Branding (product name, footer, colors, font) is passed as attrs — not hardcoded — so the same components work for any product.

Installation

def deps do
[
{:cerberus_email, "~> 0.1"}
]
end

Usage

<.email_layout brand_name="Acme" footer_text="Acme Inc" preview_text="Welcome!">
<.email_one_column_text_button
heading="Welcome to Acme"
button_text="Get Started"
button_url="https://acme.example.com/start"
>
<p style="margin: 0 0 10px;">Click below to get started.</p>
</.email_one_column_text_button>
</.email_layout>

Render to an HTML string for use with a mailer:

import CerberusEmail.Components
import Phoenix.Component
html =
~H"""
<.email_layout brand_name="Acme" footer_text="Acme Inc" preview_text="Welcome!">
<.email_one_column_text>
<p style="margin: 0;">Hello!</p>
</.email_one_column_text>
</.email_layout>
"""
|> Phoenix.HTML.Safe.to_iodata()
|> IO.iodata_to_binary()

Components

ComponentDescription
email_layoutOuter HTML shell with <head>, MSO comments, preview text, header, footer
email_content_blockWhite-background content wrapper
email_text_rowText row with standard padding and typography
email_button_rowCentered primary action button
email_secondary_button_rowOutlined secondary button
email_one_column_text_buttonCombined heading + text + button block
email_one_column_textText-only block
email_spacerVertical spacer

Branding attrs (email_layout)

AttrDefaultDescription
brand_name"App"Shown in header and footer
footer_textfalls back to brand_nameFooter line
primary_color"#3b82f6"Button/accent color
font_family"'Inter', sans-serif"Font stack
preview_textnilPreview text shown in email clients
show_headertrueWhether to render the brand name header

License

MIT