Mail: PHP encounters a non-numeric value at /var/www/nextcloud/apps/mail/vendor/pear-pear.horde.org/Horde_Imap_Client/Horde/Imap/Client/Ids.php#317

Created on 22 Apr 2020  路  18Comments  路  Source: nextcloud/mail

Expected behavior

After conecting to a new IMAP account mail-app is presenting all mails in this inbox.

Actual behavior

Mail-app shows "Keine Nachrichten in diesem Ordner" (in english "No messages in this folder") and the log shows "A non-numeric value encountered at /var/www/nextcloud/apps/mail/vendor/pear-pear.horde.org/Horde_Imap_Client/Horde/Imap/Client/Ids.php#317"

Mail app

Mail app version: 1.3.3

Mailserver or service: Icloud mail (imap.mail.me.com)

Server configuration

Operating system: Debian 10

Web server: Apache/2.4.38

Database: MariaDB

PHP version: 7.3

Nextcloud Version: 18.0.3

Client configuration

Browser: Firefox 75.0

Operating system: Windows 8.1

0. to triage bug help wanted needs info

All 18 comments

the log shows

Mind sharing the full log entry?

Here's the full log entry. I just removed IP address, Username und browser ID: {"reqId":"PWz0sokJNTDT0hofR4mO","level":3,"time":"2020-04-22T08:41:14+00:00","remoteAddr":"IPv6adress","user":"username","app":"PHP","method":"POST","url":"/apps/mail/api/accounts/3/folders/RHJhZnRz/sync","message":"A non-numeric value encountered at /var/www/nextcloud/apps/mail/vendor/pear-pear.horde.org/Horde_Imap_Client/Horde/Imap/Client/Ids.php#317","userAgent":"Mozilla/5.0 (Windows NT 6.3; Win64; x64; rv:75.0) Gecko/20100101 Firefox/75.0","version":"18.0.3.0","id":"ID"}

Other IMAP accounts work fine. I had this issue only with a iCloud mailaccount.

Thanks. So it's caused by our code here: https://github.com/nextcloud/mail/blob/e5f0e3591a44a08b36c96a52eb8d9f219bb8de2c/lib/IMAP/MessageMapper.php#L152. Somehow $upper is not an int (as I would expect) and therefore the numeric operation in horde fails.

https://github.com/nextcloud/mail/blob/e5f0e3591a44a08b36c96a52eb8d9f219bb8de2c/lib/IMAP/MessageMapper.php#L134 is where we calculate it. Could you try modifying https://github.com/nextcloud/mail/blob/e5f0e3591a44a08b36c96a52eb8d9f219bb8de2c/lib/IMAP/MessageMapper.php#L110 so it casts like $max = (int) $metaResults['max'];?

Yes, $max = (int) $metaResults['max']; fixed it!
Thank you very much for the succesfull and very fast replay!

Awesome. Then let me prepare a pull request :)

Just to be sure. Does your mailboxes show all content now as expected? :)

Oh sorry I was too quick, I can only see 1 mail in nextcloud mail app in this IMAP account now. The no integer log entry doesn't apear anymore but i get:

[mail] Error: OCA\Mail\Exception\ServiceException: Could not load message at <>

  1. /var/www/nextcloud/apps/mail/lib/Controller/MessagesController.php line 218
    OCA\Mail\Service\MailManager->getMessage(OCA\Mail\Account {}, OCA\Mail\Db\Mailbox {id: 31}, 1, true)
  2. /var/www/nextcloud/lib/private/AppFramework/Http/Dispatcher.php line 170
    OCA\Mail\Controller\MessagesController->getBody(5, "SU5CT1g=", 1)
  3. /var/www/nextcloud/lib/private/AppFramework/Http/Dispatcher.php line 99
    OC\AppFramework\Http\Dispatcher->executeController(OCA\Mail\Controller\MessagesController {}, "getBody")
  4. /var/www/nextcloud/lib/private/AppFramework/App.php line 125
    OC\AppFramework\Http\Dispatcher->dispatch(OCA\Mail\Controller\MessagesController {}, "getBody")
  5. /var/www/nextcloud/lib/private/AppFramework/Routing/RouteActionHandler.php line 47
    OC\AppFramework\App::main("OCA\Mail\Cont ... r", "getBody", OC\AppFramework\ ... {}, {accountId: "5", ... "})
  6. <>
    OC\AppFramework\Routing\RouteActionHandler->__invoke({accountId: "5", ... "})
  7. /var/www/nextcloud/lib/private/Route/Router.php line 299
    call_user_func(OC\AppFramework\ ... {}, {accountId: "5", ... "})
  8. /var/www/nextcloud/lib/base.php line 1008
    OC\Route\Router->match("/apps/mail/api/ ... y")
  9. /var/www/nextcloud/index.php line 38
    OC::handleRequest()

GET /apps/mail/api/accounts/5/folders/SU5CT1g%3D/messages/1/body
from [...] at 2020-04-23T14:00:19+00:00

Sorry for being rash

Oooof. Okay, I was actually afraid that could happen. Any other errors before that one?

jep just found this one

[mail] Error: OCA\Mail\Exception\ServiceException: Sync failed for 5:INBOX: IMAP error reported by server. at <>

  1. /var/www/nextcloud/apps/mail/lib/Service/Sync/ImapToDbSynchronizer.php line 107
    OCA\Mail\Service\Sync\ImapToDbSynchronizer->sync(OCA\Mail\Account {}, OCA\Mail\Db\Mailbox {id: 31}, 42, null, false)
  2. /var/www/nextcloud/apps/mail/lib/BackgroundJob/SyncJob.php line 86
    OCA\Mail\Service\Sync\ImapToDbSynchronizer->syncAccount(OCA\Mail\Account {})
  3. /var/www/nextcloud/lib/public/BackgroundJob/Job.php line 79
    OCA\Mail\BackgroundJob\SyncJob->run({accountId: 5})
  4. /var/www/nextcloud/lib/public/BackgroundJob/TimedJob.php line 61
    OCP\BackgroundJob\Job->execute(OC\BackgroundJob\JobList {}, OC\Log {})
  5. /var/www/nextcloud/cron.php line 125
    OCP\BackgroundJob\TimedJob->execute(OC\BackgroundJob\JobList {}, OC\Log {})

at 2020-04-23T13:00:13+00:00

IMAP error reported by server

Unfortunately that is too generic to guess what went wrong.

Mailserver or service: Icloud mail (imap.mail.me.com)

How do I get an account there? :grin:

Okay, then I'll leave this for someone else to pick up.

This issue has been automatically closed because there has been no response to our request for more information from the original author. With only the information that is currently in the issue, we don't have enough information to take action. Please reach out if you have or find the answers we need so that we can investigate further.

@ChristophWurst I can confirm this issue. With mail version 1.4.0, it is not possible to use iCloud because of this error. If I add the cast as suggested, only 1 mail message is shown. Could the problem be related only to iCloud accounts?

Could the problem be related only to iCloud accounts?

Possibly, yes

When I try to send a mail, the following stacktrace appears:

[mail] Error: Horde_Imap_Client_Exception_ServerResponse: IMAP error reported by server. at <<closure>>

 0. /var/www/html/owncloud/apps/mail/vendor/pear-pear.horde.org/Horde_Imap_Client/Horde/Imap/Client/Socket.php line 4314
    Horde_Imap_Client_Socket->_getLine(Horde_Imap_Clien ... }})
 1. /var/www/html/owncloud/apps/mail/vendor/pear-pear.horde.org/Horde_Imap_Client/Horde/Imap/Client/Socket.php line 4242
    Horde_Imap_Client_Socket->_sendCmdChunk(Horde_Imap_Clien ... }}, [Horde_Imap_Clie ... }])
 2. /var/www/html/owncloud/apps/mail/vendor/pear-pear.horde.org/Horde_Imap_Client/Horde/Imap/Client/Socket.php line 2476
    Horde_Imap_Client_Socket->_sendCmd(Horde_Imap_Clien ... }})
 3. /var/www/html/owncloud/apps/mail/vendor/pear-pear.horde.org/Horde_Imap_Client/Horde/Imap/Client/Base.php line 2267
    Horde_Imap_Client_Socket->_search(Horde_Imap_Client_Search_Query {}, {results: [2,5,1 ... }})
 4. /var/www/html/owncloud/apps/mail/vendor/pear-pear.horde.org/Horde_Imap_Client/Horde/Imap/Client/Base.php line 3533
    Horde_Imap_Client_Base->search(Horde_Imap_Client_Mailbox {}, Horde_Imap_Client_Search_Query {}, {results: [2,5,1 ... }})
 5. /var/www/html/owncloud/apps/mail/vendor/pear-pear.horde.org/Horde_Imap_Client/Horde/Imap/Client/Socket.php line 2122
    Horde_Imap_Client_Base->resolveIds(Horde_Imap_Client_Mailbox {}, Horde_Imap_Client_Ids {duplicates: false}, 2)
 6. /var/www/html/owncloud/apps/mail/vendor/pear-pear.horde.org/Horde_Imap_Client/Horde/Imap/Client/Base.php line 2003
    Horde_Imap_Client_Socket->_expunge({ids: Horde_Imap ... }})
 7. /var/www/html/owncloud/apps/mail/lib/Listener/DeleteDraftListener.php line 101
    Horde_Imap_Client_Base->expunge("Drafts")
 8. /var/www/html/owncloud/apps/mail/lib/Listener/DeleteDraftListener.php line 76
    OCA\Mail\Listener\DeleteDraftListener->deleteDraft(OCA\Mail\Account {}, 12871)
 9. /var/www/html/owncloud/lib/private/EventDispatcher/ServiceEventListener.php line 76
    OCA\Mail\Listener\DeleteDraftListener->handle(OCA\Mail\Events\MessageSentEvent {})
10. /var/www/html/owncloud/3rdparty/symfony/event-dispatcher/EventDispatcher.php line 247
    OC\EventDispatcher\ServiceEventListener->__invoke(OCA\Mail\Events\MessageSentEvent {}, "OCA\\Mail\\Events\\MessageSentEvent", Symfony\Componen ... {})
11. /var/www/html/owncloud/3rdparty/symfony/event-dispatcher/EventDispatcher.php line 73
    Symfony\Component\EventDispatcher\EventDispatcher->callListeners([Closure {},Clos ... }], "OCA\\Mail\\Events\\MessageSentEvent", OCA\Mail\Events\MessageSentEvent {})
12. /var/www/html/owncloud/lib/private/EventDispatcher/EventDispatcher.php line 80
    Symfony\Component\EventDispatcher\EventDispatcher->dispatch(OCA\Mail\Events\MessageSentEvent {}, "OCA\\Mail\\Events\\MessageSentEvent")
13. /var/www/html/owncloud/apps/mail/lib/Service/MailTransmission.php line 180
    OC\EventDispatcher\EventDispatcher->dispatch("OCA\\Mail\\Events\\MessageSentEvent", OCA\Mail\Events\MessageSentEvent {})
14. /var/www/html/owncloud/apps/mail/lib/Controller/AccountsController.php line 345
    OCA\Mail\Service\MailTransmission->sendMessage(OCA\Mail\Model\NewMessageData {}, null, null, 12871)
15. /var/www/html/owncloud/lib/private/AppFramework/Http/Dispatcher.php line 170
    OCA\Mail\Controller\AccountsController->send(11, "Das ist ein Test", "Das ist ein Test :-)", "\"Nina S**** (n ... >", "", "", false, 12871, null, null, [], null)
16. /var/www/html/owncloud/lib/private/AppFramework/Http/Dispatcher.php line 99
    OC\AppFramework\Http\Dispatcher->executeController(OCA\Mail\Controller\AccountsController {}, "send")
17. /var/www/html/owncloud/lib/private/AppFramework/App.php line 125
    OC\AppFramework\Http\Dispatcher->dispatch(OCA\Mail\Controller\AccountsController {}, "send")
18. /var/www/html/owncloud/lib/private/AppFramework/Routing/RouteActionHandler.php line 47
    OC\AppFramework\App::main("OCA\\Mail\\Cont ... r", "send", OC\AppFramework\ ... {}, {accountId: "11" ... "})
19. <<closure>>
    OC\AppFramework\Routing\RouteActionHandler->__invoke({accountId: "11" ... "})
20. /var/www/html/owncloud/lib/private/Route/Router.php line 299
    call_user_func(OC\AppFramework\ ... {}, {accountId: "11" ... "})
21. /var/www/html/owncloud/lib/base.php line 1008
    OC\Route\Router->match("/apps/mail/api/accounts/11/send")
22. /var/www/html/owncloud/index.php line 38
    OC::handleRequest()

POST /index.php/apps/mail/api/accounts/11/send
from 87.147.155.167 by Ben at 2020-06-26T14:05:00+00:00

That is an unrelated problem. The code fails to delete a draft message (created as you type the message). Please open a new ticket for this.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

StCyr picture StCyr  路  4Comments

ChristophWurst picture ChristophWurst  路  3Comments

clem-bcc picture clem-bcc  路  4Comments

fsedarkalex picture fsedarkalex  路  5Comments

CHazz picture CHazz  路  3Comments