Add Function to convert message text from UTF7 to UTF8 possibly fix the Google Issue not sure, we need further testing
This commit is contained in:
@@ -346,6 +346,11 @@ function getInboxFolder($client, $inboxNames) {
|
|||||||
throw new Exception("No inbox folder found.");
|
throw new Exception("No inbox folder found.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Function to convert UTF-7 IMAP to UTF-8
|
||||||
|
function convertToUtf8($text) {
|
||||||
|
return mb_convert_encoding($text, 'UTF-8', 'UTF7-IMAP');
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$inbox = getInboxFolder($client, $inboxNames);
|
$inbox = getInboxFolder($client, $inboxNames);
|
||||||
$messages = $inbox->query()->unseen()->get();
|
$messages = $inbox->query()->unseen()->get();
|
||||||
@@ -371,6 +376,11 @@ if ($messages->count() > 0) {
|
|||||||
|
|
||||||
$subject = sanitizeInput($message->getSubject() ?? 'No Subject');
|
$subject = sanitizeInput($message->getSubject() ?? 'No Subject');
|
||||||
$date = sanitizeInput($message->getDate() ?? date('Y-m-d H:i:s'));
|
$date = sanitizeInput($message->getDate() ?? date('Y-m-d H:i:s'));
|
||||||
|
|
||||||
|
// Convert message bodies from UTF-7 to UTF-8 if needed
|
||||||
|
$html_body = convertToUtf8($message->getHtmlBody() ?? '');
|
||||||
|
$text_body = convertToUtf8($message->getTextBody() ?? '');
|
||||||
|
|
||||||
$message_body = $message->getHtmlBody() ?? '';
|
$message_body = $message->getHtmlBody() ?? '';
|
||||||
|
|
||||||
if (empty($message_body)) {
|
if (empty($message_body)) {
|
||||||
|
|||||||
Reference in New Issue
Block a user