<?php

namespace App\Http\Controllers\API\v1;

use App\Http\Controllers\Controller;
use Illuminate\Http\Request;

use Illuminate\Support\Facades\Mail;
use App\Mail\ContactSchool;

use Exception;

class MailController extends Controller
{
    public function send(Request $request)
    {
        try {

            $data = $request->data;
            $send_to = $request->send_to;

            Mail::to($send_to)->send(new ContactSchool($data));

            return sendResponse([],'Mail sent successfully.');
        } catch (Exception $e) {
            return sendError("Request failed", $e->getMessage(), 400);
        }
    }
}
