I am trying to get my form to function by sending out separate emails depending on the options the user selects (multiple selects).
For example, if a user is interested in products A, B and C, upon submit, A will go to one email address, B to another and C to a third.
I am using this snippet (placeholder emails in place);
<?php
// Type: Snippet
//$recipient = $hook->getValue('products_interested[]');
$formFields = $hook->getValues();
$recipient = $formFields['products_interested[]'];
$recipientList = array();
if (strpos($recipient,'Product A') !== false) {
array_push($recipientList, "email A");
}
if (strpos($recipient,'Product B') !== false) {
array_push($recipientList, "email B");
}
if (strpos($recipient,'Product C') !== false) {
array_push($recipientList, "email C");
}
else{
//$email = 'email Admin';
}
$result = array_unique($recipientList);
//$result = substr(implode(",", $result), 0);
echo $result;
$hook->setValue('sendTo',$result);
return true;
//
In my chunk, I have this call:
[[!FormIt?
&hooks=`recipient,email,redirect`
&emailTpl=`adminEmailRequestAQuote`
&emailTo=`email Address`
&emailCC=`[[+sendTo]]`
&emailSubject='Request a Quote'
&emailMultiSeparator=`, `
&redirectTo=`1`
&validate=`products_interested:required,
contact_email_phone:required,
mm_subscribe:required` ]]
When I take `[[+sendTo]]` out of FormIt, it will show the applicable email address in the email response, but when I apply it to &emailCC, the emails will not go out to separate emails.
Any thoughts or suggestions would be greatly appreciated!
Thanks.