Announcement

Collapse
No announcement yet.

Check Personal Email Accounts keeps failing after a few hours

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Check Personal Email Accounts keeps failing after a few hours

    Hi there,

    I've added a personal mailbox to check for personal emails. The cronjob is doing it's work, but after some hours it keeps failing. So I deleted the personal e-mail account and re-added it, after which it is succesfully importing the personal email again. But then after a few hours it keeps failing again. No errors are thrown regarding this issue in the log files. Is this a familiair problem, or is there a way to debug this?

  • #2
    Hi

    You can debug in this file
    application/Espo/Services/EmailAccount.php

    run cron.php manually in CLI.

    Comment


    • #3
      Thanks,

      I've traced the issues back to /application/Espo/Core/Mail/Importer.php. After running some tests, I found two fatal errors, both caused by a similar problem:

      Fatal error: Call to undefined method ArrayIterator::getAddressList() in /application/Espo/Core/Mail/Importer.php on line 242 Fatal error: Call to undefined method ArrayIterator:: getParameter() in /application/Espo/Core/Mail/Importer.php on line 392
      This issue occurs because $message->getHeader(...) returns not a single result, but plural (in an array). In case of the first error, the email message header somehow contains the row 'To: steve@sowmedia.nl' twice. In the second error, a message header contains the header 'Content-Type: UTF-8' twice.

      The imported emails are coming from Gmail. I've traced back the emails and indeed in some cases Gmail really outputs the headers twice. So I think the solution would be to make sure only one of the duplicate headers is used. I've gone a ahead and rewritten Importer.php to do so by replacing $list = $message->getHeader($type)->getAddressList(); on line 242 with the following:

      if(is_a($message->getHeader($type), 'ArrayIterator')) {
      $list = $message->getHeader($type)->current()->getAddressList();
      } else {
      $list = $message->getHeader($type)->getAddressList();
      }

      I've also used the same logic on the other lines where getHeader() is being used. This results to the attached Importer.php file (renamed to txt because of uploading restrictions).
      Attached Files

      Comment


      • #4
        Thank you. Fix https://github.com/espocrm/espocrm/c...2567ff0889a684


        Zendframework is a nightmare. They could use a collection class with the Header interface for multiple headers.

        Comment


        • #5
          Great, thanks!

          Comment

          Working...
          X