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

EndpointMethodDescription
/api/marketing/test-templatePOSTTest any email template with custom variables
/api/marketing/test-email-simpleGETSend a simple test email
/api/marketing/sync-usersPOSTSync users to marketing audience
/api/marketing/cron-jobs/send-welcome-emailGETTrigger welcome email sending
/api/marketing/cron-jobs/send-login-emailGETTrigger login alert email sending
/api/marketing/cron-jobs/send-feedback-emailGETTrigger feedback request email sending
/api/marketing/cron-jobs/send-account-setup-emailGETTrigger 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

  1. Template Selection: Choose the appropriate template based on email purpose
  2. Variable Injection: Add personalization data to the template
  3. HTML Rendering: Convert React components to HTML
  4. Email Sending: Transmit to Resend.com for delivery
  5. Status Handling: Process delivery status and handle errors

Marketing Audience Management

The system includes capabilities for managing marketing audiences:

Key Audience Management Features

  1. User Segmentation: Filter users by activity level or subscription status
  2. Contact Formatting: Prepare user data for Resend.com’s audience system
  3. 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:
// Email service configuration
RESEND_API_KEY=your_resend_api_key
DEFAULT_FROM_EMAIL=noreply@yourdomain.com
DEFAULT_FROM_NAME=Your Company Name

// Marketing configuration
MARKETING_AUDIENCE_ID=your_audience_id

// URLs for email links
NEXT_PUBLIC_WEB_SITE_URL=https://yourdomain.com
NEXT_PUBLIC_WEB_SITE_URL_DASHBOARD=https://app.yourdomain.com
NEXT_PUBLIC_ACCOUNT_URL=https://app.yourdomain.com/account
NEXT_PUBLIC_WEB_SITE_URL_CHROME_EXTENSION=https://chrome.google.com/webstore/...
NEXT_PUBLIC_WEB_SITE_URL_DOC=https://docs.yourdomain.com
NEXT_PUBLIC_FEEDBACK_FORM_URL=https://forms.yourdomain.com/feedback

Security Considerations

The email system implements several security measures:
  1. Environment-Aware Processing: Different behavior in development vs. production
  2. Authorization Checks: API endpoints protected (though currently permissive in development)
  3. Data Handling: Careful processing of user data with appropriate redaction
  4. Error Handling: Comprehensive error handling without exposing sensitive details

Integration with Other Systems

The email system integrates with several other OnlyAutomator components:
  1. User Management: Retrieves user data for emails and audience management
  2. Authentication System: Powers login notification emails
  3. Subscription System: Segments users by subscription status
  4. Analytics: Email-related events can be tracked for analysis
For easier testing, here are direct links to key email functions:

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