Velrest
Velrest

Reputation: 320

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

Upvotes: 0

Views: 513

Answers (3)

Ravi Ranjan
Ravi Ranjan

Reputation: 125

I think it's possible, if after/before_save not triggering then try some similar logic hooks. The following are some logic hooks that I think could help.

  • before_retrieve
  • after_retrieve
  • before_restore
  • after_restore
  • server_roundtrip
  • after_session_start
  • after_entry_point

Comment if you want more details, like how to use logic hooks e.t.c.

Upvotes: 1

Newkstron
Newkstron

Reputation: 25

What version of sugar are you using?

You can, for example, generate an after_save hook in the E-mail module instead of inboundEmail

Would be like this:

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

Do this and see if the email fires! Another possibility would be to use the after_relationship_add, because usually, the email is associated with some lead, account, or contact. try to create a hook in the module that your email is associating with and generate the operation from there

one last possibility (I do not recommend this) is to create a trigger in your database for when the data enters the table, perform the check and take some action

Upvotes: 1

Abdur Rehman
Abdur Rehman

Reputation: 3293

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.

Upvotes: 1

Related Questions