-
-
Notifications
You must be signed in to change notification settings - Fork 151
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
how to fix memory issue when loading message? #516
Comments
If you don't need to access older messages, you could use folder's method $messages = $folder->query()
->since('01.01.2024')
->all(); I hope someone will come with better solution to read ALL messages in chunks without heavy memory impact. |
I still getting the same error. if there a way to handle an account with multiple messages? |
I had a memory problem when fetching messages with large attachments? I fixed the memory-issue with this solution: #457 |
I had to increase
I tried the following: public function index(Request $request)
{
$credentials = decrypt(session('imap_credentials'));
$config = config('imap.accounts.default');
$config['username'] = $credentials['email'];
$config['password'] = $credentials['password'];
$client = Client::make($config);
if (!$client->isConnected()) {
try {
$client->checkConnection();
} catch (\Exception $e) {
Auth::logout();
$request->session()->invalidate();
return redirect()->route('login')->with('alert', [
'type' => 'danger',
'message' => 'Failed to connect to the email server. You have been logged out. Please log in again.',
]);
}
}
$folders = [];
$mailFolders = $client->getFolders($hierarchical = false);
foreach ($mailFolders as $folder) {
$folder_name = $folder->name;
// Get unread message count
$folders[$folder_name]['unread_count'] = $folder->messages()->unseen()->count();
// Fetch messages from the folder
$folders[$folder_name]['messages'] = $folder->messages()->all()->fetchOrderDesc()->get();
}
return view('office.emails.test', compact('folders'));
} |
I was trying to load emails. it work on other email but I get issue with email account with multiple messages.
here is the code:
I get the following issue in laravel:
Is there a better way to load all message?
The text was updated successfully, but these errors were encountered: