Hi SugarCRM community, i am new on this big new world of developing for SugarCRM, i created a logic hook that trigger "before_safe", all works great but when the logic_hook sends the email it sends two emails, First without information and Second with the information required.

Example:

Using the opportunity module, the logic hook send me an email when a change in Sales Stage ocure.

First Email:

The opportunnity has change its Sales Stage from to

Second email

The opportunnity has change its state Sales Stage from Needs Analysis to Negotiation/Review



This is my code:


logic_hook.php


$hook_array = Array();
// position, file, function
$hook_array['before_save'] = Array();
$hook_array['before_save'][] = Array(1, 'Opportunities push feed', 'modules/Opportunities/SugarFeeds/OppFeed.php','OppFeed', 'pushFeed');
$hook_array['before_save'][] = Array(2, 'State change', 'include/Netcom/CheckStatus.php', 'CheckStatus', 'Checkstatus');
$hook_array['after_ui_frame'] = Array();
$hook_array['after_ui_frame'][] = Array(1, 'Opportunities InsideView frame', 'modules/Connectors/connectors/sources/ext/rest/insideview/InsideViewLogicHook.php','InsideViewLogicHook', 'showFrame');


CheckStatus.php

<?php
if (!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
require_once('modules/Opportunities/Opportunity.php');
require_once('data/SugarBean.php');
require_once('include/entryPoint.php');
include_once('include/SugarPHPMailer.php');
include_once('include/utils/db_utils.php');
include_once('custom/include/netcom/funciones.php');

class CheckStatus
{
function Checkstatus(&$bean, $event, $arguments)
{


$funciones = new funciones();
$txt = "The opportunnity has change its state ".$bean->fetched_row['sales_stage']." to ".$bean->sales_stage.".";
$funciones->SendMail($txt);
}
}
?>


Thank you for your help.


@spidersab