phpopen-sourcesugarcrmsuitecrmsugarbean

Logic Hook on Emails 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:

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

class LeadLogicHook 
{
    function handleLead($bean, $event, $arguments) 
    {
        _ppl("Test");
    }
}

Is this even possible with logic hooks?

EDIT: Added some Code


Solution

  • No need for logic hook or any other custom code. Sugar/SuiteCRM use a scheduler job to fetch email from IMAP server. You can check scheduler job function (function::pollMonitoredInboxes) which fetch emails. That contain code which is used for email fetching. track back code and you will find everything you want.