This topic is locked
[SOLVED]

 Send mass email to all users

8/9/2010 9:15:17 AM
PHPRunner General questions
S
siro author

I used this code from PHPrunner 5.2 Manual__
global $dal;
//select emails from Users table
$tblUsers = $dal->Table("UsersTableName");
$rs = $tblUsers->QueryAll();
while ($data = db_fetch_array($rs))
{
$email.=$data["EmailAddress"].", ";
$from="admin@test.com";
$msg="Check what's hot this season";
$subject="Monthly newsletter";
$ret=runner_mail(array('to' => $email, 'subject' => $subject, 'body' => $msg, 'from'=>$from));
if(!$ret["mailed"])
echo $ret["message"]."
";
}
But It is not working
This is the error code i got****

Fatal error: Call to a member function on a non-object in /homepages/16/d227498675/htdocs/Jesus/joomtop/topbase/include/TopStore_events.php on line 28
Please help me

Thanks

A
ann 8/9/2010

Joel,
here is the correct code:

global $dal;

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

$rs = $tblUsers->QueryAll();

$email="";

while ($data = db_fetch_array($rs)){

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

$from="admin@test.com";

$msg="Check what's hot this season";

$subject="Monthly newsletter";

$ret=runner_mail(array('to' => $email, 'subject' => $subject, 'body' => $msg, 'from'=>$from));

if(!$ret["mailed"])

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

}



also make sure you've replaced EmailAddress and UsersTableName with your actual field and table names.

S
siro author 8/9/2010

Hi Ann
This is the way I used this code: After record updated

But no error code, and email not sending


give me another example.
global $dal;

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

$rs = $tblUsers->QueryAll();

$email="";

while ($data = db_fetch_array($rs)){

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

$from="admin@test.com"; $msg="Check what's hot this season";

$subject="Monthly newsletter"; $ret=runner_mail(array('to' => $email, 'subject' =>

$subject, 'body' => $msg, 'from'=>$from)); if(!$ret["mailed"]) echo $ret["message"]."
"; }

A
ann 8/10/2010

Joel,
try to modify the code in the following way:

...

$rs = $tblUsers->QueryAll();

while ($data = db_fetch_array($rs)){

$email=$data["Email"];

...



If it doesn't help please publish your project on Demo Account and open a ticket at http://support.xlinesoft.com sending a URL to your pages along with instructions on reproducing this error. 'Demo Account' button can be found on the last screen in the program.

S
siro author 8/10/2010

Thanks Ann
This code is working find