Email on Update

QuestionsEmail on Update
Gary Brett asked 5 years ago

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

2 Answers
Abu Ghufran answered 5 years ago

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:

https://phpgrid.desk.com/customer/portal/articles/926266

Gary Brett answered 5 years ago

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())
;
}
}

Your Answer

14 + 9 =

Login with your Social Id:

OR, enter

Attach code here and paste link in question.
Attach screenshot here and paste link in question.



How useful was this discussion?

Click on a star to rate it!

Average rating 0 / 5. Vote count: 0

No votes so far! Be the first to rate it.

We are sorry that this post was not useful for you!

Let us improve this post!

Tell us how we can improve this post?