Out of the box the routes are NOT protected. Please add proper authorization when using this in public accessible environments.
To quickly provide an email viewer, this package provides two simple UI's:
Blade
Vue.js
Both examples use Tailwind css for the minimal styling of the user interfaces. You can use these examples as a starting point to wire the functionalitity of this package in your own application. Bot examples use CDN's for its assets, so for a production setup, you might want to use proper assets building.
Blade
The Blade UI example is powered by the BladeEmailController endpoints and can be accessed by:
A simple Vue.js example is included to provide a simple starter setup for SPA based applications. The idea of this example is to provide helper methods to display the html and raw versions of the email in a javascript UI. In a real wordt scenario your probabaly want to organize this into separate Single File Components.
This example is powered by the JsonEmailController:
<?php
namespace Axyr\EmailViewer\Http\Controllers;
use Axyr\EmailViewer\Facades\Emails;
use Axyr\EmailViewer\Http\Resources\EmailResource;
use Illuminate\Http\Resources\Json\ResourceCollection;
use Illuminate\Http\Response;
use Symfony\Component\HttpFoundation\Response as SymfonyResponse;
class JsonEmailController
{
public function index(): ResourceCollection
{
$emails = Emails::server()->paginate();
return EmailResource::collection($emails)->preserveQuery();
}
public function show(string|int $id): EmailResource
{
$email = Emails::find($id);
abort_if(! $email, SymfonyResponse::HTTP_NOT_FOUND);
return new EmailResource($email);
}
public function destroy(string|int $id): Response
{
Emails::delete($id);
return response()->noContent();
}
}