<?php

namespace App\Http\Controllers;

use App\Mail\EmailName;
use App\Mail\MailName;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Mail;
use Symfony\Component\HttpFoundation\Response;

class EmailController extends Controller
{
    //

    public function sendMail(Request $request)
    {
        $jdsb_mail = 'info@jdsb.co.tz';
        $mailData = [
            'from' => $request->from,
            'subject' => $request->subject,
            'body' => $request->body
        ];
        Mail::to($jdsb_mail)->send(new MailName($mailData));
        return response()->json(['message' => 'Email has been sent'], Response::HTTP_OK);
    }
}
