Email Templates
Create and manage reusable email templates for consistent branding and efficient email creation.
Creating Templates
Basic Template
const template = await sendmator.templates.create({
name: 'welcome-email',
subject: 'Welcome to {{app_name}}!',
html: `
<h1>Welcome, {{user_name}}!</h1>
<p>Thanks for joining {{app_name}}.</p>
`,
variables: ['user_name', 'app_name']
});
Using Templates
await sendmator.emails.send({
to: 'user@example.com',
template: 'welcome-email',
template_data: {
user_name: 'John Doe',
app_name: 'YourApp'
}
});
Template Best Practices
- Use descriptive names
- Include fallback text versions
- Test with sample data
- Keep variables consistent