Added Fetch Email on page load
This commit is contained in:
@@ -1,62 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Livewire;
|
|
||||||
|
|
||||||
use App\Models\ZEmail;
|
|
||||||
use Livewire\Component;
|
|
||||||
use Livewire\WithPagination;
|
|
||||||
|
|
||||||
class EmailInbox extends Component
|
|
||||||
{
|
|
||||||
use WithPagination;
|
|
||||||
|
|
||||||
public $currentEmail;
|
|
||||||
public $messages = [];
|
|
||||||
public $selectedMessage = null;
|
|
||||||
public $searchTerm = '';
|
|
||||||
public $refreshInterval = 30; // seconds
|
|
||||||
|
|
||||||
public function mount()
|
|
||||||
{
|
|
||||||
$this->currentEmail = ZEmail::getEmail();
|
|
||||||
$this->loadMessages();
|
|
||||||
}
|
|
||||||
|
|
||||||
public function loadMessages()
|
|
||||||
{
|
|
||||||
if ($this->currentEmail) {
|
|
||||||
$this->messages = ZEmail::getMessages($this->currentEmail);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public function selectMessage($messageId)
|
|
||||||
{
|
|
||||||
$this->selectedMessage = $messageId;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function deleteMessage($messageId)
|
|
||||||
{
|
|
||||||
ZEmail::deleteMessage($messageId);
|
|
||||||
$this->loadMessages();
|
|
||||||
$this->selectedMessage = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function generateNewEmail()
|
|
||||||
{
|
|
||||||
$this->currentEmail = ZEmail::generateRandomEmail();
|
|
||||||
$this->loadMessages();
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getPollingInterval()
|
|
||||||
{
|
|
||||||
return $this->refreshInterval * 1000; // Convert to milliseconds
|
|
||||||
}
|
|
||||||
|
|
||||||
public function render()
|
|
||||||
{
|
|
||||||
return view('livewire.email-inbox', [
|
|
||||||
'messages' => $this->messages,
|
|
||||||
'currentEmail' => $this->currentEmail
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -65,7 +65,8 @@ class Action extends Component
|
|||||||
$this->dispatch('closeModal');
|
$this->dispatch('closeModal');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function deleteEmail() {
|
public function deleteEmail(): void
|
||||||
|
{
|
||||||
ZEmail::removeEmail($this->email);
|
ZEmail::removeEmail($this->email);
|
||||||
// if (count($this->emails) <= 1 && json_decode(config('app.settings.configuration_settings'))->after_last_email_delete == 'redirect_to_homepage') {
|
// if (count($this->emails) <= 1 && json_decode(config('app.settings.configuration_settings'))->after_last_email_delete == 'redirect_to_homepage') {
|
||||||
// return redirect()->route('home');
|
// return redirect()->route('home');
|
||||||
@@ -82,7 +83,8 @@ class Action extends Component
|
|||||||
$this->dispatch('showAlert', ['type' => $type, 'message' => $message]);
|
$this->dispatch('showAlert', ['type' => $type, 'message' => $message]);
|
||||||
}
|
}
|
||||||
|
|
||||||
private function checkEmailLimit() {
|
private function checkEmailLimit(): bool
|
||||||
|
{
|
||||||
$logs = Log::select('ip', 'email')->where('ip', request()->ip())->where('created_at', '>', Carbon::now()->subDay())->groupBy('email')->groupBy('ip')->get();
|
$logs = Log::select('ip', 'email')->where('ip', request()->ip())->where('created_at', '>', Carbon::now()->subDay())->groupBy('email')->groupBy('ip')->get();
|
||||||
if (count($logs) >= json_decode(config('app.settings.configuration_settings'))->email_limit) {
|
if (count($logs) >= json_decode(config('app.settings.configuration_settings'))->email_limit) {
|
||||||
return false;
|
return false;
|
||||||
@@ -90,7 +92,8 @@ class Action extends Component
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private function checkUsedEmail() {
|
private function checkUsedEmail(): bool
|
||||||
|
{
|
||||||
if (json_decode(config('app.settings.configuration_settings'))->disable_used_email) {
|
if (json_decode(config('app.settings.configuration_settings'))->disable_used_email) {
|
||||||
$check = Log::where('email', $this->user . '@' . $this->domain)->where('ip', '<>', request()->ip())->count();
|
$check = Log::where('email', $this->user . '@' . $this->domain)->where('ip', '<>', request()->ip())->count();
|
||||||
if ($check > 0) {
|
if ($check > 0) {
|
||||||
|
|||||||
15
app/Livewire/Frontend/Components/Mail.php
Normal file
15
app/Livewire/Frontend/Components/Mail.php
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Livewire\Frontend\Components;
|
||||||
|
|
||||||
|
use Livewire\Component;
|
||||||
|
|
||||||
|
class Mail extends Component
|
||||||
|
{
|
||||||
|
public $message;
|
||||||
|
|
||||||
|
public function render()
|
||||||
|
{
|
||||||
|
return view('livewire.frontend.components.mail')->with(['message' => $this->message]);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -47,6 +47,8 @@ class Email extends Component
|
|||||||
$this->dispatch('getEmail');
|
$this->dispatch('getEmail');
|
||||||
}
|
}
|
||||||
$this->checkMultipleEmails();
|
$this->checkMultipleEmails();
|
||||||
|
$this->dispatch('syncMailbox', $this->email);
|
||||||
|
$this->dispatch('fetchMessages');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function generateEmail(): void
|
public function generateEmail(): void
|
||||||
|
|||||||
@@ -7,30 +7,34 @@ use App\Models\ZEmail;
|
|||||||
use Illuminate\Support\Facades\Auth;
|
use Illuminate\Support\Facades\Auth;
|
||||||
use Livewire\Component;
|
use Livewire\Component;
|
||||||
|
|
||||||
class App extends Component
|
class Mailbox extends Component
|
||||||
{
|
{
|
||||||
public $messages = [];
|
public $messages = [];
|
||||||
public $deleted = [];
|
public $deleted = [];
|
||||||
public $error = '';
|
public $error = '';
|
||||||
public $email;
|
public $email;
|
||||||
public $initial;
|
public $initial = false;
|
||||||
|
public $type;
|
||||||
public $overflow = false;
|
public $overflow = false;
|
||||||
|
|
||||||
protected $listeners = ['fetchMessages' => 'fetch', 'syncEmail'];
|
protected $listeners = ['fetchMessages' => 'fetch', 'syncMailbox' => 'syncEmail'];
|
||||||
|
|
||||||
public function mount()
|
public function mount(): void
|
||||||
{
|
{
|
||||||
$this->email = ZEmail::getEmails();
|
$this->email = ZEmail::getEmail();
|
||||||
|
$this->initial = false;
|
||||||
|
}
|
||||||
|
public function syncEmail($email): void
|
||||||
|
{
|
||||||
|
$this->email = $email;
|
||||||
$this->initial = false;
|
$this->initial = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function syncEmail($email) {
|
public function fetch(): void
|
||||||
$this->email = $email;
|
{
|
||||||
}
|
|
||||||
|
|
||||||
public function fetch() {
|
|
||||||
try {
|
try {
|
||||||
$count = count($this->messages);
|
$count = count($this->messages);
|
||||||
|
|
||||||
$responses = [];
|
$responses = [];
|
||||||
if (config('app.beta_feature') || !json_decode(config('app.settings.imap_settings'))->cc_check) {
|
if (config('app.beta_feature') || !json_decode(config('app.settings.imap_settings'))->cc_check) {
|
||||||
$responses = [
|
$responses = [
|
||||||
@@ -46,18 +50,36 @@ class App extends Component
|
|||||||
'cc' => ZEmail::getMessages($this->email, 'cc', $this->deleted)
|
'cc' => ZEmail::getMessages($this->email, 'cc', $this->deleted)
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// $responses = [
|
||||||
|
// 'to' => ZEmail::getMessages($this->email, 'to', $this->deleted),
|
||||||
|
// ];
|
||||||
|
// $imapSettings = json_decode(config('app.settings.imap_settings'));
|
||||||
|
// $betaFeature = config('app.beta_feature');
|
||||||
|
//
|
||||||
|
// if ($betaFeature || empty($imapSettings?->cc_check)) {
|
||||||
|
// $responses['cc'] = [
|
||||||
|
// 'data' => [],
|
||||||
|
// 'notifications' => []
|
||||||
|
// ];
|
||||||
|
// } else {
|
||||||
|
// $responses['cc'] = ZEmail::getMessages($this->email, 'cc', $this->deleted);
|
||||||
|
// }
|
||||||
|
|
||||||
$this->deleted = [];
|
$this->deleted = [];
|
||||||
$this->messages = array_merge($responses['to']['data'], $responses['cc']['data']);
|
$this->messages = array_merge($responses['to']['data'], $responses['cc']['data']);
|
||||||
$notifications = array_merge($responses['to']['notifications'], $responses['cc']['notifications']);
|
$notifications = array_merge($responses['to']['notifications'], $responses['cc']['notifications']);
|
||||||
|
|
||||||
if (count($notifications)) {
|
if (count($notifications)) {
|
||||||
if ($this->overflow == false && count($this->messages) == $count) {
|
if (!$this->overflow && count($this->messages) == $count) {
|
||||||
$this->overflow = true;
|
$this->overflow = true;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$this->overflow = false;
|
$this->overflow = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach ($notifications as $notification) {
|
foreach ($notifications as $notification) {
|
||||||
$this->dispatchBrowserEvent('showNewMailNotification', $notification);
|
$this->dispatch('showNewMailNotification', $notification);
|
||||||
}
|
}
|
||||||
ZEmail::incrementMessagesStats(count($notifications));
|
ZEmail::incrementMessagesStats(count($notifications));
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
@@ -67,8 +89,8 @@ class App extends Component
|
|||||||
$this->error = 'Not able to connect to Mail Server';
|
$this->error = 'Not able to connect to Mail Server';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$this->dispatchBrowserEvent('stopLoader');
|
$this->dispatch('stopLoader');
|
||||||
$this->dispatchBrowserEvent('loadDownload');
|
$this->dispatch('loadDownload');
|
||||||
$this->initial = true;
|
$this->initial = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -88,8 +110,9 @@ class App extends Component
|
|||||||
|
|
||||||
public function render()
|
public function render()
|
||||||
{
|
{
|
||||||
return view('livewire.frontend.app');
|
return view('livewire.frontend.mailbox')->with(['messages' => $this->messages, 'email' => $this->email, 'initial' => $this->initial, 'error' => $this->error]);
|
||||||
}
|
}
|
||||||
|
|
||||||
private function rrmdir($dir): void
|
private function rrmdir($dir): void
|
||||||
{
|
{
|
||||||
if (is_dir($dir)) {
|
if (is_dir($dir)) {
|
||||||
@@ -105,5 +128,4 @@ class App extends Component
|
|||||||
rmdir($dir);
|
rmdir($dir);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -123,7 +123,6 @@ class Message extends Model
|
|||||||
} else {
|
} else {
|
||||||
$search->addCondition(new To($email));
|
$search->addCondition(new To($email));
|
||||||
}
|
}
|
||||||
$search->addCondition(new Since((new \DateTime('-1 day'))));
|
|
||||||
$messages = $mailbox->getMessages($search, \SORTDATE, true);
|
$messages = $mailbox->getMessages($search, \SORTDATE, true);
|
||||||
$limit = json_decode(config('app.settings.configuration_settings'))->fetch_messages_limit ?? 15;
|
$limit = json_decode(config('app.settings.configuration_settings'))->fetch_messages_limit ?? 15;
|
||||||
$count = 1;
|
$count = 1;
|
||||||
@@ -148,11 +147,16 @@ class Message extends Model
|
|||||||
}
|
}
|
||||||
$datediff = new Carbon($date);
|
$datediff = new Carbon($date);
|
||||||
$content = '';
|
$content = '';
|
||||||
|
$contentText = '';
|
||||||
$html = $message->getBodyHtml();
|
$html = $message->getBodyHtml();
|
||||||
|
|
||||||
|
$text = $message->getBodyText();
|
||||||
|
if ($text) {
|
||||||
|
$contentText = str_replace('<a', '<a target="blank"', str_replace(array("\r\n", "\n"), '', $text));
|
||||||
|
}
|
||||||
if ($html) {
|
if ($html) {
|
||||||
$content = str_replace('<a', '<a target="blank"', $html);
|
$content = str_replace('<a', '<a target="blank"', $html);
|
||||||
} else {
|
} else {
|
||||||
$text = $message->getBodyText();
|
|
||||||
$content = str_replace('<a', '<a target="blank"', str_replace(array("\r\n", "\n"), '<br/>', $text));
|
$content = str_replace('<a', '<a target="blank"', str_replace(array("\r\n", "\n"), '<br/>', $text));
|
||||||
}
|
}
|
||||||
if (json_decode(config('app.settings.configuration_settings'))->enable_masking_external_link) {
|
if (json_decode(config('app.settings.configuration_settings'))->enable_masking_external_link) {
|
||||||
@@ -167,6 +171,7 @@ class Message extends Model
|
|||||||
$obj['datediff'] = $datediff->diffForHumans();
|
$obj['datediff'] = $datediff->diffForHumans();
|
||||||
$obj['id'] = $message->getNumber();
|
$obj['id'] = $message->getNumber();
|
||||||
$obj['content'] = $content;
|
$obj['content'] = $content;
|
||||||
|
$obj['contentText'] = $contentText;
|
||||||
$obj['attachments'] = [];
|
$obj['attachments'] = [];
|
||||||
//Checking if Sender is Blocked
|
//Checking if Sender is Blocked
|
||||||
$domain = explode('@', $obj['sender_email'])[1];
|
$domain = explode('@', $obj['sender_email'])[1];
|
||||||
@@ -224,125 +229,4 @@ class Message extends Model
|
|||||||
$connection->expunge();
|
$connection->expunge();
|
||||||
return $response;
|
return $response;
|
||||||
}
|
}
|
||||||
|
|
||||||
// public static function fetchMessages($email, $type = 'to', $deleted = []): array
|
|
||||||
// {
|
|
||||||
// $startTime = microtime(true);
|
|
||||||
// $allowed = explode(',', 'doc,docx,xls,xlsx,ppt,pptx,xps,pdf,dxf,ai,psd,eps,ps,svg,ttf,zip,rar,tar,gzip,mp3,mpeg,wav,ogg,jpeg,jpg,png,gif,bmp,tif,webm,mpeg4,3gpp,mov,avi,mpegs,wmv,flx,txt');
|
|
||||||
// $connection = ZEmail::connectMailBox();
|
|
||||||
//
|
|
||||||
// $mailbox = $connection->getMailbox('INBOX');
|
|
||||||
// $search = new SearchExpression();
|
|
||||||
// if ($type == 'cc') {
|
|
||||||
// $search->addCondition(new Cc($email));
|
|
||||||
// } else {
|
|
||||||
// $search->addCondition(new To($email));
|
|
||||||
// }
|
|
||||||
// $search->addCondition(new Since((new \DateTime('-1 day'))));
|
|
||||||
// $stepStart = microtime(true);
|
|
||||||
// $messages = $mailbox->getMessages($search, \SORTDATE, true);
|
|
||||||
// \Log::info("1111 messages took: " . (microtime(true) - $stepStart));
|
|
||||||
//
|
|
||||||
// $limit = json_decode(config('app.settings.configuration_settings'))->fetch_messages_limit ?? 15;
|
|
||||||
// $count = 1;
|
|
||||||
// $response = [
|
|
||||||
// 'data' => [],
|
|
||||||
// 'notifications' => []
|
|
||||||
// ];
|
|
||||||
//
|
|
||||||
// foreach ($messages as $message) {
|
|
||||||
// if (in_array($message->getNumber(), $deleted)) {
|
|
||||||
// $message->delete();
|
|
||||||
// continue;
|
|
||||||
// }
|
|
||||||
// $blocked = false;
|
|
||||||
// $sender = $message->getFrom();
|
|
||||||
// $date = $message->getDate();
|
|
||||||
// if (!$date) {
|
|
||||||
// $date = new \DateTime();
|
|
||||||
// if ($message->getHeaders()->get('udate')) {
|
|
||||||
// $date->setTimestamp($message->getHeaders()->get('udate'));
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// $datediff = new Carbon($date);
|
|
||||||
// $content = '';
|
|
||||||
// $html = $message->getBodyHtml();
|
|
||||||
// if ($html) {
|
|
||||||
// $content = str_replace('<a', '<a target="blank"', $html);
|
|
||||||
// } else {
|
|
||||||
// $text = $message->getBodyText();
|
|
||||||
// $content = str_replace('<a', '<a target="blank"', str_replace(array("\r\n", "\n"), '<br/>', $text));
|
|
||||||
// }
|
|
||||||
// if (json_decode(config('app.settings.configuration_settings'))->enable_masking_external_link) {
|
|
||||||
// $content = str_replace('href="', 'href="http://href.li/?', $content);
|
|
||||||
// }
|
|
||||||
// $obj = [];
|
|
||||||
// $obj['subject'] = $message->getSubject();
|
|
||||||
// $obj['sender_name'] = $sender->getName();
|
|
||||||
// $obj['sender_email'] = $sender->getAddress();
|
|
||||||
// $obj['timestamp'] = $message->getDate();
|
|
||||||
// $obj['date'] = $date->format(json_decode(config('app.settings.configuration_settings'))->date_format ?? 'd M Y h:i A');
|
|
||||||
// $obj['datediff'] = $datediff->diffForHumans();
|
|
||||||
// $obj['id'] = $message->getNumber();
|
|
||||||
// $obj['content'] = $content;
|
|
||||||
// $obj['attachments'] = [];
|
|
||||||
// //Checking if Sender is Blocked
|
|
||||||
// $domain = explode('@', $obj['sender_email'])[1];
|
|
||||||
// $blocked = in_array($domain, json_decode(config('app.settings.configuration_settings'))->blocked_domains);
|
|
||||||
// if ($blocked) {
|
|
||||||
// $obj['subject'] = __('Blocked');
|
|
||||||
// $obj['content'] = __('Emails from') . ' ' . $domain . ' ' . __('are blocked by Admin');
|
|
||||||
// }
|
|
||||||
// if ($message->hasAttachments() && !$blocked) {
|
|
||||||
// $attachments = $message->getAttachments();
|
|
||||||
// $directory = './tmp/attachments/' . $obj['id'] . '/';
|
|
||||||
// is_dir($directory) || mkdir($directory, 0777, true);
|
|
||||||
// foreach ($attachments as $attachment) {
|
|
||||||
// $filenameArray = explode('.', $attachment->getFilename());
|
|
||||||
// $extension = $filenameArray[count($filenameArray) - 1];
|
|
||||||
// if (in_array($extension, $allowed)) {
|
|
||||||
// if (!file_exists($directory . $attachment->getFilename())) {
|
|
||||||
// file_put_contents(
|
|
||||||
// $directory . $attachment->getFilename(),
|
|
||||||
// $attachment->getDecodedContent()
|
|
||||||
// );
|
|
||||||
// }
|
|
||||||
// if ($attachment->getFilename() !== 'undefined') {
|
|
||||||
// $url = config('app.settings.app_base_url') . str_replace('./', '/', $directory . $attachment->getFilename());
|
|
||||||
// $structure = $attachment->getStructure();
|
|
||||||
// if (isset($structure->id) && str_contains($obj['content'], trim($structure->id, '<>'))) {
|
|
||||||
// $obj['content'] = str_replace('cid:' . trim($structure->id, '<>'), $url, $obj['content']);
|
|
||||||
// }
|
|
||||||
// $obj['attachments'][] = [
|
|
||||||
// 'file' => $attachment->getFilename(),
|
|
||||||
// 'url' => $url
|
|
||||||
// ];
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// $response['data'][] = $obj;
|
|
||||||
// if (!$message->isSeen()) {
|
|
||||||
// $response['notifications'][] = [
|
|
||||||
// 'subject' => $obj['subject'],
|
|
||||||
// 'sender_name' => $obj['sender_name'],
|
|
||||||
// 'sender_email' => $obj['sender_email']
|
|
||||||
// ];
|
|
||||||
// if (config('app.zemail_log')) {
|
|
||||||
// file_put_contents(storage_path('logs/zemail.csv'), request()->ip() . "," . date("Y-m-d h:i:s a") . "," . $obj['sender_email'] . "," . $email . PHP_EOL, FILE_APPEND);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// $message->markAsSeen();
|
|
||||||
// if (++$count > $limit) {
|
|
||||||
// break;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// $response['data'] = array_reverse($response['data']);
|
|
||||||
// $connection->expunge();
|
|
||||||
// $endTime = microtime(true);
|
|
||||||
// $executionTime = $endTime - $startTime;
|
|
||||||
// \Log::info("getMessages execution time: {$executionTime} seconds");
|
|
||||||
// return $response;
|
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
|
|||||||
BIN
public/tmp/attachments/8079041/IMG-20250425-WA0000.jpg
Normal file
BIN
public/tmp/attachments/8079041/IMG-20250425-WA0000.jpg
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 43 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 619 KiB |
BIN
public/tmp/attachments/8079041/null-20250325-WA0031.jpg
Normal file
BIN
public/tmp/attachments/8079041/null-20250325-WA0031.jpg
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 2.4 KiB |
BIN
public/tmp/attachments/8079161/null-20250325-WA0031.jpg
Normal file
BIN
public/tmp/attachments/8079161/null-20250325-WA0031.jpg
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 2.4 KiB |
@@ -22,7 +22,7 @@
|
|||||||
|
|
||||||
<flux:navlist variant="outline">
|
<flux:navlist variant="outline">
|
||||||
<flux:button class="cursor-pointer inbox-btn" variant="filled" icon="inbox" x-on:click="$dispatch('getEmail')">Inbox</flux:button>
|
<flux:button class="cursor-pointer inbox-btn" variant="filled" icon="inbox" x-on:click="$dispatch('getEmail')">Inbox</flux:button>
|
||||||
<flux:button class="mt-2 cursor-pointer" variant="filled" icon="refresh-cw" x-on:click="Livewire.dispatch('updateEmail')">Refresh</flux:button>
|
<flux:button class="mt-2 cursor-pointer" variant="filled" icon="refresh-cw" x-on:click="$dispatch('fetchMessages')">Refresh</flux:button>
|
||||||
</flux:navlist>
|
</flux:navlist>
|
||||||
<img src="https://placehold.co/300x250?font=roboto" alt="sideAds" />
|
<img src="https://placehold.co/300x250?font=roboto" alt="sideAds" />
|
||||||
<flux:spacer />
|
<flux:spacer />
|
||||||
@@ -121,8 +121,6 @@
|
|||||||
<!-- Toast Container -->
|
<!-- Toast Container -->
|
||||||
|
|
||||||
<div id="toast-container" class="fixed top-5 left-1/2 transform -translate-x-1/2 z-50 space-y-4"></div>
|
<div id="toast-container" class="fixed top-5 left-1/2 transform -translate-x-1/2 z-50 space-y-4"></div>
|
||||||
<!-- Toast Wrapper (top center) -->
|
|
||||||
<div id="toast-container" class="fixed flex flex-col w-[calc(100%-2rem)] sm:w-96 z-[999999] right-4 top-4 left-1/2 -translate-x-1/2 space-y-2 pointer-events-none"></div>
|
|
||||||
|
|
||||||
@fluxScripts
|
@fluxScripts
|
||||||
</body>
|
</body>
|
||||||
|
|||||||
@@ -1,51 +0,0 @@
|
|||||||
<div>
|
|
||||||
<div class="bg-white shadow rounded-lg p-6">
|
|
||||||
<!-- Email Address Display -->
|
|
||||||
<div class="mb-6">
|
|
||||||
<h2 class="text-2xl font-bold mb-2">Your Disposable Email</h2>
|
|
||||||
<div class="flex items-center space-x-4">
|
|
||||||
<input type="text" value="{{ $currentEmail }}" readonly class="flex-1 p-2 border rounded bg-gray-50" />
|
|
||||||
<button wire:click="generateNewEmail" class="bg-blue-500 text-white px-4 py-2 rounded hover:bg-blue-600">
|
|
||||||
Generate New
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<!-- Messages List -->
|
|
||||||
<div class="space-y-4">
|
|
||||||
@if(count($messages) > 0)
|
|
||||||
@foreach($messages as $message)
|
|
||||||
<div class="border rounded p-4 hover:bg-gray-50 cursor-pointer {{ $selectedMessage === $message->id ? 'bg-blue-50' : '' }}"
|
|
||||||
wire:click="selectMessage({{ $message->id }})">
|
|
||||||
<div class="flex justify-between items-start">
|
|
||||||
<div>
|
|
||||||
<h3 class="font-semibold">{{ $message->subject }}</h3>
|
|
||||||
<p class="text-sm text-gray-600">From: {{ $message->from }}</p>
|
|
||||||
<p class="text-sm text-gray-500">{{ $message->date }}</p>
|
|
||||||
</div>
|
|
||||||
<button wire:click.stop="deleteMessage({{ $message->id }})"
|
|
||||||
class="text-red-500 hover:text-red-700">
|
|
||||||
<svg class="w-5 h-5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
|
||||||
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M19 7l-.867 12.142A2 2 0 0116.138 21H7.862a2 2 0 01-1.995-1.858L5 7m5 4v6m4-6v6m1-10V4a1 1 0 00-1-1h-4a1 1 0 00-1 1v3M4 7h16" />
|
|
||||||
</svg>
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
@endforeach
|
|
||||||
@else
|
|
||||||
<div class="text-center py-8 text-gray-500">
|
|
||||||
No messages yet. They will appear here automatically.
|
|
||||||
</div>
|
|
||||||
@endif
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<!-- Auto-refresh script -->
|
|
||||||
<script>
|
|
||||||
document.addEventListener('livewire:load', function () {
|
|
||||||
setInterval(() => {
|
|
||||||
@this.loadMessages()
|
|
||||||
}, {{ $this->getPollingInterval() }});
|
|
||||||
});
|
|
||||||
</script>
|
|
||||||
</div>
|
|
||||||
47
resources/views/livewire/frontend/components/mail.blade.php
Normal file
47
resources/views/livewire/frontend/components/mail.blade.php
Normal file
@@ -0,0 +1,47 @@
|
|||||||
|
<div class="inbox-list cursor-pointer" x-on:click="" data-message-id="{{ $message['id'] }}">
|
||||||
|
<div class="block rounded-lg bg-white shadow-md dark:bg-zinc-700 text-left">
|
||||||
|
<div class="flex items-center px-4 py-4 sm:px-6">
|
||||||
|
<div class="flex flex-1 items-center min-w-0">
|
||||||
|
<div class="flex-shrink-0">
|
||||||
|
<span class="relative inline-block">
|
||||||
|
<img src="{{ asset('images/user.webp') }}" class="size-12" alt="inbox-logo" />
|
||||||
|
<span class="shadow-solid absolute bottom-0 right-0 block w-3 h-3 dark:text-gray-500 text-white bg-amber-300 dark:bg-amber-400 rounded-full"></span>
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
<div class="flex-1 px-4 min-w-0 md:grid md:gap-4 md:grid-cols-2">
|
||||||
|
<div>
|
||||||
|
<div class="dark:text-accent text-accent-content text-sm font-medium leading-5 truncate">
|
||||||
|
{{ $message['sender_name'] }}
|
||||||
|
</div>
|
||||||
|
<div class="flex items-center mt-2 dark:text-gray-400 text-gray-500 text-sm leading-5">
|
||||||
|
<svg fill="currentColor" viewBox="0 0 20 20"
|
||||||
|
class="flex-shrink-0 mr-1.5 w-5 h-5 text-gray-400">
|
||||||
|
<path fill-rule="evenodd"
|
||||||
|
d="M2.003 5.884L10 9.882l7.997-3.998A2 2 0 0016 4H4a2 2 0 00-1.997 1.884zM18 8.118l-8 4-8-4V14a2 2 0 002 2h12a2 2 0 002-2V8.118z"
|
||||||
|
clip-rule="evenodd"></path>
|
||||||
|
</svg>
|
||||||
|
<span class="truncate">{{ $message['sender_email'] }}</span></div>
|
||||||
|
</div>
|
||||||
|
<div class="hidden md:block">
|
||||||
|
<div>
|
||||||
|
<div class="dark:text-gray-300 text-gray-900 text-sm leading-5 truncate">
|
||||||
|
{{ $message['subject'] }}
|
||||||
|
</div>
|
||||||
|
<div
|
||||||
|
class="flex items-center mt-2 text-gray-400 dark:text-gray-400 text-sm leading-5 truncate">
|
||||||
|
{{ Str::limit($message['contentText'], 100) }}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<svg fill="currentColor" viewBox="0 0 20 20" class="w-5 h-5 text-gray-400">
|
||||||
|
<path fill-rule="evenodd"
|
||||||
|
d="M7.293 14.707a1 1 0 010-1.414L10.586 10 7.293 6.707a1 1 0 011.414-1.414l4 4a1 1 0 010 1.414l-4 4a1 1 0 01-1.414 0z"
|
||||||
|
clip-rule="evenodd"></path>
|
||||||
|
</svg>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
9
resources/views/livewire/frontend/mailbox.blade.php
Normal file
9
resources/views/livewire/frontend/mailbox.blade.php
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
<span>
|
||||||
|
@if($messages)
|
||||||
|
@foreach(array_reverse($messages) as $message)
|
||||||
|
<livewire:frontend.components.mail :message="$message" />
|
||||||
|
@endforeach
|
||||||
|
@else
|
||||||
|
<flux:text>{{ $initial ? __('Empty Inbox') : __('Fetching') . '...' }}</flux:text>
|
||||||
|
@endif
|
||||||
|
</span>
|
||||||
@@ -1,11 +1,5 @@
|
|||||||
<div>
|
<div>
|
||||||
<flux:heading class="mb-3" size="xl" level="1">Inbox</flux:heading>
|
<flux:heading class="mb-3" size="xl" level="1">Inbox</flux:heading>
|
||||||
<div class="mb-3"></div>
|
<div class="mb-3"></div>
|
||||||
@php
|
<livewire:frontend.mailbox />
|
||||||
for ($i=0; $i<=10; $i++) {
|
|
||||||
@endphp
|
|
||||||
<livewire:inbox />
|
|
||||||
@php
|
|
||||||
}
|
|
||||||
@endphp
|
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -4,10 +4,18 @@ use App\Http\Controllers\AppController;
|
|||||||
use App\Livewire\Email;
|
use App\Livewire\Email;
|
||||||
use App\Livewire\EmailInbox;
|
use App\Livewire\EmailInbox;
|
||||||
use App\Livewire\Home;
|
use App\Livewire\Home;
|
||||||
|
use App\Models\ZEmail;
|
||||||
use Illuminate\Support\Facades\Route;
|
use Illuminate\Support\Facades\Route;
|
||||||
|
|
||||||
Route::get('/', Home::class)->name('home');
|
Route::get('/', Home::class)->name('home');
|
||||||
Route::get('/mailbox', Email::class)->name('mailbox');
|
Route::get('/mailbox', Email::class)->name('mailbox');
|
||||||
Route::get('/inbox', EmailInbox::class)->name('inbox');
|
|
||||||
|
|
||||||
//Route::get('/add/{email?}', [AppController::class, 'mailbox'])->name('mailbox');
|
Route::get('/msg/{email?}/', function ($email) {
|
||||||
|
$responses = [
|
||||||
|
'to' => ZEmail::getMessages($email, 'to', []),
|
||||||
|
'cc' => ZEmail::getMessages($email, 'cc', [])
|
||||||
|
];
|
||||||
|
$messages = array_merge($responses['to']['data'], $responses['cc']['data']);
|
||||||
|
$notifications = array_merge($responses['to']['notifications'], $responses['cc']['notifications']);
|
||||||
|
return $messages;
|
||||||
|
})->name('test');
|
||||||
|
|||||||
Reference in New Issue
Block a user