forked from projects/fipamo
37 lines
968 B
PHP
37 lines
968 B
PHP
<?php
|
|
|
|
namespace App\Http\Controllers\API;
|
|
|
|
use App\Http\Controllers\Controller;
|
|
use Illuminate\Http\Request;
|
|
use Illuminate\Support\Facades\Mail;
|
|
use App\Mail\SystemEmail;
|
|
use Symfony\Component\Mailer\Exception\TransportException;
|
|
|
|
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 (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');
|
|
}
|
|
}
|