This topic is locked

How to use a button to send a mass e-mail

4/16/2017 9:04:08 PM
PHPRunner General questions
M
marcelorribas author

Hi everyone, how you doing?
I need to create a button on View page to send an e-mail for several different users. After read the manual and a lot of different forum´s posts, I was able to create the code below (it´s works fine on Add and Edit pages ) but it doesn´t work when I put it in a button.
Any ideas?
Thanks in advance,
Marcelo
=====================================================

global $dal;

//select text addresses from users table

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

$rs = $tblUsers->Query("IDcond like '%".$values['idcond']."%'");
while ($data = db_fetch_array($rs))

{

// To send HTML mail, the Content-type header must be set

$headers = "MIME-Version: 1.0" . "\r\n";

$headers .= "Content-type: text/html; charset=iso-8859-1" . "\r\n";
$email=$data["email"];//get all addresses that fit the query

$from="nao_responda@xxxxxxxx.com";

$msg=$values["XXXXXXXXXXXX"];

$subject=$values['XXXXXXXXXXX'];

$fileArray = my_json_decode($values["documento"]);

$attachments = array();
foreach($fileArray as $f)

{

$attachments[] = array("path" => $f["name"]);

}
$ret=runner_mail(array('to' => $email,

'subject' => $subject,

'body' => $msg,

"attachments" => $attachments,

'from'=>$from));

if(!$ret["mailed"])

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

}
return true;