How to disable auto-mark SEEN or READ in Gmail after an inbound email is imported? (With Gmail OAuth2, Group Inbound Email Account)

(OAuth with Gmail working!)

Referring to the topic above, I am actually able to successfully setup the External OAuth Provider using Gmail OAuth2.

My current setup:

  • Windows 10
  • Using Xampp
  • SuiteCRM version: v8.9.0

Before jumping into my question stated, I also faced the “missing subject” bug in this version and I found the cause below:

In the C:\xampp\htdocs\suitecrm\public\legacy\modules\InboundEmail\InboundEmail.php:
Within the function returnImportedEmail(…),, the $parseFullHeader is undefined at line 5498. I found that the correct declared variable should be $header. After changing the variable and re-import, the subject appears.

Now back to my question. After importing each batch of inbound emails, I found that the previous imported emails will be automatically marked as “Read” in our Gmail accounts. This auto-read-marking is something we don’t want as it might cause the user not aware tht they haven’t actually read those auto-marked emails

Digging into the same InboundEmail.php file, I tried to modify the following code based on AI’s suggestion:

  • setFlagFull($uids, ‘\SEEN’, ST_UID) ==> commented for similar lines
  • $this->getImap()->getBody($uid, FT_UID | FT_PEEK) ==> added FT_PEEK for those imap getBody or fetchBody parts

However, after testing re-import with modification above, the previous imported emails are still marked read. Appreciate if any idea or direction can be provided. Thanks :pray: