<?php

namespace App\Http\Controllers;

use App\Mail\MailableRecover;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Mail;

class MailController extends Controller
{
    /**
     * Send a test email.
     *
     * @param Request $request
     * @return \Illuminate\Http\JsonResponse
     */
    public function sendTestEmail(Request $request)
    {
        $request->validate([
            'email' => 'required|email',
            'idUsuario' => 'required|string',
        ]);

        $email = $request->input('email');
        $idUsuario = $request->input('idUsuario');

        // Pass the email and idUsuario to the Mailable
        Mail::to($email)->send(new MailableRecover($idUsuario));

        return response()->json(['message' => 'Correo enviado exitosamente']);
    }
}

