Re: [Christopherb] email entire member list (Using the Membership Module)
Hi,
There's a function with CMS Builder called sendMessage() that lets you send emails.
What you can do is set up an HTML form that has 2 fields, one called "subject" and then one called "message". In the action of this form, you can have the form submit to itself (ie, action = "?" ).
At the top of your script you can use this code:
if (@$_REQUEST['subject'] && @$_REQUEST['message'] && $CURRENT_USER['isAdmin']) {
list($membersRecords, $membersMetaData) = getRecords(array(
'tableName' => 'accounts',
'allowSearch' => false,
));
$emailList = join(",", array_filter(array_pluck($memberRecords, 'email')));
sendMessage(array(
'to' => "to@email.com",
'from' => "from@email.com",
'subject' => @$_REQUEST['subject'],
'text' => @$_REQUEST['message'],
'headers' => array(
'BCC' => $emailList,
),
));
}
This code will only execute if the current user is an administrator and both subject and message were given a value.
What the script does then is get all of the users in "accounts" and create a comma separated list of their emails. It then sends out an email with all of these emails in it's BCC field. You'll need to change the value of the "to" and "from" field to whatever emails you'd like to use.
Hope this helps get you started.
---------------------------------------------------
Jason Sauchuk - Project Manager
interactivetools.com
Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/