63 lines
1.6 KiB
PHP
63 lines
1.6 KiB
PHP
<?php
|
|
|
|
namespace App\Mail;
|
|
|
|
use Illuminate\Bus\Queueable;
|
|
use Illuminate\Contracts\Queue\ShouldQueue;
|
|
use Illuminate\Mail\Mailable;
|
|
use Illuminate\Mail\Mailables\Content;
|
|
use Illuminate\Mail\Mailables\Envelope;
|
|
use Illuminate\Queue\SerializesModels;
|
|
use Illuminate\Support\Facades\Log;
|
|
|
|
class RegistrationVerificationMail extends Mailable implements ShouldQueue
|
|
{
|
|
use Queueable, SerializesModels;
|
|
|
|
public int $tries = 3;
|
|
|
|
public int $timeout = 30;
|
|
|
|
public array $backoff = [60, 300, 900];
|
|
|
|
public function __construct(public readonly string $token)
|
|
{
|
|
$this->onQueue('mail');
|
|
}
|
|
|
|
public function envelope(): Envelope
|
|
{
|
|
return new Envelope(
|
|
subject: 'Verify your Skinbase email',
|
|
);
|
|
}
|
|
|
|
public function content(): Content
|
|
{
|
|
$appUrl = rtrim((string) config('app.url', 'http://localhost'), '/');
|
|
|
|
return new Content(
|
|
view: 'emails.registration-verification',
|
|
with: [
|
|
'verificationUrl' => url('/verify/'.$this->token),
|
|
'expiresInHours' => max(1, (int) config('registration.verify_token_ttl_hours', 24)),
|
|
'supportUrl' => $appUrl . '/support',
|
|
],
|
|
);
|
|
}
|
|
|
|
public function attachments(): array
|
|
{
|
|
return [];
|
|
}
|
|
|
|
public function failed(\Throwable $exception): void
|
|
{
|
|
Log::warning('registration verification mail job failed', [
|
|
'token_prefix' => substr($this->token, 0, 12),
|
|
'message' => $exception->getMessage(),
|
|
'class' => get_class($exception),
|
|
]);
|
|
}
|
|
}
|