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
1 changed files with 6 additions and 2 deletions

View File

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