Email Logic Hook - After save

Hello,

I would like to execute a specific code after an email is received. The code parses the email subject and do specific actions. I would like a more custom way than binding the email with a case from the subject ( [Case:XXX] to Case XXX)
However it seems that the hook is never executed.

I use sugar 7.7.2

I added those files and ran "Quick Repair and Rebuild".

./custom/Extension/modules/Emails/Ext/LogicHooks/test.php

<?php

   $hook_version = 1;

   $hook_array['after_save'][] = array(
      1,
      'Create case or add to case',
      'custom/modules/Emails/Emails_hook.php',
      'email_utils',
      'link_to_case'
);

./custom/modules/Emails/Emails_hook.php

<?php

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

   class email_utils
   {
      function link_to_case($bean, $event )
      {
         $GLOBALS['log']->debug('-- Link to case executed');

         // code goes here

      }

   }

?>

What am I doing wrong here ?

Thank you for your help

Parents Reply
  • Thank you Enrico

    1. No error in my php log. The log is effectively writable.
    2. I have no custom/modules/Emails/Ext folder. (I do have it for other module : /custom/modules/Calls/Ext/LogicHooks/logichooks.ext.php)
    3. I added the third parameter
    4. I added public
    5. What is the purpose of restricting log to fatal error ?
    6. Yes the sugarcrm.log is writable.

    Unfortunately still not working...

Children
  • No problem.

    #2 check for overall folder permissions, repair again and see if it works. If not check if there is something wrong with the naming conventions (eg: misspelling, incorrect case etc). I think that might be the problem at this point

    #5 it was to make sure that you do not get lost with all the "noise" on the debug level log, if you reduce the log level and increase the logging of the method you will only see what is actually happening on your code

    If you have a copy of the system (obviously don't use your production), give it a test with my code and add some logging there, if that works, there is definitely something wrong with the current code.

    --

    Enrico Simonetti

    Principal Technical Advisory Manager

    SugarCRM Inc

  • Hi Enrico, 

    I realized I still had directory permissions issues on Extension and includes folder. The owner was root so the apache server was not able to write into those folders.

    Sorry if I kinda waster your time.

    Thank you