Skip to main content

Email Integration

Set up automated emails for user authentication, notifications, and custom workflows in your Cocobase project.
All email configurations are managed through the Cocobase Dashboard. No code required for setup.

Overview

Cocobase email features:
  • Transactional emails - Welcome, verification, password reset
  • Custom templates - Design emails with HTML/CSS
  • Template variables - Personalize with user data
  • Email triggers - Automated sends based on events
  • SMTP configuration - Use your own email provider
  • Email analytics - Track opens, clicks, deliveries

Default Email Templates

Cocobase provides pre-built templates for common scenarios:

1. Welcome Email

Sent when a new user registers:
  • Triggered automatically on registration
  • Includes: username, account details, getting started tips
  • Can be customized in dashboard

2. Email Verification

Sent to verify user’s email address:
  • Contains verification link
  • Link expires after 24 hours
  • Automatic retry if not verified

3. Password Reset

Sent when user requests password reset:
  • Contains secure reset link
  • Link expires after 1 hour
  • One-time use only

4. Password Changed

Confirmation when password is successfully changed:
  • Includes timestamp and location
  • Security alert

5. Two-Factor Authentication

2FA code delivery:
  • 6-digit verification code
  • Expires after 10 minutes

Email Configuration

Step 1: Access Email Settings

  1. Log in to Cocobase Dashboard
  2. Select your project
  3. Navigate to SettingsEmail Configuration
  4. View email provider and templates

Step 2: Choose Email Provider

Cocobase supports multiple email providers:

Option 1: Cocobase Email (Default)

  • Free tier: 100 emails/day
  • Pro plan: 10,000 emails/day
  • No configuration needed
  • Sent from: noreply@cocobase.cc

Option 2: Custom SMTP

Use your own email service:
  1. Click Custom SMTP
  2. Enter SMTP credentials:
    • Host: smtp.yourprovider.com
    • Port: 587 (or 465 for SSL)
    • Username: Your email or API key
    • Password: Your password or API secret
    • From Email: sender@yourdomain.com
    • From Name: Your App Name
  3. Click Test Connection
  4. Save settings
Supported Providers:
  • SendGrid
  • Mailgun
  • Amazon SES
  • SMTP2GO
  • Gmail (for testing only)
  • Any SMTP server

Option 3: Email API Integration

Integrate with email service APIs:
  1. Select API Integration
  2. Choose provider:
    • SendGrid
    • Mailgun
    • Postmark
    • Amazon SES
  3. Enter API credentials
  4. Configure sending domain
  5. Test and save

Customizing Email Templates

Step 1: Select Template

  1. Email Configuration → Templates
  2. Choose template to customize:
    • Welcome Email
    • Email Verification
    • Password Reset
    • Custom Template

Step 2: Edit Template

Subject Line:
HTML Body:

Step 3: Available Variables

Use these variables in your templates: User Variables:
  • {user_name} - User’s full name
  • {user_email} - User’s email address
  • {user_id} - User’s unique ID
  • {user_username} - Username
  • {user_role} - User’s role
  • Any custom user field: {user.custom_field}
App Variables:
  • {app_name} - Your project name
  • {app_url} - Your application URL
  • {support_email} - Support email address
Action Variables:
  • {verification_link} - Email verification URL
  • {reset_link} - Password reset URL
  • {verification_code} - 2FA or verification code
  • {magic_link} - Passwordless login link
System Variables:
  • {current_date} - Current date
  • {current_time} - Current time
  • {current_year} - Current year

Step 4: Preview & Test

  1. Click Preview to see rendered email
  2. Send test email to yourself
  3. Check inbox and spam folder
  4. Verify links work correctly
  5. Test on mobile and desktop
  6. Save template when satisfied

Custom Email Triggers

Send emails based on custom events and conditions.

Step 1: Create Trigger

  1. Email Configuration → Triggers
  2. Click Create Trigger
  3. Configure trigger:
Trigger Name: Order Confirmation Event: Document Created Collection: orders Conditions:

Step 2: Configure Email

Recipient: {document.customer_email} Subject: Order # Confirmed Template: Select or create custom template Template Variables:

Step 3: Test Trigger

  1. Click Test Trigger
  2. Provide sample document data
  3. Check email delivery
  4. Verify template rendering
  5. Activate trigger

Email Examples

Welcome Email

Password Reset

Order Confirmation

Weekly Digest


Email Best Practices

  • Use clean, minimal design
  • Focus on one call-to-action
  • Avoid large images (slow loading)
  • Test on mobile devices
  • Use system fonts for better rendering
Use user data to make emails relevant and engaging.
  1. Send test emails to yourself
  2. Check on different email clients:
    • Gmail
    • Outlook
    • Apple Mail
    • Mobile apps
  3. Verify all links work
  4. Check spam score
  5. Review on mobile
Don’t use:
  • ALL CAPS IN SUBJECT LINES
  • Excessive exclamation marks!!!
  • Spam trigger words (FREE, WINNER, ACT NOW)
  • Suspicious links
  • Large attachments
Do:
  • Use clear subject lines
  • Include unsubscribe link
  • Authenticate your domain
  • Maintain clean email list

Programmatic Email Sending

While most emails are triggered automatically, you can also send custom emails from your code.

Email Analytics

Track email performance in the dashboard.

Available Metrics

  1. Delivery Rate
    • Total emails sent
    • Successfully delivered
    • Bounced emails
    • Failed deliveries
  2. Engagement
    • Open rate
    • Click-through rate
    • Time to first open
    • Device/client breakdown
  3. Issues
    • Bounce rate (hard/soft)
    • Spam complaints
    • Unsubscribes
    • Blocked emails

Viewing Analytics

  1. Dashboard → Email → Analytics
  2. Select date range
  3. Filter by template
  4. View detailed reports
  5. Export data (CSV)

Improving Deliverability

If open rates are low:
  • Improve subject lines
  • Send at better times
  • Segment your audience
  • A/B test templates
If bounce rate is high:
  • Clean email list
  • Remove invalid addresses
  • Verify email domains
  • Check SMTP configuration
If marked as spam:
  • Add unsubscribe link
  • Authenticate domain (SPF/DKIM)
  • Reduce send frequency
  • Improve email content

Domain Authentication

Improve email deliverability by authenticating your domain.

Step 1: Add DNS Records

  1. Dashboard → Email → Domain Authentication
  2. Click Authenticate Domain
  3. Enter your domain: yourdomain.com
  4. Copy provided DNS records:
SPF Record:
DKIM Record:
DMARC Record:

Step 2: Add Records to DNS Provider

  1. Log in to your DNS provider (Cloudflare, Namecheap, etc.)
  2. Add the records exactly as shown
  3. Wait for DNS propagation (up to 48 hours)

Step 3: Verify

  1. Return to Cocobase dashboard
  2. Click Verify Domain
  3. Wait for confirmation
  4. Start sending authenticated emails

Troubleshooting

Emails Not Being Received

Check:
  1. Spam/junk folder
  2. Email configuration in dashboard
  3. SMTP credentials are correct
  4. Email provider status
  5. Recipient email is valid
Solutions:
  1. Verify variable syntax: {verification_link}
  2. Check template preview
  3. Test with real data
  4. Ensure app URL is configured correctly

Template Not Rendering

Common Issues:
  1. Invalid HTML syntax
  2. Missing closing tags
  3. Undefined variables
  4. CSS compatibility issues
Solutions:
  • Use HTML validator
  • Test template preview
  • Check all variables are defined
  • Use inline CSS

Next Steps

Authentication

Set up user authentication

Role-Based Access

Configure user roles and permissions

Cloud Functions

Automate workflows with functions

Best Practices

Learn optimization tips