'recept@school.nz','Enrolments'=>'if@school.nz','Sports'=>'sport@rosmini.school.nz','International'=>'int@school.nz','Accounts'=>'acc@school.nz','IT'=>'adm@school.nz');$MyForm =& CFChronoForm::getInstance('ContactUs');$MyFormEmails =& CFEMails::getInstance($MyForm->formrow->id);$MyFormEmails->setEmailData(1, 'to', $emails_2[$_POST['subject']]);?> What I've tried to do in V4 is add this to a custom code event (as shown in the attached image).This however results in the following error:Fatal error: Class 'CFEMails' not found in /var/www/vhosts/school.nz/subdomains/upgrade/httpdocs/administrator/components/com_chronoforms/form_actions/custom_code/custom_code.php(18) : eval()'d code on line 4Obviously something has changed but alas I know not what."> Changing e-mail address depending on subject. - Forums

Forums

Changing e-mail address depending on subject.

rcadmin 20 Jun, 2012
It's been a while since I have worked on Chronoforms properly and since then it has gone from V3 to V4.

In the past I would assign an email address by putting the following code in the "On Submit code - before sending email" box:
<?php
$emails_2 = array('General Question'=>'reception@rosmini.school.nz', 'Absentees'=>'recept@school.nz','Enrolments'=>'if@school.nz','Sports'=>'sport@rosmini.school.nz','International'=>'int@school.nz','Accounts'=>'acc@school.nz','IT'=>'adm@school.nz');
$MyForm =& CFChronoForm::getInstance('ContactUs');
$MyFormEmails =& CFEMails::getInstance($MyForm->formrow->id);
$MyFormEmails->setEmailData(1, 'to', $emails_2[$_POST['subject']]);
?> 


What I've tried to do in V4 is add this to a custom code event (as shown in the attached image).

This however results in the following error:
Fatal error: Class 'CFEMails' not found in /var/www/vhosts/school.nz/subdomains/upgrade/httpdocs/administrator/components/com_chronoforms/form_actions/custom_code/custom_code.php(18) : eval()'d code on line 4

Obviously something has changed but alas I know not what.
GreyHead 20 Jun, 2012
Hi rcadmin,

The equivalent in CFv4 is:
<?php
$emails_2 = array(
  'General Question'=>'reception@rosmini.school.nz', 
  'Absentees'=>'recept@school.nz',
  'Enrolments'=>'if@school.nz',
  'Sports'=>'sport@rosmini.school.nz',
  'International'=>'int@school.nz',
  'Accounts'=>'acc@school.nz',
  'IT'=>'adm@school.nz'
);
$form->data['to_email'] = $emails_2[$form->data['subject']];
?>
Then put to_email in the Dynamic To box in the Email action.

Bob
rcadmin 20 Jun, 2012
Excellent... thanks it works like a dream.

Once again, an excellent product with great support. 😀
This topic is locked and no more replies can be posted.