Email builder product mode with template styles, spacing controls, mobile preview, and export to email-ready HTML. Adds style panel, preview, image alignment, and spacing tools to the toolbar.
Disables todo, embed, outset, and wrap blocks. Use getEmail() to export table-based HTML suitable for mail clients.
<script src="/assets/redactor/redactor.js"></script>
<script src="/assets/redactor/plugins/email/email.js"></script>
const app = Redactor('#entry', {
plugins: ['email'],
email: {
title: 'Newsletter',
font: 'Inter, Helvetica, Arial, sans-serif',
body: {
background: '#f5f5f5',
padding: '32px 20px'
},
content: {
width: '600px',
background: '#ffffff'
}
}
});
Email options define template styles and defaults. They merge with built-in EmailConfig defaults.
string)
''string | false)
falsestring)
'Helvetica, Arial, sans-serif'string | false)
falsestring)
'32px'string)
'24px'string)
'420px''light' | 'dark')
'light'boolean)
trueboolean)
trueKeys body, content, text, h1–h4, link, button, quote, pre, and divider hold CSS-like defaults for the email template. Values are camelCase property names (fontSize, borderRadius, …). Set a property to false to turn it off (for example no border on content).
Built-in defaults:
{
body: {
background: '#ffffff',
padding: '32px 20px 64px 20px'
},
content: {
width: '600px',
background: '#ffffff',
padding: '0',
borderRadius: false,
border: false
},
text: {
fontSize: '16px',
lineHeight: '1.618',
color: '#333333'
},
h1: {
fontSize: '36px',
fontWeight: 'bold',
lineHeight: '1.3',
letterSpacing: '0',
textTransform: 'none',
color: '#000000'
},
h2: {
fontSize: '24px',
fontWeight: 'bold',
lineHeight: '1.3',
letterSpacing: '0',
textTransform: 'none',
color: '#000000'
},
h3: {
fontSize: '20px',
fontWeight: 'bold',
lineHeight: '1.4',
letterSpacing: '0',
textTransform: 'none',
color: '#000000'
},
h4: {
fontSize: '16px',
fontWeight: 'bold',
lineHeight: '1.4',
letterSpacing: '0',
textTransform: 'none',
color: '#000000'
},
link: {
color: '#046BFB'
},
button: {
padding: '16px',
fontSize: '16px',
fontWeight: '500',
background: '#000000',
color: '#ffffff',
borderRadius: '8px'
},
quote: {
borderLeft: '2px solid #ccc',
background: false,
padding: '0 0 0 24px',
color: '#000000',
fontWeight: 'bold',
fontStyle: 'italic'
},
pre: {
fontFamily: 'monospace',
fontSize: '14px',
lineHeight: 1.618,
padding: '20px',
borderRadius: false,
border: false,
color: '#333333',
background: '#f5f5f5'
},
divider: {
size: '1px',
background: '#000000'
}
}
Override only the fields you need — nested objects are deep-merged with these defaults:
Redactor('#entry', {
plugins: ['email'],
email: {
quote: {
borderLeft: '4px solid #087F5B',
fontStyle: 'normal'
},
button: {
background: '#7FF3D0',
color: '#000000'
}
}
});
padding, fontSize, and other untouched button fields stay at their built-in values.
Saved email HTML may include hidden <div> blocks at the top of the document. On load (setContent, paste, import) the plugin reads them, applies the values, and removes the blocks from the editor. On export (getEmail, getJson) they are written back when set.
Preview line shown in inbox lists (not visible in the email body).
<div class="email-preheader">Your order #39574867 has shipped</div>
JSON object with the same shape as plugin email options — deep-merged into the active template styles.
<div class="email-options">
{
"title": "Order receipt",
"font": "Inter, Helvetica, Arial, sans-serif",
"link": {
"color": "#087F5B"
},
"button": {
"background": "#7FF3D0",
"color": "#000000"
}
}
</div>
Custom CSS injected into the email preview and export <head>.
<div class="email-style">
.email-content a { text-decoration: underline; }
h1 { letter-spacing: -0.02em; }
</div>
en: {
email: {
button: 'Button',
'mobile-view': 'Mobile view',
'preview-dark': 'Dark preview',
'style-panel': 'Style panel',
spacing: 'Spacing',
padding: 'Padding',
'margin-bottom': 'Margin bottom',
alignment: 'Alignment',
'size-and-color': 'Size & color',
body: 'Body',
background: 'Background',
content: 'Content',
'border-width': 'Border width',
'border-color': 'Border color',
radius: 'Radius',
size: 'Size',
color: 'Color',
'align-left': 'Align left',
'align-center': 'Align center',
'align-right': 'Align right'
}
}
Fired when email preview is shown.
Fired when email preview is hidden.
app.on('email:preview:show', () => {
console.log('preview open');
});
Exports email-ready HTML (table layout, inlined styles when tidy is true).
const html = app.email.getEmail();
Returns plain-text version of the email body.
const text = app.email.getEmailText();
Returns block JSON plus email meta (preheader, options, style).
const json = app.email.getJson();
Returns current title and preheader strings.
app.email.getTitle();
app.email.getPreheader();
Loads email HTML and rebuilds the template.
app.email.setContent('<h1>Hello</h1><p>Body copy.</p>');
Loads JSON blocks with optional email meta.
app.email.setJson({ blocks: [ /* … */ ], preheader: 'Preview line' });
Opens or closes the mobile email preview overlay.
app.email.showPreview({ mobile: true });
app.email.hidePreview();
app.email.togglePreview();
Opens preview in dark mode.
app.email.togglePreviewDark();