Trigger logic hook whe new mail gets synced from IMAP server

I am trying to add a Logic Hook for Emails synced from IMAP Mail server. In the end i want trigger a hook when a new mail gets synced and check the senders mail if its saved in one of the accounts.

The problem is that the Synced Mails dont get saved (at least not in InboundMail or Emails module) so the after/before_save does not trigger.

Here is my hook from logic_hooks.php:

$hook_array['after_save'][] = Array(1, 'Create Lead', 'custom/modules/InboundEmail/LeadLogicHook.php', 'LeadLogicHook', 'handleLead');

It does not work in InboundEmail and Email Module.

And the LeadLogicHook:

if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');

class LeadLogicHook 
    function handleLead($bean, $event, $arguments) 

Is this even possible with logic hooks?

1 Like

This is probably not possible.

Have you tried with a Workflow? I fear you will probably get the same problem, only saved Emails will trigger the workflow. But it’s worth checking out.

You can, of course, customize the code of the function that imports the emails. You just have to find it (sometimes this is tricky…), and create a custom version.

The Email module is still evolving, these things can change in the near future.

1 Like

We also discovered the same problem. Is there an upgrade-save way of executing some code when new mail gets synced from an IMAP server?