Email Templates
Ever Works includes professional, responsive email templates for newsletters and transactional emails.
Overviewβ
The email template system provides:
- π§ Pre-built templates - Welcome, newsletter, unsubscribe
- π± Responsive design - Optimized for mobile and desktop
- π¨ Modern styling - Gradients, rounded borders, shadows
- β Email client compatibility - Works across all major clients
- π§ Customizable - Easy to modify and extend
Available Templatesβ
1. Welcome Emailβ
Sent to new newsletter subscribers.
Function: getWelcomeEmailTemplate(email, appName)
Parameters:
email(string): Subscriber's email addressappName(string, optional): Application name (default: "Ever Works")
Usage:
import { getWelcomeEmailTemplate } from '@/lib/mail/templates';
const template = getWelcomeEmailTemplate('user@example.com', 'My App');
await emailService.sendCustomEmail({
from: 'welcome@myapp.com',
to: 'user@example.com',
subject: template.subject,
html: template.html,
text: template.text,
});
2. Unsubscribe Emailβ
Confirms user unsubscription.
Function: getUnsubscribeEmailTemplate(email, appName)
Parameters:
email(string): User's email addressappName(string, optional): Application name
Usage:
import { getUnsubscribeEmailTemplate } from '@/lib/mail/templates';
const template = getUnsubscribeEmailTemplate('user@example.com', 'My App');
3. Regular Newsletterβ
Weekly/monthly newsletters with dynamic content.
Function: getRegularNewsletterTemplate(email, appName, content)
Parameters:
email(string): Subscriber's email addressappName(string, optional): Application namecontent(object): Newsletter content
Content Structure:
interface NewsletterContent {
title: string;
subtitle?: string;
articles: Array<{
title: string;
excerpt: string;
image?: string;
link: string;
category?: string;
}>;
featured?: {
title: string;
description: string;
image?: string;
link: string;
cta: string;
};
stats?: {
totalUsers: number;
newFeatures: number;
updates: number;
};
}
Usage Example:
import { getRegularNewsletterTemplate } from '@/lib/mail/templates';
const content = {
title: "π New Features This Week",
subtitle: "Discover the latest improvements",
featured: {
title: "β¨ New Interface",
description: "Completely redesigned user interface",
link: "https://myapp.com/blog/new-ui",
cta: "Learn More"
},
articles: [
{
title: "π Enhanced Statistics",
excerpt: "New charts and metrics for better insights",
category: "Feature",
link: "https://myapp.com/blog/stats"
},
{
title: "π Improved Security",
excerpt: "Two-factor authentication now available",
category: "Security",
link: "https://myapp.com/blog/2fa"
}
],
stats: {
totalUsers: 15420,
newFeatures: 8,
updates: 12
}
};
const template = getRegularNewsletterTemplate(
'user@example.com',
'My App',
content
);
Template Featuresβ
Responsive Designβ
- β Optimized for mobile and desktop
- β Maximum width of 600px (email standard)
- β Adaptive grid for statistics
- β Touch-friendly buttons
Modern Stylesβ
- β Colorful gradients for headers
- β Rounded borders and shadows
- β Subtle CSS animations
- β Optimized typography
- β Professional color scheme
Modular Sectionsβ
- Header: Logo and date
- Main title: Customizable title and subtitle
- Featured section: Highlight main content (optional)
- Articles: News list with categories
- Statistics: Weekly metrics (optional)
- Footer: Social links and unsubscribe
Email Configurationβ
Environment Variablesβ
# Email Provider (Resend or Novu)
RESEND_API_KEY=your_resend_api_key
NOVU_API_KEY=your_novu_api_key
# Email Settings
NEXT_PUBLIC_APP_URL=https://yourdomain.com
EMAIL_FROM=newsletter@yourdomain.com
Email Service Configurationβ
const emailConfig = {
provider: "resend", // or "novu"
defaultFrom: "newsletter@yourdomain.com",
domain: "https://yourdomain.com",
apiKeys: {
resend: process.env.RESEND_API_KEY,
novu: process.env.NOVU_API_KEY,
},
};
Customizationβ
Template Colorsβ
// Modify gradient colors
const customHtml = template.html.replace(
'linear-gradient(135deg, #667eea 0%, #764ba2 100%)',
'linear-gradient(135deg, #your-color-1 0%, #your-color-2 100%)'
);
Personalizationβ
// Personalize content based on user
const personalizedContent = {
...newsletterContent,
title: `Hello ${userName}, here are your updates!`,
articles: getUserSpecificArticles(userId)
};
Add UTM Trackingβ
// Add UTM parameters for analytics
const trackingUrl = `${article.link}?utm_source=newsletter&utm_medium=email&utm_campaign=weekly`;
Email Client Compatibilityβ
Supported Clientsβ
- β Gmail (Web and Mobile)
- β Outlook (Web and Desktop)
- β Apple Mail
- β Thunderbird
- β Yahoo Mail
- β Native mobile clients
Supported CSS Featuresβ
- β Flexbox and Grid
- β Gradients
- β Rounded borders
- β Shadows
- β Media queries
- β CSS animations (limited)
Best Practicesβ
Contentβ
- Catchy titles - Use emojis and descriptive text
- Short content - Keep it concise and impactful
- Clear CTAs - Make actions obvious
- Optimized images - Max 1MB, use CDN
- Alt text - Always include for accessibility
Technicalβ
- Test thoroughly - Check on different email clients
- Verify links - Test all links before sending
- Respect limits - Follow email provider sending limits
- Monitor metrics - Track open rates, clicks, bounces
Legalβ
- Unsubscribe link - Always include and make it easy
- GDPR compliance - Get explicit consent
- Privacy policy - Link to your privacy policy
- Subscription proof - Keep records of opt-ins
Troubleshootingβ
Images Not Displayingβ
Issue: Images don't show in emails
Solution: Use absolute URLs
// β Bad
image: "/images/logo.png"
// β
Good
image: "https://yourdomain.com/images/logo.png"
Styles Not Appliedβ
Issue: CSS styles not working
Solution: Use inline CSS for critical styles
<p style="color: #333; font-size: 16px;">Text</p>
Emails Going to Spamβ
Issue: Emails end up in spam folder
Solution:
- Avoid spam trigger words
- Set up SPF, DKIM, DMARC records
- Use reputable email service
- Maintain good sender reputation
Analytics and Trackingβ
Recommended Metricsβ
- π Open rate
- π±οΈ Click-through rate
- π Unsubscribe rate
- β±οΈ Reading time
- π Engagement by section
Testing Toolsβ
- Mail Tester - Deliverability testing
- Litmus - Email client testing
- Email on Acid - Comprehensive testing
Next Stepsβ
- Customization - General customization guide
- Deployment - Deploy your application
- Environment Variables - Configure email settings