Mass enquiry form

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

By willydoit - February 21, 2012

Hi,
We use cmsadmin to provide advertiser listings for holiday accommodation, while visitors can contact individual advertisers from the listings page, we would like to offer the visitor the ability to send a form based enquiry to multiple or all advertisers in each section. (I suspect that having a dynamic list of advertisers appear to be checked to receive an email could be costly to produce so a simple mail all facility would be sufficient)

With no php programming experience I suspect that what we need to accomplish this is likely to be pretty straight forward but would need someone to create the required code for us.

Any help or advice on how easily this could be accomplished, or potential costs would be appreciated. Our big problem is that we provide the site as a community support initiative and provide advertising on it at a minimal cost to cover admin etc (£1.00per week) so the site doesnt generate any real profit which could be used to fund such development so availible funding is minimal to say the least.

Thanks in advance for any help provided.

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: [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/