I have a table called myemail that has an index column and then 3 columns in varchar or text type named tostuff, subject, body.
When those fields are retrieved I have the parts of an email ready to loop through and send using the runner_email function.
This is the code sitting in the List page Custom Query Events:
global $dal;
$sql = "SELECT * FROM `myemail`";
$rstmp = CustomQuery($sql);
if($rstmp === FALSE) {
die(mysql_error());
}
while ($datatmp = db_fetch_array($rstmp))
{
$to = $datatmp["tostuff"];
$subject = $datatmp["subject"];
$body = $datatmp["body"];
$from = "mygmail@gmail.com";
$ret=runner_mail(array('to' =>$to,'subject' =>$subject, 'htmlbody' =>$body,'charset' => 'UTF-8', 'from'=>$from ));
}
I have tried different connection methods and different PHPRunner code examples. I figured Jane's was sure to work.
This is adapted from Jane's example in the Tips and Tricks Forum.
Jane's Example
But I keep getting this error:
mysqli_fetch_array() expects parameter 1 to be mysqli_result, null given
Same error with this example from the PHPRunner documentation on mass emails (never more than 7 or 8 in actual use on a Dedicated Server )--
global $dal;
//select emails from Users table
$tblUsers = $dal->Table("myemail");
$rs = $tblUsers->QueryAll();
while ($data = db_fetch_array($rs))
{
$to =$data["tostuff"];
$subject = $data["subject"];
$email =$data["body"]."\r\n";
$from="mgmail@gmail.com";
$msg="Check what's hot this season";
$subject="Monthly newsletter";
$ret=runner_mail(array('to' => $to, 'subject' => $subject, 'body' => $email, 'from'=>$from));
if(!$ret["mailed"])
echo $ret["message"]."
";
}