Please enable JavaScript to view this site.

Navigation: Advanced topics > Events > Sample events > Email

Send mass email to all users

Scroll Prev Next More

 

To send an email with new data to email addresses from the user table, use the following code in one of the following events:

Add page: Before record added

Add page: After record added

Edit page: Before record updated

Edit page: After record updated

 

 

 

global $dal;
//select emails from Users table
$tblUsers = $dal->Table("UsersTableName");
$rs = $tblUsers->QueryAll();
while ($data = db_fetch_array($rs))
{
$email=$data["EmailAddress"];
$from="[email protected]";
$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"]."<br>";
}

See also:

About Database API

Send simple email

runner_mail function

DAL method: QueryAll()

 

Created with Help+Manual 7 and styled with Premium Pack Version 3 © by EC Software