Files
cim_summary/backend/EMAIL_SETUP.md
Jon c6d292fe22 Fix email service: resolve malformed environment variable and add email validation
- Fixed malformed WEEKLY_EMAIL_RECIPIENT in .env file
- Added email address validation to prevent malformed emails
- Enhanced logging for better debugging
- Updated email service to use Firebase config in production with env var fallback
- Added proper error handling for invalid email formats
- Deployed fixes to resolve 500 error on weekly email functionality
2025-08-15 09:26:50 -04:00

2.7 KiB

Email Configuration Setup

Overview

This application uses environment variables for email configuration instead of Firebase Functions config (which is being deprecated).

Required Environment Variables

Email Server Configuration

  • EMAIL_HOST - SMTP server host (default: smtp.gmail.com)
  • EMAIL_PORT - SMTP server port (default: 587)
  • EMAIL_SECURE - Use secure connection (default: false)
  • EMAIL_USER - SMTP username/email
  • EMAIL_PASS - SMTP password or app password
  • EMAIL_FROM - From email address (default: noreply@cim-summarizer.com)

Weekly Email Recipients

Setup Instructions

For Local Development

  1. Create a .env file in the backend directory
  2. Add the required environment variables:
EMAIL_HOST=smtp.gmail.com
EMAIL_PORT=587
EMAIL_SECURE=false
EMAIL_USER=your-email@gmail.com
EMAIL_PASS=your-app-password
EMAIL_FROM=noreply@cim-summarizer.com
WEEKLY_EMAIL_RECIPIENT=recipient@example.com

For Firebase Functions (Production)

  1. Set environment variables using Firebase CLI:
firebase functions:config:set email.host="smtp.gmail.com"
firebase functions:config:set email.port="587"
firebase functions:config:set email.secure="false"
firebase functions:config:set email.user="your-email@gmail.com"
firebase functions:config:set email.pass="your-app-password"
firebase functions:config:set email.from="noreply@cim-summarizer.com"
firebase functions:config:set email.weekly_recipient="recipient@example.com"
  1. IMPORTANT: After December 31, 2025, you must migrate to environment variables:
firebase functions:config:unset email

And set environment variables instead:

firebase functions:secrets:set EMAIL_HOST
firebase functions:secrets:set EMAIL_PORT
firebase functions:secrets:set EMAIL_SECURE
firebase functions:secrets:set EMAIL_USER
firebase functions:secrets:set EMAIL_PASS
firebase functions:secrets:set EMAIL_FROM
firebase functions:secrets:set WEEKLY_EMAIL_RECIPIENT
  1. Enable 2-factor authentication on your Gmail account
  2. Generate an App Password:
    • Go to Google Account settings
    • Security → 2-Step Verification → App passwords
    • Generate a password for "Mail"
  3. Use the generated password as EMAIL_PASS

Testing

Use the test script to verify email configuration:

cd backend
npm run test:email

Migration from functions.config()

The application has been updated to use environment variables directly instead of functions.config(). This change ensures compatibility after the Firebase Functions configuration API is deprecated on December 31, 2025.