A Laravel-based CRM application that automatically processes emails to generate leads and notify clients through a Filament admin interface.
- Automated Email Processing: Automatically processes incoming emails and converts them into leads
- Client Management: Manage multiple clients with their contact information and notification preferences
- Distribution Rules: Flexible email routing system with three types of rules:
- Email Match Rules: Route emails based on sender address or domain
- Custom Body Text Rules: Route emails based on content patterns in the email body (e.g., "Source: Facebook AND rep: henry")
- Combined Rules: Route emails that match BOTH email pattern AND body text conditions
- Interactive Kanban Board: Visual lead management with drag-and-drop functionality:
- Real-time Lead Organization: Drag leads between disposition columns (new, contacted, qualified, etc.)
- Customizable Columns: Show/hide disposition columns based on your workflow
- Persistent User Preferences: Column order and visibility settings saved per user across devices
- Lead Notes: Quick access to add and edit lead notes directly from the board
- Responsive Design: Optimized for desktop and mobile with horizontal scrolling support
- Lead Tracking: Track leads through various stages (new, contacted, qualified, converted, lost)
- Admin Interface: Modern admin panel built with Filament for easy management
- Admin Notifications: Configurable email notifications for administrators about system events:
- Email processing success/failure notifications
- Error alerts for SMTP, IMAP, and processing issues
- Alerts when no client rules match incoming emails
- Duplicate lead detection notifications
- Individual notification preferences per admin user
- User Impersonation: Admins can securely log into the client portal as any client user without password changes, with full audit logging
- Notifications: Automatic email notifications to clients when new leads are received
- Multiple Lead Sources: Support for leads from website, phone, referral, social media, and other sources
- Backend: Laravel 12.x (PHP 8.2+)
- Admin Panel: Filament 3.x
- Real-time Updates: Livewire for dynamic UI interactions
- Database: configurable
- Email Processing: PHP-IMAP, Mail-MIME-Parser
- Frontend: Vite + TailwindCSS + Custom JavaScript (drag-and-drop, user preferences)
- Testing: Pest PHP
- PHP 8.2 or higher
- Composer
- SQLite (or MySQL/PostgreSQL if preferred)
- Node.js & npm (optional - only needed for frontend asset compilation)
-
Clone the repository
git clone https://github.com/ElivateDev/Leads cd Leads
-
Install PHP dependencies
composer install
-
Environment Configuration
cp .env.example .env php artisan key:generate
-
Database Setup
Configure your DB settings in the
.env
file:DB_CONNECTION=mysql # or dealer's choice DB_HOST=127.0.0.1 DB_PORT=3306 DB_DATABASE=laravel DB_USERNAME=user DB_PASSWORD=
php artisan migrate
-
Create Admin User
php artisan make:filament-user
-
Optional: Install Node.js dependencies (for frontend customization)
npm install npm run build
Configure your IMAP settings in the .env
file:
IMAP_HOST=your-imap-server.com
IMAP_PORT=993
IMAP_ENCRYPTION=ssl
IMAP_USERNAME=your-email@domain.com
IMAP_PASSWORD=your-password
IMAP_DEFAULT_FOLDER=INBOX
For email notifications, configure your mail settings:
MAIL_MAILER=smtp
MAIL_HOST=your-smtp-server.com
MAIL_PORT=587
MAIL_USERNAME=your-email@domain.com
MAIL_PASSWORD=your-password
MAIL_FROM_ADDRESS="your-email@domain.com"
MAIL_FROM_NAME="Your Company Name"
Set a default client ID for unmatched emails:
DEFAULT_CLIENT_ID=1
Configure default admin notification settings:
# Admin notification defaults (individual admins can override these)
ADMIN_NOTIFY_EMAIL_PROCESSED=false
ADMIN_NOTIFY_ERRORS=true
ADMIN_NOTIFY_RULES_NOT_MATCHED=false
ADMIN_NOTIFY_DUPLICATE_LEADS=false
ADMIN_NOTIFY_IMAP_CONNECTION_ISSUES=true
ADMIN_NOTIFY_SMTP_ISSUES=true
Individual admin users can customize their notification preferences through Administration > Admin Settings in the admin panel.
Process emails manually:
php artisan leads:process-emails
Or set up a cron job for automatic processing:
* * * * * cd /path-to-your-project && php artisan schedule:run >> /dev/null 2>&1
Test admin notification settings:
# Test all notification types for all admins
php artisan admin:test-notifications
# Test specific notification type
php artisan admin:test-notifications --type=error
# Test notifications for specific admin
php artisan admin:test-notifications --admin-email=admin@example.com
The Lead Board provides an interactive kanban-style interface for managing leads visually:
Key Features:
- Drag & Drop: Move leads between disposition columns by dragging lead cards
- Column Management:
- Reorder columns by dragging column headers
- Show/hide columns using the filter panel
- Column order and visibility preferences are saved per user
- Lead Interaction:
- Click on any lead card to quickly add or edit notes
- Lead information displays contact details, source, and current status
- Real-time updates when leads are moved between dispositions
Available Dispositions:
- New: Freshly received leads awaiting initial contact
- Contacted (Attempt 1-3): Leads with ongoing contact attempts
- Qualified: Leads that meet your criteria and show interest
- Scheduled: Leads with scheduled appointments or follow-ups
- Completed: Successfully closed leads
- Warm: Interested leads for future follow-up
- Signed: Leads that have converted to customers
- Lost: Leads that didn't convert
- No Show: Leads that missed scheduled appointments
- Spam: Invalid or unwanted leads
- Recycled: Leads being given another opportunity
User Preferences:
- Column order and visibility settings are automatically saved to your user profile
- Preferences sync across devices and browser sessions
- Local storage provides immediate feedback while database sync happens in the background
Navigation:
- Access the Lead Board from the main navigation menu
- Use horizontal scroll navigation for viewing many columns on smaller screens
- Filter controls allow quick showing/hiding of disposition columns
- Create clients with contact information
- Enable/disable email notifications per client
- Manage multiple email addresses per client for lead routing
The Distribution Rules system allows you to automatically route incoming emails to the correct clients based on the sender's email address, the content of the email body, or both.
Email Match Rules route emails based on the sender's email address:
-
Exact Email Match: Route emails from a specific address
- Example:
info@client.com
→ Routes to Client A - Use case: Direct contact forms or specific email addresses
- Example:
-
Domain Match: Route all emails from a domain
- Example:
@client.com
→ Routes to Client A - Use case: All emails from a client's organization
- Example:
Custom Body Text Rules analyze the email content and route based on patterns:
-
Single Condition: Match a single text pattern
- Example:
Source: Facebook
→ Routes Facebook leads - Use case: Lead forms with source identification
- Example:
-
AND Conditions: All conditions must be met
- Example:
Source: Facebook AND rep: henry
→ Routes Facebook leads for Henry - Use case: Specific combinations of criteria
- Example:
-
OR Conditions: Any condition can be met
- Example:
Source: Facebook OR Source: Instagram
→ Routes social media leads - Use case: Multiple sources going to the same client
- Example:
Combined Rules require BOTH email pattern AND body text conditions to be met:
-
Exact Email + Custom Conditions: Most specific targeting
- Example:
leads@facebook.com
+rep: henry
→ Only Facebook emails for Henry - Use case: Specific rep handling specific source emails
- Example:
-
Domain + Custom Conditions: Broad email filtering with content specificity
- Example:
@zillow.com
+property_type: commercial
→ Only Zillow commercial leads - Use case: Platform-specific content filtering
- Example:
-
Complex Combinations: Multiple conditions on both sides
- Example:
@realtor.com
+agent: sarah AND property_type: residential
- Use case: Highly targeted lead routing
- Example:
- Navigate to "Distribution Rules" in the admin panel
- Click "Create Distribution Rule"
- Select the client to receive matched emails
- Choose rule type:
- Email Address Match: Enter the email address or domain pattern
- Custom Body Text Rule: Enter the conditions using AND/OR logic
- Combined Rule (Email + Body Text): Enter both email pattern AND custom conditions
- Add a description to help identify the rule's purpose
- Ensure the rule is active
All matching rules are processed: When an email arrives, the system checks ALL distribution rules and creates leads for every client that has a matching rule. This means:
- Multiple clients can receive the same lead: If two clients have identical rules (e.g., both want
leads@zillow.com
), both will receive a copy of the lead - No rule priority system: All matching rules are treated equally - there's no "first match wins" behavior
- Comprehensive rule matching: The system processes exact email matches, domain patterns, custom rules, and combined rules to find all possible matches
Best Practices:
- Use specific conditions to avoid unwanted duplicates
- For shared email sources, differentiate rules with custom conditions (e.g.,
rep: john
vsrep: sarah
) - Monitor rule logs to identify overlapping rules that might need adjustment
Rule Types Processed (in this order, but all matches are included):
- Exact email address matches
- Domain pattern matches (@domain.com)
- Custom body text rules
- Combined rules (email + body text)
- Fallback to client domain matching
-
Real Estate Agent with Multiple Sources:
Source: Zillow AND agent: john
→ Routes Zillow leads to JohnSource: Realtor.com AND agent: jane
→ Routes Realtor.com leads to Jane
-
Marketing Agency with Campaign Tracking:
campaign: summer2023 AND product: webdesign
→ Routes to Web Design teamcampaign: summer2023 AND product: seo
→ Routes to SEO team
-
Business with Multiple Locations:
location: downtown
→ Routes to Downtown officelocation: suburbs
→ Routes to Suburban office
-
Combined Rule Examples:
leads@facebook.com
+rep: henry
→ Only Facebook emails for Henry@zillow.com
+property_type: commercial AND agent: sarah
→ Zillow commercial leads for Sarahsupport@company.com
+priority: high OR urgent: true
→ High priority support emails
The system supports multiple clients having identical or overlapping distribution rules. This is useful for:
Lead Distribution Scenarios:
- Team Lead Distribution: Multiple agents want leads from the same source
- Backup Coverage: Primary and backup agents for the same lead source
- Cross-Department Routing: Sales and support teams both need certain emails
Example: Multiple Agents for Zillow Leads
Agent 1: leads@zillow.com → Creates lead for Agent 1
Agent 2: leads@zillow.com → Creates lead for Agent 2
Result: One Zillow email creates leads for both agents
Example: Differentiated Rules for Same Source
Agent 1: leads@zillow.com + "rep: john" → Only John's Zillow leads
Agent 2: leads@zillow.com + "rep: sarah" → Only Sarah's Zillow leads
General: leads@zillow.com → All other Zillow leads
Result: Selective distribution based on email content
Monitoring: Check the Email Processing Logs to see which rules matched for each email and verify leads are being distributed as expected.
- View all leads with filtering and search capabilities
- Update lead status as they progress through your sales funnel
- Track lead sources and contact information
- Basic contact information (name, email, phone, company)
- Email notification preferences
- Contact details (name, email, phone)
- Message content and source information
- Status tracking and client assignment
- Timestamps for lead received date
- Email-to-client mapping system
- Support for multiple emails per client
- Active/inactive status for mappings
- Per-user settings storage for kanban board customization
- JSON-based preference values for flexible data storage
- Tracks column order, visibility settings, and other UI preferences
- Unique constraints to ensure one preference per key per user
- EmailLeadProcessor: Core service for processing incoming emails
- Lead Observer: Handles automatic notifications when leads are created
- Filament Resources: Admin interface for managing clients, leads, and email mappings
- Console Commands: Artisan commands for email processing
- Notifications: Email notification system for new leads
- Connect to IMAP server and fetch unread emails
- Extract sender information, content, and metadata
- Determine appropriate client based on email routing rules
- Parse contact information from email content
- Create lead record and send notifications if enabled
- Fork the repository
- Create a feature branch
- Make your changes
- Run tests:
php artisan test
- Submit a pull request
Run the test suite:
composer run test
Or use Pest directly:
./vendor/bin/pest
If you discover a security vulnerability in this application, please create a private security advisory on GitHub or contact the maintainers directly.
This project is licensed under the MIT License. See the LICENSE file for details.