5.6 KiB
5.6 KiB
Artisan Email Testing Command - Summary
New Artisan Command Created
php artisan email:send-test - A comprehensive command for testing all transactional emails in the system.
Features
13 Email Types Supported
-
Inactive Profile Warnings
inactive-warning-1- First warning (2 weeks remaining)inactive-warning-2- Second warning (1 week remaining)inactive-warning-final- Final warning (24 hours remaining)
-
Account Management
user-deleted- User account deleted notificationverify-email- Email verification requestprofile-link-changed- Profile name/link changedprofile-edited-by-admin- Admin edited profile notification
-
Transactions
transfer-received- Payment/transfer received notification
-
Reservations
reservation-created- New reservation createdreservation-cancelled- Reservation cancelledreservation-updated- Reservation updated
-
Social
reaction-created- New comment/reaction on posttag-added- Tag added to profile
Multiple Receiver Types
user- Individual user profilesorganization- Organization profilesadmin- Admin profilesbank- Bank profiles
Command Modes
1. Direct Command
php artisan email:send-test --type=inactive-warning-1 --receiver=user --id=102
2. Interactive Mode
php artisan email:send-test
# Presents menu to select email type, receiver type, and ID
3. List Mode
php artisan email:send-test --list
# Shows all available email types with descriptions
4. Queue Mode
php artisan email:send-test --type=transfer-received --receiver=user --id=102 --queue
# Sends via queue instead of immediately
Quick Start Examples
Send a Single Email
php artisan email:send-test --type=inactive-warning-1 --receiver=user --id=102
Test All Warning Emails
./test-warning-emails.sh 102
Or manually:
php artisan email:send-test --type=inactive-warning-1 --receiver=user --id=102
php artisan email:send-test --type=inactive-warning-2 --receiver=user --id=102
php artisan email:send-test --type=inactive-warning-final --receiver=user --id=102
List All Available Emails
php artisan email:send-test --list
Interactive Mode
php artisan email:send-test
# Follow the prompts
Test Data Generation
The command automatically generates realistic test data for each email type:
- Account balances: Uses actual account data from the receiver's profile
- Time remaining: Realistic values based on email type
- Transaction amounts: Sample formatted amounts
- Dates: Future dates for reservations
- Names/URLs: Generated test data with proper formatting
Files Created
app/Console/Commands/SendTestEmail.php- Main artisan commandEMAIL-TESTING-GUIDE.md- Comprehensive usage guidetest-warning-emails.sh- Quick script to test all 3 warning emailsARTISAN-EMAIL-COMMAND-SUMMARY.md- This summary
Advantages Over Tinker Script
- Type Safety: Validates email types and receiver types before sending
- Error Handling: Clear error messages for invalid inputs
- User-Friendly: Interactive mode for easy selection
- Comprehensive: Supports 13 different email types
- Flexible: Multiple receiver types (user, organization, admin, bank)
- Queue Support: Option to send via queue
- List View: Easy discovery of all available email types
- Professional CLI: Proper command structure and help text
Migration from Tinker Script
Old Way (Tinker)
php artisan tinker --execute="include 'send-test-warnings.php'; sendTestWarnings(102);"
New Way (Artisan Command)
# Single email
php artisan email:send-test --type=inactive-warning-1 --receiver=user --id=102
# All warnings
./test-warning-emails.sh 102
# Or interactive
php artisan email:send-test
Next Steps
- Test all email types - Verify each email renders correctly
- Test different receivers - Try with user, organization profiles
- Test themes - Send emails with different
TIMEBANK_THEMEvalues - Test languages - Verify emails in all supported languages (en, nl, de, es, fr)
- Review email content - Approve English text for translation
- Create translation keys - Add approved text to language files
Usage Tips
-
Find User IDs:
php artisan tinker --execute="echo App\Models\User::where('email', 'user@example.com')->first()->id;" -
Test Theme Colors:
TIMEBANK_THEME=uuro php artisan email:send-test --type=inactive-warning-1 --receiver=user --id=102 -
Test Language:
# Change user's language first php artisan tinker --execute="\$u = App\Models\User::find(102); \$u->lang_preference = 'nl'; \$u->save();" # Then send email php artisan email:send-test --type=inactive-warning-1 --receiver=user --id=102 -
Batch Testing:
# Queue multiple emails php artisan email:send-test --type=inactive-warning-1 --receiver=user --id=102 --queue php artisan email:send-test --type=inactive-warning-2 --receiver=user --id=102 --queue php artisan email:send-test --type=inactive-warning-final --receiver=user --id=102 --queue # Process queue php artisan queue:work --stop-when-empty
Documentation
See EMAIL-TESTING-GUIDE.md for comprehensive documentation including:
- All available email types
- Command options
- Usage examples
- Troubleshooting guide
- Theme and language testing
- Batch testing scripts