Mail support testing faze

This commit is contained in:
Simon Pocrnjič
2025-10-07 21:57:10 +02:00
parent 175111bed4
commit b9ca8244ef
18 changed files with 1279 additions and 101 deletions
+31
View File
@@ -0,0 +1,31 @@
<?php
namespace Database\Factories;
use App\Models\MailProfile;
use Illuminate\Database\Eloquent\Factories\Factory;
/**
* @extends Factory<MailProfile>
*/
class MailProfileFactory extends Factory
{
protected $model = MailProfile::class;
public function definition(): array
{
return [
'name' => 'Primary SMTP '.$this->faker->unique()->word(),
'active' => false,
'host' => 'smtp.example.test',
'port' => 587,
'encryption' => 'tls',
'username' => 'user@example.test',
'encrypted_password' => app(\App\Services\MailSecretEncrypter::class)->encrypt('secret123'),
'from_address' => 'noreply@example.test',
'from_name' => 'Example App',
'priority' => 0,
'emails_sent_today' => 0,
];
}
}
@@ -0,0 +1,41 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
public function up(): void
{
Schema::create('mail_profiles', function (Blueprint $table) {
$table->id();
$table->string('name');
$table->boolean('active')->default(false);
$table->string('host');
$table->unsignedSmallInteger('port');
$table->enum('encryption', ['ssl', 'tls', 'starttls'])->nullable();
$table->string('username')->nullable();
$table->text('encrypted_password');
$table->string('from_address');
$table->string('from_name')->nullable();
$table->string('reply_to_address')->nullable();
$table->string('reply_to_name')->nullable();
$table->unsignedSmallInteger('priority')->default(0);
$table->unsignedInteger('max_daily_quota')->nullable();
$table->unsignedInteger('emails_sent_today')->default(0);
$table->timestamp('last_success_at')->nullable();
$table->timestamp('last_error_at')->nullable();
$table->text('last_error_message')->nullable();
$table->foreignId('failover_to_id')->nullable()->constrained('mail_profiles')->nullOnDelete();
$table->string('test_status')->nullable();
$table->timestamp('test_checked_at')->nullable();
$table->timestamps();
});
}
public function down(): void
{
Schema::dropIfExists('mail_profiles');
}
};