I have been trying to create a form that sends two emails - one to the same address every time (mine, [email]myemail@example.com[/email]) and another to an address depending on one of the fields chosen by the user.
To do this I have set my address in the general email setup of the form and tried to use some code for sending the "conditional" one.
So, I have put in the "form HTML"
<option value="em1">Email1</option>
<option value="em2">Email2</option>
<option value="em3">Email3</option>
and in the "on Submit code"
<?php
$emails_2 = array('em1'=>'email1@example.com', 'em2'=>'email2@example.com', 'em3'=>'email3@example.com');
$MyForm =& CFChronoForm::getInstance('LoA_appl_2011');
$MyFormEmails =& CFEMails::getInstance($MyForm->formrow->id);
$MyFormEmails->setEmailData(1, 'to', $emails_2[$_POST['NSO']]);
?>
(the names of the fields and the emails have been changed for the purpose of this post).
Now, the problem is that, when someone is filling the form, the email is sent to [email]email1@example.com[/email] but not to my email (the one set in the general email setup). I tried even having an array within an array (e.g.
$emails_2 = array('em1'=>array('email1@example.com', myemail@example.com), 'em2'=>'email2@example.com', 'em3'=>'email3@example.com');
) but with no avail: it gives the user an error and the form is send to [email]myemail@example.com[/email] but not to [email]email1@example.com[/email]!I assume that there is a simple solution to this but I was unable to find it (and, believe me, I did try searching in the tutorials and perusing all the forums).
Any suggestion will be appreciated,
Thanks for all your work,
radu