Files
timebank-cc-public/references/EMAIL-TESTING-GUIDE.md
Ronald Huynen 2547717edb Initial commit
2026-03-23 21:37:59 +01:00

8.3 KiB

Email Testing Guide

This guide explains how to test all transactional emails in the system using the email:send-test artisan command.

Quick Start

List All Available Emails

php artisan email:send-test --list

Send a Specific Email

php artisan email:send-test --type=inactive-warning-1 --receiver=user --id=102

Interactive Mode

Run without options for an interactive menu:

php artisan email:send-test

Available Email Types

Inactive Profile Warnings

Test the automated profile deletion warning emails:

# First warning (2 weeks remaining)
php artisan email:send-test --type=inactive-warning-1 --receiver=user --id=102

# Second warning (1 week remaining)
php artisan email:send-test --type=inactive-warning-2 --receiver=user --id=102

# Final warning (24 hours remaining)
php artisan email:send-test --type=inactive-warning-final --receiver=user --id=102

Supports: user, organization

Account Management

# User account deleted notification
php artisan email:send-test --type=user-deleted --receiver=user --id=102

# Email verification request
php artisan email:send-test --type=verify-email --receiver=user --id=102

# Profile name/link changed notification
php artisan email:send-test --type=profile-link-changed --receiver=user --id=102

# Profile edited by admin notification
php artisan email:send-test --type=profile-edited-by-admin --receiver=user --id=102

Transactions

# Transfer/payment received notification
php artisan email:send-test --type=transfer-received --receiver=user --id=102

Supports: user, organization

Reservations

# Reservation created
php artisan email:send-test --type=reservation-created --receiver=user --id=102

# Reservation cancelled
php artisan email:send-test --type=reservation-cancelled --receiver=user --id=102

# Reservation updated
php artisan email:send-test --type=reservation-updated --receiver=user --id=102

Supports: user, organization

Social Interactions

# New comment/reaction on post
php artisan email:send-test --type=reaction-created --receiver=user --id=102

# Tag added to profile
php artisan email:send-test --type=tag-added --receiver=user --id=102

Supports: user, organization

Command Options

--type

Specifies which email type to send. Use --list to see all available types.

--receiver

Specifies the receiver profile type:

  • user - Individual user profiles
  • organization - Organization profiles
  • admin - Admin profiles
  • bank - Bank profiles

--id

The ID of the receiver profile.

--queue

Send emails via queue instead of immediately:

php artisan email:send-test --type=inactive-warning-1 --receiver=user --id=102 --queue

Then process the queue:

php artisan queue:work --stop-when-empty

--list

Display all available email types with descriptions:

php artisan email:send-test --list

Usage Examples

Test All Inactive Profile Warnings

# Send all 3 warning levels
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

Test Organization Emails

# Get an organization ID first
php artisan tinker --execute="echo App\Models\Organization::first()->id;"

# Then Send test mailing email
php artisan email:send-test --type=transfer-received --receiver=organization --id=1

Test with Queue

# Queue the emails
php artisan email:send-test --type=user-deleted --receiver=user --id=102 --queue
php artisan email:send-test --type=transfer-received --receiver=user --id=102 --queue

# Process all queued emails
php artisan queue:work --stop-when-empty

Finding Profile IDs

Find User ID by Email

php artisan tinker --execute="echo App\Models\User::where('email', 'user@example.com')->first()->id;"

List Recent Users

php artisan tinker --execute="App\Models\User::latest()->take(5)->get(['id', 'name', 'email'])->each(function(\$u) { echo \$u->id . ' - ' . \$u->name . ' (' . \$u->email . ')' . PHP_EOL; });"

List Organizations

php artisan tinker --execute="App\Models\Organization::latest()->take(5)->get(['id', 'name', 'email'])->each(function(\$o) { echo \$o->id . ' - ' . \$o->name . ' (' . \$o->email . ')' . PHP_EOL; });"

Test Data

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 (2 weeks, 1 week, 24 hours)
  • Transaction amounts: Sample amounts formatted correctly
  • Dates: Future dates for reservations
  • Names/URLs: Generated test data with proper formatting

Troubleshooting

Email Not Received

  1. Check if the email was sent successfully (command should show )
  2. Verify the email address is correct
  3. Check spam/junk folders
  4. Verify mail configuration in .env

Receiver Not Found Error

Receiver not found: user #102

Solution: Verify the receiver exists and the ID is correct:

php artisan tinker --execute="echo App\Models\User::find(102) ? 'Found' : 'Not found';"

Invalid Email Type Error

Invalid email type: xyz

Solution: Use --list to see all available types:

php artisan email:send-test --list

Unsupported Receiver Type

Email type 'user-deleted' does not support receiver type 'organization'

Solution: Check which receiver types are supported for that email type using --list.

Theme Testing

Emails use theme-aware colors. Test across all themes by changing TIMEBANK_THEME in .env:

# Test with uuro theme
TIMEBANK_THEME=uuro php artisan email:send-test --type=inactive-warning-1 --receiver=user --id=102

# Test with vegetable theme
TIMEBANK_THEME=vegetable php artisan email:send-test --type=inactive-warning-1 --receiver=user --id=102

# Test with yellow theme
TIMEBANK_THEME=yellow php artisan email:send-test --type=inactive-warning-1 --receiver=user --id=102

# Test with default theme
TIMEBANK_THEME=timebank_cc php artisan email:send-test --type=inactive-warning-1 --receiver=user --id=102

Language Testing

Emails are sent in the receiver's preferred language (lang_preference). To test different languages:

  1. Change a user's language preference:
php artisan tinker --execute="\$u = App\Models\User::find(102); \$u->lang_preference = 'nl'; \$u->save(); echo 'Updated';"
  1. Send test mailing email:
php artisan email:send-test --type=inactive-warning-1 --receiver=user --id=102
  1. Repeat for other languages: en, nl, de, es, fr

Batch Testing Script

Create a bash script to test all emails for a single user:

#!/bin/bash
USER_ID=102

echo "Testing all transactional emails for user #$USER_ID"

php artisan email:send-test --type=inactive-warning-1 --receiver=user --id=$USER_ID --queue
php artisan email:send-test --type=inactive-warning-2 --receiver=user --id=$USER_ID --queue
php artisan email:send-test --type=inactive-warning-final --receiver=user --id=$USER_ID --queue
php artisan email:send-test --type=user-deleted --receiver=user --id=$USER_ID --queue
php artisan email:send-test --type=transfer-received --receiver=user --id=$USER_ID --queue
php artisan email:send-test --type=profile-link-changed --receiver=user --id=$USER_ID --queue
php artisan email:send-test --type=profile-edited-by-admin --receiver=user --id=$USER_ID --queue
php artisan email:send-test --type=verify-email --receiver=user --id=$USER_ID --queue
php artisan email:send-test --type=reservation-created --receiver=user --id=$USER_ID --queue
php artisan email:send-test --type=reservation-cancelled --receiver=user --id=$USER_ID --queue
php artisan email:send-test --type=reservation-updated --receiver=user --id=$USER_ID --queue
php artisan email:send-test --type=reaction-created --receiver=user --id=$USER_ID --queue
php artisan email:send-test --type=tag-added --receiver=user --id=$USER_ID --queue

echo "All emails queued. Processing queue..."
php artisan queue:work --stop-when-empty

echo "✅ All test emails sent!"

Save as test-all-emails.sh, make executable, and run:

chmod +x test-all-emails.sh
./test-all-emails.sh