Hi Abu, on my grid I wanted an email alert when a row is edited, I tried using the code below but I never receive the email, is there something I am doing wrong?
function update_lead()
{
$id = $data["params"]["id"];
$lead_status = $data["params"]["lead_status"];
$username = $data["params"]["username"];
$postcodes = $data["params"]["postcodes"];
if($lead_status=="None")
{
require_once('/class.phpmailer.php');
$mail = new PHPMailer();
$mail->IsSMTP();
$mail->AddCC('[email protected]');
$mail->Subject = "Lead Updated";
$body = ("Adviser Status has been changed. ");
$mail->MsgHTML($body);
$mail->AddCC($address);
if(!$mail->Send())
;
}
}
Thank you
Code seems fine, you can try putting some debug statements like echo and print_r for variables and check the output in firebug ajax call response as mentioned in following:
Top support Abu, thank you for your help in getting this one sorted much appreciated.. If it helps anyone going forward this works;
$e["on_update"] = array("update_lead", null, true);
$g->set_events($e);
function update_lead($data)
{
$id = $data["params"]["id"];
$lead_status = $data["params"]["lead_status"];
$username = $data["params"]["username"];
$postcodes = $data["params"]["postcodes"];
//if($lead_status=="1")
{
require_once('/var/sites/g/ghlportal.co.uk/public_html/Library/form/mailer/phpmailer/PHPMailerAutoload.php');
$mail = new PHPMailer();
$mail->isSMTP();
$mail->Host = 'smtp.gmail.co.uk';
$mail->Port = 25;
$mail->SMTPAuth = true;
$mail->Username = '[email protected]';
$mail->Password = 'mypassword';
$mail->SMTPSecure = 'tls';
$mail->From = '[email protected]';
$mail->FromName = 'GHL Portal';
$mail->AddCC('[email protected]');
$mail->addAddress('[email protected]');
$mail->isHTML(true);
$mail->Subject = "Lead Status / Postcode Updated";
$body = ("FAO Nigel & Finance..<br />{$data["params"]["username"]}; has recently changed their Lead Status or PostCode to <b>{$data["params"]["lead_status"]};</b> ///// 1 – On | 0 – Off<br />
<b>PostCodes</b> ::: {$data["params"]["postcodes"]};<br />
<b>Off Until</b> ::: {$data["params"]["leaddays"]};");
$mail->MsgHTML($body);
$mail->AddCC($address);
if(!$mail->Send())
;
}
}