- Created MailTestController to handle email sending requests. - Added SendTestMailRequest for validating email input. - Developed MailTestService to manage email sending logic. - Introduced TestMail Mailable for formatting test emails. - Defined API route for sending test emails. - Created EmailIntegrationSeeder to seed email integration settings. - Updated DatabaseSeeder to include EmailIntegrationSeeder. - Added MailTestControllerTest to ensure email sending functionality works as expected.
28 lines
764 B
PHP
28 lines
764 B
PHP
<?php
|
|
|
|
namespace App\Domains\MailTest\Services;
|
|
|
|
use App\Domains\MailTest\Mailables\TestMail;
|
|
use Illuminate\Support\Facades\Mail;
|
|
|
|
class MailTestService
|
|
{
|
|
/**
|
|
* @return array<string, string>
|
|
*/
|
|
public function send(string $recipient, ?string $subject = null, ?string $message = null): array
|
|
{
|
|
$subject ??= 'Prueba de correo de Shopit';
|
|
$message ??= 'Este es un correo de prueba enviado desde Shopit.';
|
|
|
|
Mail::to($recipient)->send(new TestMail($subject, $message));
|
|
|
|
return [
|
|
'message' => 'Correo de prueba enviado correctamente.',
|
|
'recipient' => $recipient,
|
|
'mailer' => (string) config('mail.default'),
|
|
'sent_at' => now()->toIso8601String(),
|
|
];
|
|
}
|
|
}
|