I was able to fix this with Outlook 365 by modifying InboundEmail.php function handleMimeHeaderDecode($subject) to the following:
public function handleMimeHeaderDecode($subject)
{
$subjectDecoded = $this->getImap()->MimeHeaderDecode($subject);
$ret = '';
if (is_array($subjectDecoded)) {
foreach ($subjectDecoded as $object) {
if ($object->charset != 'default') {
$ret .= $this->handleCharsetTranslation($object->text, $object->charset);
} else {
$ret .= $object->text;
}
}
} else {
$ret = $subjectDecoded;
}
return $ret;
}
I am still unable to import emails but the data is now there.
2 Likes
pgr
20 June 2023 09:39
13
Hi, @norrch , welcome to the Community!
Nice fix, maybe you could create a PR for it on Github?
1 Like
I am not sure, I havenāt been able to determine what the original use was. The code is setup to parse a dictionary, but from what I can see this is only impacting Outlook 365? How is Gmail different? I havenāt tested these alternative scenarios yet.
1 Like
pgr
20 June 2023 12:19
15
Okā¦ youāre right to be prudent, this can get really complicated with email and SuiteCRM
Then maybe just open an Issue, without the PR, so the devs can take a look at it. Having your fix there helps focus the attention on the relevant bit of code.
Great ! Now i can see subject and from in the list ! Good job!
We must solve this for future releases. @pgr can you create the PR, i dont think it was created.
Thanks
pgr
19 July 2023 21:40
17
I think I will wait for my other PRās to be merged before opening new onesā¦
pjdm
7 August 2023 04:15
18
The problem remains in the email dashlet in v8.4.0-beta.
I applied the patch from @norrch and it fixed the issue. I believe a PR would make sense otherwise email is crippled in v8.4 and we really should have these basics working by now. Here are the before and after pictures.
pjdm
11 September 2023 19:42
19
applying @norrch fix worked for v8.3, v8.4-beta and now v8.4
pjdm
2 November 2023 02:10
20
Still not fixed in āupgradeā v.8.4.1.
My recommendation is not to do these āupgradesā. They only wipe out any fixes youāve made that continue not to be made to the core code. For some reason, nobody appears to be actually using this in the development team because they would not be able to see emails. It is a shame but if you āupgradeā you will actually go backwards. This has carried through every V8 āupgradeā and, this and other similar nuisances, will waste your time or frustrate your clients.
pgr
2 November 2023 10:43
21
Where is the issue and PR for this on Github?
rsp
2 November 2023 14:07
22
Hello all,
Is there any way to tag all Suitecrm developer, responsible maintainers and fix all these known issues?
pgr
2 November 2023 15:02
23
@rsp you create Issues in the GitHub repos, one for v7, one for v8
I found the exact same issue
This helped, thank you very much
After testing I found another issue relevant, when the subjects are in other encoding like āGBKā, so I modified the code a little bit, as below:
public function handleMimeHeaderDecode($subject)
{
$subjectDecoded = $this->getImap()->MimeHeaderDecode($subject);
$ret = '';
if(!is_array($subjectDecoded)){
// regex to extract all the MIME parts (Like GBK)
preg_match_all("/=\?[^?]+\?[B|Q]\?[^?]+\?=/", $subjectDecoded, $matches);
if (!empty($matches[0])) {
$allEncodedParts = array_merge(...$matches);
foreach ($allEncodedParts as $part) {
//decode the GBK MIME
$ret.= mb_decode_mimeheader($part);
}
return $ret;
} else {
return $subjectDecoded;
}
}
foreach ($subjectDecoded as $object) {
if ($object->charset != 'default') {
$ret .= $this->handleCharsetTranslation($object->text, $object->charset);
} else {
$ret .= $object->text;
}
}
return $ret;
}
I uploaded a fix for this to v7, hopefully itāll get added to both v7 and v8 ASAP.
salesagility:hotfix
ā chris001:patch-37
opened 02:41AM - 20 Jan 24 UTC
ā¦breaking on MIME decoding.
A commonly reported bug report on the forum: httpā¦ s://community.suitecrm.com/t/subject-line-missing-from-inbound-emails/88059
Also fixes this issue https://github.com/salesagility/SuiteCRM-Core/issues/363
..and fixes https://github.com/salesagility/SuiteCRM-Core/issues/420
..all similar reports about the same bug - a lack of resilience in decoding the MIME headers, resulting in broken inbox emails.
Credit also to @DBRenny for putting together a first version of this: https://github.com/salesagility/SuiteCRM-Core/pull/366
<!--- Please be aware that as of the 31st January 2022 we no longer support 7.10.x.
New PRs to hotfix-7.10.x will be invalid. If your fix is still applicable to 7.12.x,
please create the pull request to the hotfix branch accordingly. -->
## Description
## Motivation and Context
Inbound email was broken on Bitnami containers, and on any installation that is missing the `php-imap` extension. [Bitnami intentionally leaves out the `php-imap` extension, because of the long time since it last received security fixes](https://github.com/bitnami/containers/issues/51877).
## How To Test This
Try inbound email on a bitnami container. There should be no subjects, for servers that return MIME encoded headers (languages with accented characters outside of US-ASCII character set, e.g. French, German, etc).
Then from inside the container, get the patch with `wget` and apply the patch `git apply`, try inbound email again, and it should show email Subjects in the inbox. Other MIME encoded headers may also display properly as `UTF-8`, such as `From`, `To`, `CC`, `Bcc`.
## Types of changes
- [x] Bug fix (non-breaking change which fixes an issue)
- [ ] New feature (non-breaking change which adds functionality)
- [ ] Breaking change (fix or feature that would cause existing functionality to change)
### Final checklist
- [x] My code follows the code style of this project found [here](https://docs.suitecrm.com/community/contributing-code/coding-standards/).
- [ ] My change requires a change to the documentation.
- [x] I have read the [**How to Contribute**](https://docs.suitecrm.com/community/contributing-code/) guidelines.
To test this fix on your own server:
Go to your serverās Linux command line terminal.
Go to base directory of your Suite 7 install, example: cd /home/suite7/public_html
apt update -qqq && apt -y install wget git
wget https://github.com/salesagility/SuiteCRM/pull/10323.diff
git apply 10323.diff
1 Like
i would like to share my experience with this issue.
my environment is docker
when i use bitnami/php-fpm:8.0 ~ 8.2, i have this issue. when i changed to bitnami/php-fpm:7.4.33, issue Disappeared
The Norrch patch is missing (again) from v8.6.
You will not see FROM or SUBJECT fields in emails.
2 Likes
I am having this problem as well. Is there a manual workaround or estimated time for when the patch will be reapplied?
Try this patch, and report back here if it works for you or no:
salesagility:hotfix
ā chris001:patch-37
opened 02:41AM - 20 Jan 24 UTC
ā¦breaking on MIME decoding.
A commonly reported bug report on the forum: httpā¦ s://community.suitecrm.com/t/subject-line-missing-from-inbound-emails/88059
Also fixes this issue https://github.com/salesagility/SuiteCRM-Core/issues/363
..and fixes https://github.com/salesagility/SuiteCRM-Core/issues/420
..all similar reports about the same bug - a lack of resilience in decoding the MIME headers, resulting in broken inbox emails.
Credit also to @DBRenny for putting together a first version of this: https://github.com/salesagility/SuiteCRM-Core/pull/366
<!--- Please be aware that as of the 31st January 2022 we no longer support 7.10.x.
New PRs to hotfix-7.10.x will be invalid. If your fix is still applicable to 7.12.x,
please create the pull request to the hotfix branch accordingly. -->
## Description
## Motivation and Context
Inbound email was broken on Bitnami containers, and on any installation that is missing the `php-imap` extension. [Bitnami intentionally leaves out the `php-imap` extension, because of the long time since it last received security fixes](https://github.com/bitnami/containers/issues/51877).
## How To Test This
Try inbound email on a bitnami container. There should be no subjects, for servers that return MIME encoded headers (languages with accented characters outside of US-ASCII character set, e.g. French, German, etc).
Then from inside the container, get the patch with `wget` and apply the patch `git apply`, try inbound email again, and it should show email Subjects in the inbox. Other MIME encoded headers may also display properly as `UTF-8`, such as `From`, `To`, `CC`, `Bcc`.
## Types of changes
- [x] Bug fix (non-breaking change which fixes an issue)
- [ ] New feature (non-breaking change which adds functionality)
- [ ] Breaking change (fix or feature that would cause existing functionality to change)
### Final checklist
- [x] My code follows the code style of this project found [here](https://docs.suitecrm.com/community/contributing-code/coding-standards/).
- [ ] My change requires a change to the documentation.
- [x] I have read the [**How to Contribute**](https://docs.suitecrm.com/community/contributing-code/) guidelines.