Forums

Send email according to option select

richardJam 02 Dec, 2013
Hi ,

I have the same issue as what can be found at the following topic - http://www.chronoengine.com/forums/index.php?option=com_chronoforums&cont=posts&f=2&t=67671

And specifically to the following reply -

Hi quantum_leap,

Hmmm you're about ten days too late. Max just took down all the old FAQs when he put up the new CC+CF FAQ application.

But it's still in the database :-)

One ChronoForms user wanted to offer form users a drop-down list of e-mail addresses that they could pick from and send the form results to - but they wanted to do it without putting the email addresses themselves on the form page.

We found a way to do this in two parts. First include the following in your Form HTML:

Select the recipient you wish to contact:
<select name="recipients"><
	<option value="em1">Name 1</option>
	<option value="em2">Name 2</option>
	<option value="em3">Name 3</option>
	. . . 
</select>


Then enter this code in the 'On Submit code - before sending email' field:

For ChronoForms 3.1 and later:
<?php
$emails_2 = array(
	'em1'=>'sample1@email.com', 
	'em2'=>'sample2@email.com', 
	'em3'=>'name_3@example.com', 
	. . .
);
$MyForm =& CFChronoForm::getInstance('form_name_here');
$MyFormEmails =& CFEMails::getInstance($MyForm->formrow->id);
$MyFormEmails->setEmailData(1, 'to', $emails_2[$_POST['recipients']]);
?> 


For ChronoForms v3.0 and later:
<?php
$emails_2 = array('em1'=>'sample1@email.com', 'em2'=>'sample2@email.com', 'em3'=>'name_3@example.com', . . .);
$emails[0]->to .= ','.$emails_2[$_POST['recipients']];
?>


For ChronoForms 2.5.x and earlier
<?php
$emails = array('em1'=>'name_1@example.com', 'em2'=>'name_2@example.com', 'em3'=>'name_3@example.com', . . .);
$rows[0]->extraemail = $emails[$_POST['recipients']];
?>


Thanks to deafjoomla.com for this FAQ



Bob




However it seems that chronoforms has rewritten the class names so I get an error with regards to the CFEMails not being found.

Is there possibly a Chronoforms 4 version of this class and method that I can use in this case or an alternative solution to my problem?
richardJam 02 Dec, 2013
Fantastic!
I don't know why I could not find that earlier
Thank you very much
This topic is locked and no more replies can be posted.