I've followed the FAQ for sending to multiple emails based upon a dropdown element, but it's not working. It only sends it to the first email in the listing that has more than one. What could I be missing. I've attached an image of what I've do
Hi larry_g1s,
This looks as if you have copied and pasted chunks of the FAQ, I have no idea what code you are actually using. What do you see when you add a Debugger action?
Bob
This looks as if you have copied and pasted chunks of the FAQ, I have no idea what code you are actually using. What do you see when you add a Debugger action?
Bob
Well, I copied the code, but personalized it with my info. (i.e. emails, etc.) The only error I get is the one below.
The check marks I did on that image were just to show you what I was doing (i.e. CFV5, etc.)
The check marks I did on that image were just to show you what I was doing (i.e. CFV5, etc.)
Just an update, I can get the first one working (i.e. send to single different user based upon a drop down). But changing the code to accommodate sending to multiple users associated with a selection doesn't work.
Hi larry_g1s,
That just shows that there are no reported errors. Please copy and paste the full debugger output.
Bob
That just shows that there are no reported errors. Please copy and paste the full debugger output.
Bob
I apologize. Please see attachment. I don't see the 'Dynamic To' in the Array that is set up in the 'Advance Tab' of the email.
-- Larry
-- Larry
Hi Larry,
As you can see there is a , at the start of the To Email value so there is an 'empty' email address before that.
Again, Please copy and paste the full debugger output.
Bob
As you can see there is a , at the start of the To Email value so there is an 'empty' email address before that.
Again, Please copy and paste the full debugger output.
Bob
I apologize, I thought that's what you needed. Here is all that is on the page:
Data Array
Errors
Debug Info
Data Array
Array
(
[option] => com_chronoforms5
[chronoform] => Test02
[event] => submit
[first] => John
[last] => Doe
[email] => john.doe@supermail.com
[recipients] => em2
[reelSub] =>
[message] => Testing email form.
[Apply] => Apply
[emails_to_use] =>
[ip_address] => 00.71.0.66
)
Array ( )
Errors
Array ( )
Debug Info
Array
(
[0] => Array
(
[Email] => Array
(
[0] => An email with the details below was sent successfully:
[1] => To:, larry@supermail.com
[2] => Subject:Test
[3] => From name:iA
[4] => From email:do-not-reply@supermail.com
[5] => CC:
[6] => BCC:
[7] => Reply name:John
[8] => Reply email:john.doe@supermail.com
[9] => Attachments:
[10] => Array
(
)
[11] => Body:
<table>
<tr><td><strong>Applicants Name</strong></td></tr>
<tr><td>John Doe</td></tr>
<tr><td><strong>Applicants e-mail address</strong></td></tr>
<tr><td>john.doe@supermail.com</td></tr>
<tr><td><strong>Applicants Location</strong></td></tr>
<tr><td></td></tr>
<tr><td><strong>Applicants Message</strong></td></tr>
<tr><td>Testing email form.</td></tr>
<tr><td><strong>How Applicant heard about iA</strong></td></tr>
<tr><td></td></tr>
<tr><td></td></tr>
<tr><td><strong>Placement Level</strong></td></tr>
<tr><td></td></tr>
<tr><td><strong>Applicants Link Submission</strong></td></tr>
<tr><td><a href=></td></tr>
</table><br /><br />IP: 00.71.0.66
)
)
)
P.s. this is what is in the custom code. I've changed the emails for this example:
<?php
// set a default recipient
$recipients = array( 'em1' );
if ( isset($form->data['recipients']) && $form->data['recipients'] ) {
$recipients = $form->data['recipients'];
}
$emails = array (
'em1' => array('test01@email.com'),
'em2' => array('test02@email.com', 'test03@email.com'),
'em3' => array('test02@email.com', 'test03@email.com')
);
$emails_to_use = array();
foreach ( $recipients as $v ) {
$emails_to_use = array_merge($emails[$v], $emails_to_use);
}
$emails_to_use = implode(',', $emails_to_use);
$form->data['emails_to_use'] = $emails_to_use;
?>
Hi Larry,
In the Debugger output 'emails_to_use' is empty.
And the recipients value is not an array which is what the Custom Code is expecting.
If you only have one value set for the recipient then you don't need this particular code.
Bob
In the Debugger output 'emails_to_use' is empty.
And the recipients value is not an array which is what the Custom Code is expecting.
If you only have one value set for the recipient then you don't need this particular code.
Bob
So if I have two emails I want to send to for an option (i.e. option em2 has two recipients) I wouldn't use this code?
Sorry Bob, I'm confused...The user will only select one option from the dropdown. Depending on the option the form will need to go to more than one address. Which option on that FAQ would I go with?
Hi Larry,
All of the FAQ examples after the first one are for the case where the user can select more than one address - i.e. there is a multi-select dropdown or a checkbox group used for the selection.
If you don't need this but just want to send to more than one address then using an address list in the first case should work.
All of the FAQ examples after the first one are for the case where the user can select more than one address - i.e. there is a multi-select dropdown or a checkbox group used for the selection.
If you don't need this but just want to send to more than one address then using an address list in the first case should work.
$emails = array (Bob
'em1' => 'test01@email.com',
'em2' => 'test02@email.com,test03@email.com',
'em3' => 'test04@email.com'
);
Hello,
Im trying to implement this code but just to confirm. the $emails = array its the the ID to get from the dropdown list
<?
// set a default recipient
$recipients = array ('11');
if ( isset ($form->data['recipients']) && $form->data['recipients']){
$recipients = $form->data['recipients'];
}
$emails = array (
'9' => array('xxx@ddd.com'),
'11' => array('axxx@ddd.com'),
'15' => array('cxxx@ddd.comg'),
'8' => array('cxxx@ddd.comg'),
'14' => array('fxxx@ddd.com'),
'7' => array('fxxx@ddd.com'),
'16' => array('fxxx@ddd.comg'),
'10' => array('xxx@ddd.com'),
'5' => array('portxxx@ddd.com'),
'12' => array('xxx@ddd.com'),
);
$emails_to_use = array ();
foreach ( $recipients as $v) {
$emails_to_use = array_merge ($emails[$v], $emails_to_use);
}
$emails_to_use = implode (',', $emails_to_use);
$from->data['emails_to_use'] = $emails_to_use;
?>
Do I need to implement anything else?
Thanks a lot!
Im trying to implement this code but just to confirm. the $emails = array its the the ID to get from the dropdown list

<?
// set a default recipient
$recipients = array ('11');
if ( isset ($form->data['recipients']) && $form->data['recipients']){
$recipients = $form->data['recipients'];
}
$emails = array (
'9' => array('xxx@ddd.com'),
'11' => array('axxx@ddd.com'),
'15' => array('cxxx@ddd.comg'),
'8' => array('cxxx@ddd.comg'),
'14' => array('fxxx@ddd.com'),
'7' => array('fxxx@ddd.com'),
'16' => array('fxxx@ddd.comg'),
'10' => array('xxx@ddd.com'),
'5' => array('portxxx@ddd.com'),
'12' => array('xxx@ddd.com'),
);
$emails_to_use = array ();
foreach ( $recipients as $v) {
$emails_to_use = array_merge ($emails[$v], $emails_to_use);
}
$emails_to_use = implode (',', $emails_to_use);
$from->data['emails_to_use'] = $emails_to_use;
?>
Do I need to implement anything else?
Thanks a lot!
This topic is locked and no more replies can be posted.
