SENDING EMAILS TO A SPECIFIC GROUP OF USERS - Aug 6th, 2012
|
If you're using an email form and sendmail to create and send emails, the manual way to add recipients to the list would be something like this: NOTE: I haven't checked this out so let me know if there are issues.
'To' => email1@example.com,email2@example.com
If all of your potential recipients have user accounts, you might also think about changing the To values to a variable ($emailList) that gets populated from user email addresses where there's a "notifications" check box checked in their record.
Something like this:
First add a check box field called notifications to your user account editor.
Then, create your list from the accounts records.
<?php list($emailListRecords,) = getRecords(array( "tableName" => "accounts", 'where' => "notifications = '1' AND hidden = '0'", 'orWhere' => "notifications = '1' AND hidden = '1'", )); $emailList = ""; foreach( $emailListRecords as $record ) { $emailList.= $record['email'] .","; } ?>
Then use the variable in your sendmail code,
'To' => $emailList,
Another way of listing all of the notification email addresses, say in a viewer, would be:
<?php // Get email list of those members with notifications on, and access to the project $accounts = mysql_query_fetch_all_assoc("SELECT * FROM `{$TABLE_PREFIX}accounts` WHERE notifications = '1'"); $emailList = join(",", array_pluck($accounts, 'email')); ?> <?php echo $emailList ;?>
|
The materials on this web site have been created for use with CMS Builder content management software. CMS Builder software is published and licensed for use by InteractiveTools.com. Please contact
Interactive Tools for information on the downloading of the software or the purchasing of licenses.