email entire member list (Using the Membership Module)

By Christopherb - April 15, 2011

We would like the capability to email the entire member list. Any ideas on what we may need to do?

Thank you.

Re: [Christopherb] email entire member list (Using the Membership Module)

By Jason - April 15, 2011

Hi,

Would you be able to give some more information about what you are trying to accomplish? How do you want to send the emails? Is this a one time email, or do you need to email them more than once? How are you creating the message body for the email?

Let us know and we can give you some suggestions.

Thanks
---------------------------------------------------
Jason Sauchuk - Project Manager
interactivetools.com

Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/

Re: [Christopherb] email entire member list (Using the Membership Module)

By Christopherb - April 17, 2011

After some thought, what would be a good form-to-mail php script to use if all we want to do is populate the BCC field with all the users within the CMS builder database?

Re: [Christopherb] email entire member list (Using the Membership Module)

By Jason - April 18, 2011

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/