• Hi Zoho Mail Team,

    I’m writing to report a compatibility issue with the Zoho Mail plugin (v1.6.3)
    running on PHP 8.3 + WordPress. After OAuth authentication succeeds, the
    From Email Address dropdown remains empty, and the plugin throws PHP errors. Root Cause (Two Issues) Issue 1: PHP 8.x Strict Typing

    The plugin uses count() and foreach() on sendMailDetails without
    null-checking. In PHP 7.x this silently returned 0 / skipped, but PHP 8.x
    throws TypeError:

    Line 380: count($jsonbodyAccounts->data[$i]->sendMailDetails)
    → TypeError: count(): Argument #1 must be Countable|array, null given

    Line 618: foreach ($account->sendMailDetails as $mailDetail)
    → Warning: foreach() argument must be array|object, null given

    Issue 2: Zoho API No Longer Returns sendMailDetails

    When calling https://mail.zoho.com/api/accounts with a valid OAuth token,
    the response no longer includes the sendMailDetails field for some account
    types. The account object has primaryEmailAddress (string) and
    emailAddress (array of objects), but sendMailDetails is simply absent.

    This means even after fixing Issue 1, the dropdown has no data to display. Fix Applied

    Three changes in zohoMail.php: Change 1 — Null-safe count() (line ~380)

    `php<br>// Before<br>for ($j = 0; $j < count($jsonbodyAccounts->data[$i]->sendMailDetails); $j++) {</p> <p>// After<br>if (is_array($jsonbodyAccounts->data[$i]->sendMailDetails)<br>&& count($jsonbodyAccounts->data[$i]->sendMailDetails) > 0) {<br>for ($j = 0; $j < count($jsonbodyAccounts->data[$i]->sendMailDetails); $j++) {</p> <p></p> <p>Change 2 — Null-safe foreach() (line ~618)</p> <p>// Before<br>foreach ($account->sendMailDetails as $mailDetail) {</p> <p>// After<br>if (is_array($account->sendMailDetails) && count($account->sendMailDetails) > 0) {<br>foreach ($account->sendMailDetails as $mailDetail) {</p> <p></p> <p>Change 3 — Fallback to primaryEmailAddress (lines ~391 and ~635)</p> <p>// When sendMailDetails is empty, use primaryEmailAddress as fallback<br>} elseif (!empty($account->primaryEmailAddress)) {<br>$fromAddress = $account->primaryEmailAddress;<br>// … render option<br>}</p> <p></p> <p>Environment</p> <ul> <li>WordPress: latest</li> <li>PHP: 8.3.32 (NTS)</li> <li>Plugin: Zoho Mail 1.6.3</li> <li>Server: Debian 10, Nginx</li> </ul> <p>Suggested Permanent Fix</p> <p>Consider using <code>primaryEmailAddress</code> as the primary data source (it’s always<br>a string and always present), falling back to iterating <code>emailAddress</code> array<br>or <code>sendMailDetails</code> if needed. This would be more robust across Zoho API<br>versions.</p> <p>Thanks,</p>

Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)

You must be logged in to reply to this topic.