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:
@@ -4,12 +4,15 @@ declare(strict_types=1);
|
||||
|
||||
namespace Tests\Feature\Invitation;
|
||||
|
||||
use App\Enums\EmailTemplateType;
|
||||
use App\Jobs\SendTransactionalEmail;
|
||||
use App\Models\Organisation;
|
||||
use App\Models\User;
|
||||
use App\Models\UserInvitation;
|
||||
use Database\Seeders\RoleSeeder;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use Illuminate\Support\Facades\Mail;
|
||||
use Illuminate\Support\Facades\Queue;
|
||||
use Laravel\Sanctum\Sanctum;
|
||||
use Tests\TestCase;
|
||||
|
||||
@@ -34,7 +37,7 @@ class InvitationTest extends TestCase
|
||||
|
||||
public function test_org_admin_can_invite_user(): void
|
||||
{
|
||||
Mail::fake();
|
||||
Queue::fake();
|
||||
Sanctum::actingAs($this->orgAdmin);
|
||||
|
||||
$response = $this->postJson("/api/v1/organisations/{$this->org->id}/invite", [
|
||||
@@ -48,7 +51,10 @@ class InvitationTest extends TestCase
|
||||
'organisation_id' => $this->org->id,
|
||||
'status' => 'pending',
|
||||
]);
|
||||
Mail::assertQueued(\App\Mail\InvitationMail::class);
|
||||
Queue::assertPushed(SendTransactionalEmail::class, function ($job) {
|
||||
return $job->recipientEmail === 'newuser@test.nl'
|
||||
&& $job->type === EmailTemplateType::INVITATION;
|
||||
});
|
||||
}
|
||||
|
||||
public function test_org_member_cannot_invite_user(): void
|
||||
|
||||
Reference in New Issue
Block a user