Overview
OnlyAutomator’s email system provides a comprehensive solution for all email communications, from transactional messages to marketing campaigns. The system leverages modern technologies to deliver personalized, branded emails with high deliverability.Key Features
- Component-Based Templates: Email templates built with React Email for consistency and maintainability
- Dynamic Personalization: Variable injection for personalized content
- Marketing Audience Management: User segmentation and audience syncing
- Template Testing System: Live preview and testing of email templates
- Production Safeguards: Environment-aware functionality with safety mechanisms
- High Deliverability: Reliable delivery through Resend.com
API Testing
The email system exposes several API endpoints for testing and managing emails. These endpoints can be tested directly using the API Playground below or via the API Reference.API Endpoints
Endpoint | Method | Description |
---|---|---|
/api/marketing/test-template | POST | Test any email template with custom variables |
/api/marketing/test-email-simple | GET | Send a simple test email |
/api/marketing/sync-users | POST | Sync users to marketing audience |
/api/marketing/cron-jobs/send-welcome-email | GET | Trigger welcome email sending |
/api/marketing/cron-jobs/send-login-email | GET | Trigger login alert email sending |
/api/marketing/cron-jobs/send-feedback-email | GET | Trigger feedback request email sending |
/api/marketing/cron-jobs/send-account-setup-email | GET | Trigger account setup email sending |
Test Template API
This API allows you to test any of the email templates with custom variables.Sync Users API
This API allows you to sync users to a marketing audience in Resend.Check Config API
This API allows you to verify the email system configuration.Email Templates
OnlyAutomator implements several email templates for different purposes:Welcome Email
Sent to new users after signup to encourage platform adoption and explain key features. Key Elements:- Personalized greeting using first name
- Call to action to install Chrome extension
- Bullet points of top benefits (time savings, retention increase, etc.)
- 3-step quick start guide
- Social proof via creator testimonial
- Dashboard access link
Login Security Alert
Notifies users of new logins to their account, enhancing security awareness. Key Elements:- Clear security alert header
- Detailed login information (location, device, time, IP)
- Color-coded instructions for unauthorized access
- Secure account button with direct link
- 24/7 security support information
Feedback Request Email
Solicits user feedback after a period of platform usage to improve the product. Key Elements:- Usage summary showing days active
- Specific questions about feature impact
- Incentive for providing feedback (exclusive guide)
- Clear call-to-action button
- Value statement explaining how feedback shapes development
Account Setup Email
Prompts users to complete their account setup, with reminder functionality. Key Elements:- Differentiated content for initial vs. reminder contexts
- Days since signup tracking for reminders
- Clear call-to-action to complete setup
- Support assistance offer
- Brand reinforcement elements
Technical Architecture
The email system is built with a modular architecture that separates concerns:Directory Structure
- /lib/react-email/ - Base directory for email functionality
- /templates/ - Email template components
- /components/ - Shared email components
- /styles/ - Shared email styles
- /utils/ - Email utility functions
- /lib/resend.ts - Resend.com API integration
- /lib/marketing.ts - Marketing audience management
- /app/api/marketing/ - API routes for email functionality
- /app/email-test/ - Testing interface
- /app/email-preview/ - Preview functionality
Email Flow Process
The email sending process follows this sequence:Key Process Steps
- Template Selection: Choose the appropriate template based on email purpose
- Variable Injection: Add personalization data to the template
- HTML Rendering: Convert React components to HTML
- Email Sending: Transmit to Resend.com for delivery
- Status Handling: Process delivery status and handle errors
Marketing Audience Management
The system includes capabilities for managing marketing audiences:Key Audience Management Features
- User Segmentation: Filter users by activity level or subscription status
- Contact Formatting: Prepare user data for Resend.com’s audience system
- Safety Features:
- Dry run mode for testing
- Production safeguards (forced dry runs unless explicitly disabled)
- Data redaction in production
Email Testing System
A dedicated testing system enables previewing and testing email templates:Testing UI Features
- Template Selection: Dropdown with all available templates
- Dynamic Variable Inputs: Form fields specific to the selected template
- Real-time Feedback: Success/error status display
- Testing Isolation: Test emails tagged for filtering
Configuration
The email system requires the following environment variables:Security Considerations
The email system implements several security measures:- Environment-Aware Processing: Different behavior in development vs. production
- Authorization Checks: API endpoints protected (though currently permissive in development)
- Data Handling: Careful processing of user data with appropriate redaction
- Error Handling: Comprehensive error handling without exposing sensitive details
Integration with Other Systems
The email system integrates with several other OnlyAutomator components:- User Management: Retrieves user data for emails and audience management
- Authentication System: Powers login notification emails
- Subscription System: Segments users by subscription status
- Analytics: Email-related events can be tracked for analysis
Quick Links
For easier testing, here are direct links to key email functions:- API Reference - Complete API documentation
- Marketing APIs - All marketing email endpoints
- Test Template API - API for testing templates
- Simple Test Email - Send a simple test email
- Sync Users API - API to sync users to audiences
- Sync Single User - API to sync a specific user
- Cron Jobs - Scheduled email tasks
Detailed Email Template Development
For detailed information on how to create, preview, and use email templates with React Email in OnlyAutomator, please refer to our dedicated React Email Integration documentation. This comprehensive guide covers:- Creating new email templates
- Using shared components and styles
- Previewing email templates during development
- Sending emails using templates
- Best practices for email template development