Mass enquiry form

4 posts by 2 authors in: Forums > CMS Builder
Last Post: February 22, 2012   (RSS)

Re: [willydoit] Mass enquiry form

By Jason - February 21, 2012

Hi,

The biggest part of this will be getting your list of advertisers. Are they all stored in the same section? Will the form simply send to all of them, or will it have to only send to some of them?

Once you get your advertiser records, you need to combine all their emails into a comma separated list.

For example:

$toEmailList = join(",", array_unique(array_pluck($advertiserRecords, 'email')));

This code assumes that all the advertiser records you want to send the message to are in a variable called $advertiserRecords, and they have a field called "email" where their email is stored.

After that, you can use the CMS Builder sendMessage() function to send your email. Here is a very basic example:

$mailErrors = sendMessage(array(
'from' => 'me@example.com',
'to' => $toEmailList,
'subject' => "Email Subject",
'text' => "My Message",
));

if ($mailErrors) { die("Error Sending Message: ".$mailErrors); }


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/

Re: [Jason] Mass enquiry form

By willydoit - February 21, 2012

Hi jason,
Thanks for that, i assume that i would use the normal listing page code before the header of the php page to open the database link etc, then add your first line of code to create the array. The form will be submitted to all the advertisers in the record.

I assume i would then simply create my enquiry form in the usual manner using dreamweavers insert form facilities, I usually use an existing form to mail facility for handling such forms to a single email address, are you saying that cmsb also has a form to mail facility built in which would be implemented automatically just by using your second lot of code or do we use your code aswell as our normal form to mail handler?

If we just use your code, where would i put your second section of code in relation to the <FORM METHOD=POST ACTION= element and what value would i put for action=

Sorry if this is basic stuff we should know.

Also is there any security facility built in which we can implement to avoid abuse from spam bots etc.

Thanks in advance for your help,

Re: [willydoit] Mass enquiry form

By Jason - February 22, 2012

Hi,

That first piece of code I posted would come after you have the normal header code to connect to CMS Builder. Also, before using that piece of code, you'll need a getRecords() call that will retrieve all of the advertiser records that you want to send the email to. In the code example, it assumes that the variable you're storing your advertiser records in a variable called $advertiserRecords.

The CMS Builder function sendMessage() just sends an email, it doesn't create a form for processing emails. The "to" option does allow for mulitple addresses, which we get in the first code snippet. You'll need to create your own form that will submit to a page that has this code on it.

There is no built in Captcha security with CMS Builder. You can always integrate in your own captcha script intto your form and add it in as part of your normal error checking.

Give this a try. If you run into any problems, let us know and attach the code you have so far. We may be able to point you in the right direction.

Hope this helps
---------------------------------------------------
Jason Sauchuk - Project Manager
interactivetools.com

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