mirror of
https://github.com/Gowtham-Darkseid/MailComposer.git
synced 2026-04-24 08:15:58 +02:00
44ea4d2e64
- Rich email composer with formatting tools (bold, italic, underline, links) - Multi-recipient support (To, CC, BCC fields) - File attachments with drag & drop support - Priority levels and email validation - Draft management with auto-save and cloud sync - Real email sending via EmailJS integration - Responsive design for mobile and desktop - Comprehensive error handling and fallback modes - Complete documentation and setup guides - Firebase integration ready for advanced features Features: ✅ Real email sending (EmailJS) ✅ Rich text editor ✅ File attachments ✅ Draft management ✅ Form validation ✅ Responsive UI ✅ Error handling ✅ Documentation
4.9 KiB
4.9 KiB
Firebase Setup Guide for Mail Composer
This guide will help you set up Firebase for your Mail Composer application to send real emails.
Prerequisites
- A Google account
- Node.js installed on your machine
- Firebase CLI installed globally:
npm install -g firebase-tools
Step 1: Create a Firebase Project
- Go to the Firebase Console
- Click "Add project"
- Enter a project name (e.g., "mail-composer")
- Enable Google Analytics (optional)
- Create the project
Step 2: Enable Firestore Database
- In your Firebase project console, go to "Firestore Database"
- Click "Create database"
- Choose "Start in test mode" for now
- Select a location for your database
Step 3: Set up Firebase Functions
- In the Firebase console, go to "Functions"
- Click "Get started"
- This will enable the Cloud Functions API
Step 4: Configure Email Service
Option A: Gmail (Recommended for development)
- Enable 2-factor authentication on your Gmail account
- Generate an App Password:
- Go to Google Account settings
- Security → 2-Step Verification → App passwords
- Generate a password for "Mail"
- Save this password securely
Option B: Other Email Providers
Configure SMTP settings for your email provider (SendGrid, Mailgun, etc.)
Step 5: Configure Your Local Environment
-
Copy the environment file:
cp .env.example .env -
Get your Firebase configuration:
- In Firebase console, go to Project Settings (gear icon)
- Scroll down to "Your apps"
- Click the web icon
</> - Register your app with a nickname
- Copy the config object values
-
Update your
.envfile with the Firebase config values:VITE_FIREBASE_API_KEY=your-actual-api-key VITE_FIREBASE_AUTH_DOMAIN=your-project.firebaseapp.com VITE_FIREBASE_PROJECT_ID=your-actual-project-id VITE_FIREBASE_STORAGE_BUCKET=your-project.appspot.com VITE_FIREBASE_MESSAGING_SENDER_ID=your-actual-sender-id VITE_FIREBASE_APP_ID=your-actual-app-id
Step 6: Deploy Firebase Functions
-
Login to Firebase CLI:
firebase login -
Initialize Firebase in your project:
firebase init- Select "Functions", "Firestore", and "Hosting"
- Choose your existing project
- Accept defaults for most options
-
Install function dependencies:
cd functions npm install cd .. -
Set environment variables for functions:
firebase functions:config:set gmail.user="your-email@gmail.com" firebase functions:config:set gmail.password="your-app-password" -
Deploy functions:
firebase deploy --only functions
Step 7: Update Firestore Security Rules
- Go to Firestore Database → Rules
- Replace the rules with the content from
firestore.rules - Publish the rules
Step 8: Test the Application
-
Start your development server:
npm run dev -
Open the application and try sending a test email
Alternative Email Services
SendGrid
// In functions/index.js, replace the transporter with:
const sgMail = require('@sendgrid/mail');
sgMail.setApiKey(process.env.SENDGRID_API_KEY);
Mailgun
// In functions/index.js, replace the transporter with:
const formData = require('form-data');
const Mailgun = require('mailgun.js');
const mailgun = new Mailgun(formData);
const mg = mailgun.client({
username: 'api',
key: process.env.MAILGUN_API_KEY,
url: 'https://api.mailgun.net' // or 'https://api.eu.mailgun.net'
});
Security Considerations
- Never commit your
.envfile - it's already in.gitignore - Use Firebase Security Rules to protect your Firestore data
- Implement user authentication for production use
- Set rate limits in Firebase Functions to prevent abuse
- Validate all inputs on both client and server side
Troubleshooting
Common Issues
-
"Permission denied" errors
- Check your Firestore security rules
- Ensure your Firebase project is properly configured
-
Email sending fails
- Verify your email credentials
- Check Firebase Functions logs:
firebase functions:log - Ensure "Less secure app access" is disabled and App Password is used
-
"Function not found" errors
- Ensure functions are deployed:
firebase deploy --only functions - Check function names match in your code
- Ensure functions are deployed:
-
CORS errors
- Functions should handle CORS automatically
- Check browser developer console for specific errors
Getting Help
- Check Firebase Functions logs:
firebase functions:log - View Firestore data in the Firebase console
- Check browser developer console for client-side errors
Production Deployment
-
Build the application:
npm run build -
Deploy to Firebase Hosting:
firebase deploy
Your application will be available at https://your-project-id.web.app