I've been using hooks to send emails in the hooks tablename_after_insert function, and it has been working fine until a few days ago. The PHP code I am using calls for 'sendmail'. I'm wondering if anyone has suggestions on a different or better way to send automated emails in this hook?
Thank you in advance.
Partial code. Some variables comprise much of the email message but don't affect the sendmail service.
Code: Select all
$response =sql("SELECT contacts.email_address
FROM `contacts`
WHERE contacts.notify = 'yes'
AND contacts.project_id = $auditproject",$eo);
while ($row = db_fetch_assoc($response)) {
$receipt[] = $row['email_address'];
}
//****************************************************************************
$msgTEXT = "<strong>The following audit finding was submitted by <u>$authorname</u>.</strong>"."
<strong>Project: </strong><u>$projectname</u>
<strong>Date of audit: </strong>$auditdate <strong>Auditor: </strong>$auditorname
<strong>Deficiency Found?: </strong>{$data['risk']}
<strong>Area audited: </strong>$area
<strong>Category: </strong>$category
<strong>Subcategory: </strong>$subcategory
<strong>Findings:</strong>
{$data['find1']}
<strong>Follow up required?: </strong>{$data['fu']}
<strong>Follow up completed?: </strong>{$data['fu_comp']}
<strong>Follow up description:
</strong>{$data['fu_desc']}
<strong>Person responsible for follow up: </strong>{$data['resp']}
<strong>Follow up closure target date: </strong>{$data['targ_date']}
<strong>Closure Status</strong>
<strong>Finding closed?: </strong>{$data['closed']}
<strong>Finding closure date: </strong>{$data['close_date']}
";
foreach ($receipt as $address){
sendmail(array(
// mail recipient
'to' => $address,
'name' => "",
// subject
'subject' => "An audit has been submitted for $projectname ",
// message
'message' => nl2br (stripcslashes($msgTEXT)),
// sender address
"From: [email protected]"
));
}
//end email code
return TRUE;
}