This topic is locked

Send email conditional

2/18/2016 5:18:08 AM
PHPRunner General questions
E
epanc author

Hi, I have used the manual code to send emails automatically when I add new data:
//** Send email with new data ****

$email="test@test.com";

$from="admin@test.com";

$msg="";

$subject="New data record";
$msg.= "Name: ".$values["name"]."\r\n";

$msg.= "Email: ".$values["email"]."\r\n";

$msg.= "Age: ".$values["age"]."\r\n";
$ret=runner_mail(array('to' => $email, 'subject' => $subject, 'body' => $msg, 'from'=>$from));

if(!$ret["mailed"])

echo $ret["message"];
My requirement is to automatically send new data if the value of "xyz" Field "aa". Otherwise no action.

Thank you.

emendoza 2/18/2016

In the "After record added" event place the following:
If ($values ['aa'] == "xyz") {
//** Send email with new data ****

$email="test@test.com";

$from="admin@test.com";

$msg="";

$subject="New data record";
$msg.= "Name: ".$values["name"]."\r\n";

$msg.= "Email: ".$values["email"]."\r\n";

$msg.= "Age: ".$values["age"]."\r\n";
$ret=runner_mail(array('to' => $email, 'subject' => $subject, 'body' => $msg, 'from'=>$from));

if(!$ret["mailed"])

echo $ret["message"];

}