Buy Now
Sign in

How can I send an email to different addresses? from FAQ not working

larry_g1s , July 06 2018
L
larry_g1s
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 domultiple-emails.jpg
GreyHead
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
ChronoForms technical support
If you'd like to buy me a coffee or two, thank you very much
L
larry_g1s
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.)
error.JPG
Attachments
error.JPG
error.JPG
(24.99 KiB)
229 Downloads/Views
L
larry_g1s
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.
GreyHead
Hi larry_g1s,
That just shows that there are no reported errors. Please copy and paste the full debugger output.
Bob
ChronoForms technical support
If you'd like to buy me a coffee or two, thank you very much
L
larry_g1s
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.
-- LarryUntitled-1.jpg
Attachments
Untitled-1.jpg
Untitled-1.jpg
(92.77 KiB)
202 Downloads/Views
GreyHead
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
ChronoForms technical support
If you'd like to buy me a coffee or two, thank you very much
L
larry_g1s
I apologize, I thought that's what you needed. Here is all that is on the page:
[div]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
(
)
[/div]
[div]Errors
Array
(
)
[/div]
[div]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
)

)

)
[/div]
L
larry_g1s
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;
?>
GreyHead
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
ChronoForms technical support
If you'd like to buy me a coffee or two, thank you very much
L
larry_g1s
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?
L
larry_g1s
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?
GreyHead
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.
$emails = array (
'em1' => 'test01@email.com',
'em2' => 'test02@email.com,test03@email.com',
'em3' => 'test04@email.com'
);
Bob
ChronoForms technical support
If you'd like to buy me a coffee or two, thank you very much
D
dmachado
Hello,
Im trying to implement this code but just to confirm. the $emails = array its the the ID to get from the dropdown list Screen_Shot_2018-10-11_at_11.09.44.png
<?
// 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!
Attachments
Screen_Shot_2018-10-11_at_11.09.44.png
Screen_Shot_2018-10-11_at_11.09.44.png
(24.07 KiB)
103 Downloads/Views
Screen_Shot_2018-10-11_at_11.09.44.png
Screen_Shot_2018-10-11_at_11.09.44.png
(36.65 KiB)
116 Downloads/Views