This topic is locked
[SOLVED]

 Email from database but CC all the emails

5/6/2019 12:12:39 PM
PHPRunner General questions
D
david22585 author

I'm using the trial version of PHPRunner 10 to see if it can truly do everything our association needs. One of the biggest things we have is groups setup for email and multiple programs/systems to e-mail people from. I'm using the cost to get the e-mails from a database to send it to them, but I need it to also show all the same e-mails as a CC to as well, so everyone get a reply from the system. Here is the code I'm using for the e-mail:

global $dal;

//select emails from Users table

$tblUsers = $dal->Table("bod_members");

$rs = $tblUsers->QueryAll();

while ($data = db_fetch_array($rs))

{

$email=$data["email"];

$from="email@mail.com";

$fromName="HC Work Order System";

$msg="";

$subject="New Work Order ".$values["submission_id"]."";
$msg.= "Work Order ID: ".$values["submission_id"]."\r\n";

$msg.= "Name: ".$values["name"]."\r\n";

$msg.= "Address: ".$values["address"]."\r\n";

$msg.= "E-Mail: ".$values["email_address"]."\r\n";

$msg.= "Phone Number: ".$values["phone_number"]."\r\n";

$msg.= "Problem: ".$values["description_of_problem"]."\r\n";

$msg.= "Date Submitted: ".$values["submission_date"]."\r\n";
$ret=runner_mail(array('to' => $email, 'subject' => $subject, 'body' => $msg, 'from'=>$from, 'replyTo' => $values["email_address"]));

if(!$ret["mailed"])

echo $ret["message"]."
";

}


So the e-mail it sent to everyone from the bod_members table, and the main reply to is the person who submitted the work order request. When we reply, a reply needs to go to the person that submitted it, but also the people from the bod_members table so everyone is in the same loop. There is about 15 different systems that I'd need to build for us that would have this function, and having to edit every single one when someone changes a role or a e-mail would be a pain in the butt when I can just edit their e-mail addresses from the bod_members table.
I was thinking there may be a way to use the code from this page ( How to get a comma separated list of selected email address)., but I'm not quite sure how to tweak it to use with the email echo statement.
Thanks!

admin 5/8/2019

I think something like this will work:

global $dal;

$email="";

//select emails from Users table

$tblUsers = $dal->Table("bod_members");

$rs = $tblUsers->QueryAll();

while ($data = db_fetch_array($rs))

{

$email.=$data["email"].",";

}

$email=rtrim($email,',');
$from="email@mail.com";

$fromName="HC Work Order System";

$msg="";

$subject="New Work Order ".$values["submission_id"]."";
$msg.= "Work Order ID: ".$values["submission_id"]."\r\n";

$msg.= "Name: ".$values["name"]."\r\n";

$msg.= "Address: ".$values["address"]."\r\n";

$msg.= "E-Mail: ".$values["email_address"]."\r\n";

$msg.= "Phone Number: ".$values["phone_number"]."\r\n";

$msg.= "Problem: ".$values["description_of_problem"]."\r\n";

$msg.= "Date Submitted: ".$values["submission_date"]."\r\n";
$ret=runner_mail(array('to' => $email, 'subject' => $subject, 'body' => $msg, 'from'=>$from, 'replyTo' => $values["email_address"]));

if(!$ret["mailed"])

echo $ret["message"]."
";
D
david22585 author 5/10/2019



I think something like this will work:


That works! Just need to see if a few other items can work for me before purchase. Gotta figure out how to do bank balances for multiple accounts. You're the man Sergey!