How to add email in new record with hook after or before save?

@Dharmik

You can add the code to SugarEmailAddress.php for testing. The function debug_backtrace write in log who called saveEmail (the first array). I looked at my log and saw that the first call from include/SugarObjects/templates/person/Person.php with old data of email and the second call from custom/modules/Contacts/<my_logichook_file>.php with new data of email.

        $GLOBALS['log']->fatal(get_class()." ". __FUNCTION__." id:\n ".print_r($id,true));
        $GLOBALS['log']->fatal(get_class()." ". __FUNCTION__." module:\n ".print_r($module,true));
        $GLOBALS['log']->fatal(get_class()." ". __FUNCTION__." this->addresses:\n ".print_r($this->addresses,true));
        $GLOBALS['log']->fatal(get_class()." ". __FUNCTION__." debug_backtrace:\n ".print_r(debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS,0),true));