feat: complete email infrastructure with queue, templates, logging, and API

Adds the full transactional email system:
- Redis queue (QUEUE_CONNECTION=redis), SES config in .env.example
- 3 migrations: organisation_email_settings, organisation_email_templates, email_logs
- EmailTemplateType and EmailLogStatus enums with Dutch defaults
- EmailService as central entry point for all email sending
- SendTransactionalEmail queued job with retries and idempotency
- TransactionalMail mailable with responsive HTML + plain text templates
- Organisation-level branding (colors, logo, footer, reply-to)
- Per-type template overrides with {variable} substitution
- Email log with filtering by status, type, date range, recipient
- Preview and send-test endpoints for template management
- API endpoints: email-settings, email-templates (CRUD), email-logs (read-only)
- Integrated into existing flows: invitations, password reset, email
  verification, registration approval/rejection
- 37 new tests across 4 test files, all existing tests updated

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-04-15 20:12:21 +02:00
parent c64875b6ef
commit 65978104d8
42 changed files with 2420 additions and 48 deletions

View File

@@ -4,6 +4,7 @@ declare(strict_types=1);
use App\Http\Controllers\Api\V1\CheckEmailController;
use App\Http\Controllers\Api\V1\CompanyController;
use App\Http\Controllers\Api\V1\EmailLogController;
use App\Http\Controllers\Api\V1\CrowdListController;
use App\Http\Controllers\Api\V1\CrowdTypeController;
use App\Http\Controllers\Api\V1\EventController;
@@ -15,6 +16,8 @@ use App\Http\Controllers\Api\V1\LogoutController;
use App\Http\Controllers\Api\V1\MeController;
use App\Http\Controllers\Api\V1\MemberController;
use App\Http\Controllers\Api\V1\OrganisationController;
use App\Http\Controllers\Api\V1\OrganisationEmailSettingsController;
use App\Http\Controllers\Api\V1\OrganisationEmailTemplateController;
use App\Http\Controllers\Api\V1\PersonController;
use App\Http\Controllers\Api\V1\PersonFieldValueController;
use App\Http\Controllers\Api\V1\PersonIdentityMatchController;
@@ -163,6 +166,20 @@ Route::middleware('auth:sanctum')->group(function () {
return response()->json(['data' => $categories]);
});
// Email settings & templates
Route::get('email-settings', [OrganisationEmailSettingsController::class, 'show']);
Route::put('email-settings', [OrganisationEmailSettingsController::class, 'update']);
Route::get('email-templates', [OrganisationEmailTemplateController::class, 'index']);
Route::get('email-templates/{type}', [OrganisationEmailTemplateController::class, 'show']);
Route::put('email-templates/{type}', [OrganisationEmailTemplateController::class, 'update']);
Route::delete('email-templates/{type}', [OrganisationEmailTemplateController::class, 'destroy']);
Route::post('email-templates/{type}/preview', [OrganisationEmailTemplateController::class, 'preview']);
Route::post('email-templates/{type}/send-test', [OrganisationEmailTemplateController::class, 'sendTest']);
// Email logs (read-only)
Route::get('email-logs', [EmailLogController::class, 'index']);
// Person tags (organisation settings)
Route::apiResource('person-tags', PersonTagController::class)
->except(['show']);