fipamo/app/Http/Controllers/API/MailAPIController.php

36 lines
846 B
PHP
Raw Normal View History

<?php
namespace App\Http\Controllers\API;
use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Mail;
use App\Mail\SystemEmail;
class MailAPIController extends Controller
{
public function __construct()
{
}
//init stuff
public function sendNotify(Request $request)
{
$result = [];
try {
Mail::to(env('ADMIN_EMAIL'))->send(new SystemEmail($request->content));
$result = [
'type' => 'mail_good',
'message' => 'Mail Sent',
];
} catch (ERROR $e) {
$result = [
'type' => 'mail_not_good',
'message' => 'Mail Not Sent',
];
}
return response()->json($result)->header('Content-Type', 'application/json');
}
}