Subject Line Missing from Inbound Emails

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

Hi, @norrch , welcome to the Community! :tada:

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

Okā€¦ youā€™re right to be prudent, this can get really complicated with email and SuiteCRM :sweat_smile:

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

I think I will wait for my other PRā€™s to be merged before opening new onesā€¦

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.

applying @norrch fix worked for v8.3, v8.4-beta and now v8.4
image

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.

Where is the issue and PR for this on Github?

Hello all,

Is there any way to tag all Suitecrm developer, responsible maintainers and fix all these known issues?

@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.

To test this fix on your own server:

  1. Go to your serverā€™s Linux command line terminal.
  2. Go to base directory of your Suite 7 install, example: cd /home/suite7/public_html
  3. apt update -qqq && apt -y install wget git
  4. wget https://github.com/salesagility/SuiteCRM/pull/10323.diff
  5. 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: