2024-06-05 13:33:11 -06:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Http\Controllers;
|
|
|
|
|
|
|
|
use Illuminate\Support\Facades\Mail;
|
2025-05-16 17:37:53 -06:00
|
|
|
use App\Mail\SystemEmail;
|
|
|
|
use Illuminate\Http\Request;
|
2024-06-05 13:33:11 -06:00
|
|
|
|
|
|
|
class SystemMailController extends Controller
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* Send notification
|
|
|
|
*/
|
|
|
|
public function sendNotification()
|
|
|
|
{
|
|
|
|
$message = "This is something important. Probably";
|
|
|
|
Mail::to(env('ADMIN_EMAIL'))->send(new SystemEmail($message));
|
|
|
|
}
|
2025-05-16 17:37:53 -06:00
|
|
|
|
|
|
|
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 (TransportException $e) {
|
|
|
|
$result = [
|
|
|
|
'type' => 'mail_not_good',
|
|
|
|
'message' => 'Mail Not Sent. It\'s cool. Just check mail settings in the .env',
|
|
|
|
];
|
|
|
|
}
|
|
|
|
|
|
|
|
return response()->json($result)->header('Content-Type', 'application/json');
|
|
|
|
}
|
2024-06-05 13:33:11 -06:00
|
|
|
}
|