Set Charset to UTF-8 to avoid encoding issues on some mail servers

This commit is contained in:
johnnyq
2024-06-28 11:39:34 -04:00
parent 97c2928830
commit c27f9fd6a9

View File

@@ -320,7 +320,8 @@ $client = $clientManager->make([
'validate_cert' => true, 'validate_cert' => true,
'username' => $config_imap_username, 'username' => $config_imap_username,
'password' => $config_imap_password, 'password' => $config_imap_password,
'protocol' => 'imap' 'protocol' => 'imap',
'charset' => 'UTF-8' // Add charset to avoid encoding issues
]); ]);
// Connect to the IMAP server // Connect to the IMAP server
@@ -350,6 +351,7 @@ try {
$messages = $inbox->query()->unseen()->get(); $messages = $inbox->query()->unseen()->get();
} catch (Exception $e) { } catch (Exception $e) {
echo "Error: " . $e->getMessage(); echo "Error: " . $e->getMessage();
$messages = collect(); // Ensure $messages is defined as an empty collection
} }
if ($messages->count() > 0) { if ($messages->count() > 0) {
@@ -432,10 +434,12 @@ if ($messages->count() > 0) {
unlink("uploads/tmp/{$original_message_file}"); unlink("uploads/tmp/{$original_message_file}");
} }
} }
} else {
echo "No unseen messages found.";
} }
$client->expunge(); $client->expunge();
$client->disconnect(); $client->disconnect();
// Remove the lock file // Remove the lock file
unlink($lock_file_path); unlink($lock_file_path);