Using Sendmail for multiple recipients

Discussions related to customizing hooks. Hooks are documented at http://bigprof.com/appgini/help/advanced-topics/hooks/
Post Reply
rpierce
Veteran Member
Posts: 255
Joined: 2018-11-26 13:55
Location: Washington State

Using Sendmail for multiple recipients

Post by rpierce » 2021-02-08 19:54

Hello,

I see that some have figured out how to use Sendmail to get messages to multiple recipients. I followed the step by step instructions provided in setting up the SMTP. It is working good. But I am unable to figure out exactly how to get the messages to go to more than one recipient. I see in the forum that some have figured it out, but I'm not a coder and need some assistance if possible.

What I have is a database for tracking injuries for a construction company. When there is an injury the system sends out email notification to a list of users. I have been using PHP email to do this up till now. The problem with PHP mail is there is really no way to format them message that I can find. It seems to just dump the database info.

Below is the Sendmail code I'm testing out in the hooks file for the table. I would appreciate any help you can offer.

Ray

function firstaid_after_insert($data, $memberInfo, &$args){
// to compose a message containing the submitted data,
// we need to iterate through the $data array
foreach($data as $field => $value){
$messageData .= "$field: $value \n";
}


sendmail([
// mail recipient
'to' => "[email protected],[email protected]",


'name' => "",

// subject
'subject' => "An injury report has been submitted for " . sqlValue("select name from project where id='{$data['project']}'"),

// message
'message' => "The following Injury Report was submitted by {$memberInfo['username']} This is a preliminary report, items may change. \n\n".

"
<table>
<tbody>
<tr>
<td><strong>Date of Injury</strong></td>
<td></td>
<td><strong>Time of Injury</strong></td>
</tr>
<tr>
<td>{$data['date']}</td>
<td></td>
<td>{$data['time']}</td>
</tr>
</tbody>
</table>
<p></p>
<p><strong>Injured Worker Craft:</strong> {$data['craft']}</p>
<p><strong>First Name:</strong> {$data['fname']} &nbsp;&nbsp;&nbsp; <strong>Last Name:</strong> {$data['lname']}</p>
<p><strong>Injury Severity:</strong> {$data['severity']}</p>
<p><strong>Type of Injury:</strong> {$data['injury']}</p>
<p><strong>Body Part:</strong> {$data['body_part']}</p>
<p><strong>Treatment Provided:</strong> {$data['treatment']}</p>
<p><strong>Treated By:</strong> {$data['treat_by']}</p>
<p><strong>Mode of Injury:</strong> {$data['event']}</p>
<p><strong>Event Description:</strong> {$data['event_desc']}</p>
<p><strong>Source of the Injury:</strong> {$data['source']}</p>
<p><strong>Injury Source Details:</strong> {$data['source_desc']}</p>
<p><strong>What was the employee doing just before the incident occurred?&nbsp;</strong> {$data['action']}</p>
<p><strong>What object or substance directly harmed the employee?&nbsp;</strong> {$data['object']}</p>
<p>{$data['action_desc']}</p>
<p><strong>How it Happened:</strong> {$data['cause_explain']}</p>
<p><strong>Direct Cause:</strong> {$data['direct_cause']}</p>
<p><strong>Indirect Cause:</strong> {$data['indirect_cause']}</p>
<p><strong>Basic Cause:</strong> {$data['basic_cause']}</p>
<p><strong>Workplace Layout Issues:</strong> {$data['workplace']}</p>
<p><strong>Workplace Layout Explanation:</strong> {$data['work_explain']}</p>
<p><strong>Behavior Based Safety Factor:</strong> {$data['bbs']}</p>
<p><strong>Authors comments:</strong> {$data['comments']}",

]);



return TRUE;
}

patsd102
Veteran Member
Posts: 142
Joined: 2013-01-15 19:59

Re: Using Sendmail for multiple recipients

Post by patsd102 » 2021-02-08 20:28

I can't help with coding, but someone else asked this question a while back , and added multiple recipients via an array

Try the search on the forum
23.17

patsd102
Veteran Member
Posts: 142
Joined: 2013-01-15 19:59

Re: Using Sendmail for multiple recipients

Post by patsd102 » 2021-02-08 20:35

23.17

rpierce
Veteran Member
Posts: 255
Joined: 2018-11-26 13:55
Location: Washington State

Re: Using Sendmail for multiple recipients

Post by rpierce » 2021-02-08 22:10

I did see that thread and thought it looked promising. The trouble for me is that I have no idea on how to implement it. Maybe one of you experts could help me out??

rpierce
Veteran Member
Posts: 255
Joined: 2018-11-26 13:55
Location: Washington State

Re: Using Sendmail for multiple recipients

Post by rpierce » 2021-02-08 22:36

OK!! I used the array and actually figured out how to code it myself!! Huge pat on my back. This forum is so absolutely awesome!!1

Post Reply