Email Configuration Guide
This guide explains how to set up and use email configurations for dev.meo-mai-moi.com.
Quick Setup
Using the Artisan Command (Recommended)
bash
# Set up configurations with your credentials
php artisan email:setup \
--smtp-username=your-email@gmail.com \
--smtp-password=your-app-password \
--mailgun-api-key=key-your-actual-api-key \
--activate=smtp
# Or set up without credentials (update later in admin panel)
php artisan email:setupUsing Database Seeder
bash
php artisan db:seed --class=EmailConfigurationSeederConfiguration Details
Both SMTP and Mailgun configurations are pre-configured with:
- Domain:
dev.meo-mai-moi.com - From Email:
mail@meo-mai-moi.com - From Name:
Meo Mai Moi - Test Email:
pavel@catarchy.space
SMTP Configuration
- Host:
smtp.gmail.com - Port:
587 - Encryption:
tls - Username: Your Gmail address
- Password: Your Gmail app password
Mailgun Configuration
- Domain:
dev.meo-mai-moi.com - Endpoint:
api.mailgun.net - API Key: Your Mailgun API key
Admin Panel Usage
Accessing Email Configurations
- Go to
/admin/email-configurations - View, edit, or create new configurations
- Test configurations using the "Send Test Email" button
Testing Email Configurations
- Both SMTP and Mailgun now require a Test Email Address
- Test emails are sent to
pavel@catarchy.spaceby default - All test emails now appear in
/admin/email-logs
Viewing Email Logs
- Go to
/admin/email-logs - View all sent emails including test emails
- Check delivery status and error messages
- Retry failed emails if needed
Email Status Lifecycle
Email logs track the full delivery lifecycle with Mailgun webhook integration:
- pending: Initial state when queued
- accepted: Mailgun has accepted the email for delivery (replaces legacy "sent" status)
- delivered: Email successfully delivered to recipient's mail server
- opened: Recipient opened the email (tracking pixel)
- clicked: Recipient clicked a link in the email
- unsubscribed: Recipient unsubscribed via Mailgun
- complained: Recipient marked email as spam
- failed: Permanent delivery failure
Additional tracking fields:
opened_at,clicked_at,unsubscribed_at,complained_at,permanent_fail_at
Idempotency Protection
Email verification notifications use idempotency to prevent duplicate sends:
- Default window: 30 seconds (configurable via
EMAIL_VERIFICATION_IDEMPOTENCY_SECONDS) - Applied at: notification channel, registration response, resend endpoint
- See
config/notifications.phpfor configuration
Mailgun Webhook Setup
Configure webhook in Mailgun dashboard to track delivery events:
POST /webhooks/mailgunRequired events: delivered, opened, clicked, unsubscribed, complained, permanent_fail
New Features
✅ Test Email Address for Mailgun
- Mailgun configurations now have a "Test Email Address" field
- Consistent experience between SMTP and Mailgun
- Required for sending test emails
✅ Test Emails in Email Logs
- All test emails are now logged in the database
- Visible in the admin panel at
/admin/email-logs - Proper status tracking (pending → sent/failed)
- Error messages for failed test emails
Troubleshooting
Test Email Not Received
- Check
/admin/email-logsfor delivery status - Verify the test email address is correct
- Check spam folder
- Ensure email configuration is valid and active
Database Connection Issues
If you see database connection errors:
- Ensure your database is running
- Check your
.envfile database settings - Run
php artisan migrateif needed
Gmail SMTP Issues
- Use an App Password, not your regular password
- Enable 2-factor authentication first
- Generate App Password in Google Account settings
Mailgun Issues
- Verify your domain is properly configured in Mailgun
- Check your API key is correct and active
- Ensure your domain is verified in Mailgun dashboard
Commands Reference
bash
# Setup email configurations
php artisan email:setup
# Setup with credentials
php artisan email:setup --smtp-username=email@gmail.com --smtp-password=password
# Setup and activate SMTP
php artisan email:setup --activate=smtp
# Setup and activate Mailgun
php artisan email:setup --activate=mailgun
# Run email configuration seeder
php artisan db:seed --class=EmailConfigurationSeeder
# Check migration status
php artisan migrate:status
# Run migrations
php artisan migrateSecurity Notes
- Never commit real credentials to version control
- Use environment variables for sensitive data
- Regularly rotate API keys and passwords
- Use App Passwords for Gmail SMTP