A Ruby on Rails email aggregator that allows you to consolidate multiple email accounts into a single unified inbox.
- User authentication with Devise
- Support for multiple email accounts per user
- IMAP email synchronization
- Background job processing with Sidekiq
- Email message pagination
- Read/unread status tracking
- Attachment detection
- Rate limiting with Rack::Attack
- Incremental email syncing (only fetches new messages)
- Ruby 3.4.7
- Rails 8.1.1
- PostgreSQL
- Sidekiq for background jobs
- Redis for job queue
- Devise for authentication
- Kaminari for pagination
- Rack::Attack for rate limiting
- Ruby 3.4.7 (use rbenv or rvm)
- PostgreSQL (version 9.3+)
- Redis (for Sidekiq)
- Bundler
- Clone the repository:
git clone <repository-url>
cd Emerail- Install dependencies:
bundle install- Setup environment variables:
Create a
.envfile in the root directory:
# Database (optional if using defaults)
DATABASE_URL=postgresql://localhost/emerail_development
# Rails
RAILS_ENV=development- Create and setup the database:
rails db:create
rails db:migrateYou need to run three separate processes:
redis-serverIn a new terminal:
bundle exec sidekiqIn another terminal:
rails serverThe application will be available at http://localhost:3000
- Visit
http://localhost:3000/users/sign_up - Register with your email and password
- Navigate to
/email_accounts/new - Fill in your IMAP details:
- Provider: Select "imap"
- IMAP Host: e.g.,
imap.gmail.com - IMAP Port: e.g.,
993 - IMAP SSL: Check if using SSL/TLS
- Username: Your email address
- Password: Your email password or app-specific password
Emails are synced automatically via background jobs. To manually trigger a sync:
rails consoleThen run:
account = EmailAccount.first
SyncEmailAccountJob.perform_async(account.id)- Visit
http://localhost:3000to see your aggregated emails - Click on any email to view its full content
- Emails are automatically marked as read when viewed
Edit app/services/email_sync_service.rb to adjust:
BATCH_SIZE: Number of emails to process at once (default: 50)DEFAULT_SYNC_DAYS: How many days back to sync on first sync (default: 30)
Edit config/initializers/rack_attack.rb to adjust rate limits:
- Login attempts: 5 per minute per email
- Signups: 5 per 5 minutes per IP
- API requests: 300 per 5 minutes per IP
- Email account creation: 10 per hour per IP
Edit app/controllers/email_messages_controller.rb to change items per page (default: 50)
- IMAP Host:
imap.gmail.com - IMAP Port:
993 - SSL: Yes
- Note: You'll need to use an App Password (not your regular password)
- Enable IMAP in Gmail settings
- IMAP Host:
outlook.office365.com - IMAP Port:
993 - SSL: Yes
- IMAP Host:
imap.mail.yahoo.com - IMAP Port:
993 - SSL: Yes
- Note: You'll need to use an App Password
- Email authentication with Devise
- Has many email accounts
- Belongs to a user
- Stores IMAP credentials (encrypted password)
- Tracks last sync time
- Supports multiple providers (IMAP, Gmail OAuth, Outlook OAuth)
- Belongs to an email account
- Stores message content, metadata, and status
- Tracks read/unread status
- Detects attachments
rails testrails consolerails dbconsoleThe project includes Docker support via Kamal. See .kamal/ directory for deployment configuration.
- Email passwords are encrypted using
has_secure_password - Rate limiting is enabled to prevent abuse
- User authentication required for all email operations
- Unique message IDs prevent duplicate emails
- OAuth support for Gmail and Outlook
- Email search functionality
- Folder/label support
- Email composition and sending
- Attachment downloads
- Email filtering and rules
- Mobile responsive design
- Email threading
This project is available as open source.
- Fork the repository
- Create your feature branch
- Commit your changes
- Push to the branch
- Create a Pull Request