I have a need to send e-mails to all users in my login table that ticked the field Cancellations field as "Yes". This e-mail needs to be sent when a new record is added by admin. I got this code from support, but it is suddenly not working anymore- used to sent e-mails without a problem. The record is saved and returns to the list page (as setup as event on after record added), but no mails are sent out.
Can anyone maybe see an error in the code?
function BeforeAdd(&$values)
{
global $conn;
$all_emails="";
$strSQL = "select Email from Login where Available='Yes'";
$rs = db_query($strSQL,$conn);
while ($data = db_fetch_array($rs))
$all_emails .= $data["Email"].", ";
$all_emails = substr($all_emails,0,strlen($all_emails)-2);
$message="The following rentals are available. Please book at our office.\r\n";
$subject="Rental Availability:";
foreach($values as $field=>$value)
$message.= $field." : ".$value."\r\n";
mail($all_emails, "$subject", "$message");
return true;
}
Have newest version 218 of PHPRunner installed.