diff --git a/app/Livewire/EmailInbox.php b/app/Livewire/EmailInbox.php
deleted file mode 100644
index c4ffb91..0000000
--- a/app/Livewire/EmailInbox.php
+++ /dev/null
@@ -1,62 +0,0 @@
-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
- ]);
- }
-}
diff --git a/app/Livewire/Frontend/Action.php b/app/Livewire/Frontend/Action.php
index 626f823..a9ea897 100644
--- a/app/Livewire/Frontend/Action.php
+++ b/app/Livewire/Frontend/Action.php
@@ -65,7 +65,8 @@ class Action extends Component
$this->dispatch('closeModal');
}
- public function deleteEmail() {
+ public function deleteEmail(): void
+ {
ZEmail::removeEmail($this->email);
// if (count($this->emails) <= 1 && json_decode(config('app.settings.configuration_settings'))->after_last_email_delete == 'redirect_to_homepage') {
// return redirect()->route('home');
@@ -82,7 +83,8 @@ class Action extends Component
$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();
if (count($logs) >= json_decode(config('app.settings.configuration_settings'))->email_limit) {
return false;
@@ -90,7 +92,8 @@ class Action extends Component
return true;
}
- private function checkUsedEmail() {
+ private function checkUsedEmail(): bool
+ {
if (json_decode(config('app.settings.configuration_settings'))->disable_used_email) {
$check = Log::where('email', $this->user . '@' . $this->domain)->where('ip', '<>', request()->ip())->count();
if ($check > 0) {
diff --git a/app/Livewire/Frontend/Components/Mail.php b/app/Livewire/Frontend/Components/Mail.php
new file mode 100644
index 0000000..a581011
--- /dev/null
+++ b/app/Livewire/Frontend/Components/Mail.php
@@ -0,0 +1,15 @@
+with(['message' => $this->message]);
+ }
+}
diff --git a/app/Livewire/Frontend/Email.php b/app/Livewire/Frontend/Email.php
index 22d34f8..8bf4c6b 100644
--- a/app/Livewire/Frontend/Email.php
+++ b/app/Livewire/Frontend/Email.php
@@ -47,6 +47,8 @@ class Email extends Component
$this->dispatch('getEmail');
}
$this->checkMultipleEmails();
+ $this->dispatch('syncMailbox', $this->email);
+ $this->dispatch('fetchMessages');
}
public function generateEmail(): void
diff --git a/app/Livewire/Frontend/App.php b/app/Livewire/Frontend/Mailbox.php
similarity index 68%
rename from app/Livewire/Frontend/App.php
rename to app/Livewire/Frontend/Mailbox.php
index 66f643d..dc8d415 100644
--- a/app/Livewire/Frontend/App.php
+++ b/app/Livewire/Frontend/Mailbox.php
@@ -7,30 +7,34 @@ use App\Models\ZEmail;
use Illuminate\Support\Facades\Auth;
use Livewire\Component;
-class App extends Component
+class Mailbox extends Component
{
public $messages = [];
public $deleted = [];
public $error = '';
public $email;
- public $initial;
+ public $initial = false;
+ public $type;
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;
}
- public function syncEmail($email) {
- $this->email = $email;
- }
-
- public function fetch() {
+ public function fetch(): void
+ {
try {
$count = count($this->messages);
+
$responses = [];
if (config('app.beta_feature') || !json_decode(config('app.settings.imap_settings'))->cc_check) {
$responses = [
@@ -46,18 +50,36 @@ class App extends Component
'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->messages = array_merge($responses['to']['data'], $responses['cc']['data']);
$notifications = array_merge($responses['to']['notifications'], $responses['cc']['notifications']);
+
if (count($notifications)) {
- if ($this->overflow == false && count($this->messages) == $count) {
+ if (!$this->overflow && count($this->messages) == $count) {
$this->overflow = true;
}
} else {
$this->overflow = false;
}
+
foreach ($notifications as $notification) {
- $this->dispatchBrowserEvent('showNewMailNotification', $notification);
+ $this->dispatch('showNewMailNotification', $notification);
}
ZEmail::incrementMessagesStats(count($notifications));
} catch (\Exception $e) {
@@ -67,8 +89,8 @@ class App extends Component
$this->error = 'Not able to connect to Mail Server';
}
}
- $this->dispatchBrowserEvent('stopLoader');
- $this->dispatchBrowserEvent('loadDownload');
+ $this->dispatch('stopLoader');
+ $this->dispatch('loadDownload');
$this->initial = true;
}
@@ -88,8 +110,9 @@ class App extends Component
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
{
if (is_dir($dir)) {
@@ -105,5 +128,4 @@ class App extends Component
rmdir($dir);
}
}
-
}
diff --git a/app/Models/Message.php b/app/Models/Message.php
index b34431a..58900ee 100644
--- a/app/Models/Message.php
+++ b/app/Models/Message.php
@@ -123,7 +123,6 @@ class Message extends Model
} else {
$search->addCondition(new To($email));
}
- $search->addCondition(new Since((new \DateTime('-1 day'))));
$messages = $mailbox->getMessages($search, \SORTDATE, true);
$limit = json_decode(config('app.settings.configuration_settings'))->fetch_messages_limit ?? 15;
$count = 1;
@@ -148,11 +147,16 @@ class Message extends Model
}
$datediff = new Carbon($date);
$content = '';
+ $contentText = '';
$html = $message->getBodyHtml();
+
+ $text = $message->getBodyText();
+ if ($text) {
+ $contentText = str_replace('getBodyText();
$content = str_replace('', $text));
}
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['id'] = $message->getNumber();
$obj['content'] = $content;
+ $obj['contentText'] = $contentText;
$obj['attachments'] = [];
//Checking if Sender is Blocked
$domain = explode('@', $obj['sender_email'])[1];
@@ -224,125 +229,4 @@ class Message extends Model
$connection->expunge();
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('getBodyText();
-// $content = str_replace('', $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;
-// }
}
diff --git a/public/tmp/attachments/8079041/IMG-20250425-WA0000.jpg b/public/tmp/attachments/8079041/IMG-20250425-WA0000.jpg
new file mode 100644
index 0000000..e6b52c2
Binary files /dev/null and b/public/tmp/attachments/8079041/IMG-20250425-WA0000.jpg differ
diff --git a/public/tmp/attachments/8079041/Screenshot_2025-04-22-10-12-51-40_6012fa4d4ddec268fc5c7112cbb265e7.jpg b/public/tmp/attachments/8079041/Screenshot_2025-04-22-10-12-51-40_6012fa4d4ddec268fc5c7112cbb265e7.jpg
new file mode 100644
index 0000000..17898ae
Binary files /dev/null and b/public/tmp/attachments/8079041/Screenshot_2025-04-22-10-12-51-40_6012fa4d4ddec268fc5c7112cbb265e7.jpg differ
diff --git a/public/tmp/attachments/8079041/null-20250325-WA0031.jpg b/public/tmp/attachments/8079041/null-20250325-WA0031.jpg
new file mode 100644
index 0000000..ed7e547
Binary files /dev/null and b/public/tmp/attachments/8079041/null-20250325-WA0031.jpg differ
diff --git a/public/tmp/attachments/8079161/null-20250325-WA0031.jpg b/public/tmp/attachments/8079161/null-20250325-WA0031.jpg
new file mode 100644
index 0000000..ed7e547
Binary files /dev/null and b/public/tmp/attachments/8079161/null-20250325-WA0031.jpg differ
diff --git a/resources/views/components/layouts/app.blade.php b/resources/views/components/layouts/app.blade.php
index 8d20aa8..dfb95d3 100644
--- a/resources/views/components/layouts/app.blade.php
+++ b/resources/views/components/layouts/app.blade.php
@@ -22,7 +22,7 @@