Class 'CFEMails' not found

jhdesign 02 Sep, 2011
I'm migrating CF 3.2 forms to CF 4.

I have this custom before email code:

$MyFormEmails =& CFEMails::getInstance($MyForm->formrow->id);


I get this error on CF4.


Fatal error: Class 'CFEMails' not found 


Has this class been renamed in CF4?

Jacob
GreyHead 02 Sep, 2011
Hi jhdesign,

Yes, just about every variable and class name changed. Mas did a pretty complete re-write.

What are you trying to do? Is this to enable a email depending on form data?

Bob
jhdesign 02 Sep, 2011
The form gets contactid from URL, fetches email and sends email to custom address. Here's the full code:


$db =& JFactory::getDBO();
$query = "SELECT email_to FROM #__contact_details WHERE id=".$_POST['contactid'];
$db->setQuery($query);
$jEmail=$db->loadResult();


$MyForm =& CFChronoForm::getInstance('StaffContact');
$MyFormEmails =& CFEMails::getInstance($MyForm->formrow->id);
$MyFormEmails->setEmailData(1, 'to', $jEmail);
GreyHead 02 Sep, 2011
Hi jhdesign,

A little simpler in CFv4. Use a Custom Code action before the Email action and put something like this in the code box:
$db =& JFactory::getDBO();
$query = "
  SELECT `email_to` 
    FROM `#__contact_details`
    WHERE `id` = '{$form->data['contactid']}' ;
";
$db->setQuery($query);
$form->data['jEmail'] = $db->loadResult();
?>

Then use {jEmail} in the Email Dynamic To Email box

Bob
jhdesign 02 Sep, 2011
Thanks Ill try now. New issue with Captcha CF4. I started a nwe thread.
This topic is locked and no more replies can be posted.