Forums

Send the form to a specific e-mail address

andrea74 22 Nov, 2010
Hello, I need your help.
I'm using ChronoForm with good success, but now I need to improve a form with a Dynamic destination address.
In the form there is a select like this

<select class="cf_inputbox" id="select_1" size="1" title=""  name="select_1">
<option value="">Choose Option</option>
<option value="Argentina">Argentina</option>
<option value="Italy">Italy</option>
<option value="USA">USA</option>
</select>

My question is: is it possible to send the form to a specific e-mail address depending on the value selected?
For example:
[list]if "Argentina" is selected, the "To" field should be [email]argentina@address.com[/email][/list]
[list]if "Italy" is selected, the "To" field should be [email]italy@address.com[/email][/list]
[list]if "USA" is selected, the "To" field should be [email]USA@address.com[/email][/list]

If yes, how and where should be set the PHP code to do it?
Thank you very much for the support.
Andrea
GreyHead 22 Nov, 2010
Hi Andrea74,

Please see FAQ #31 from the FAQs menu above.

Bob
andrea74 22 Nov, 2010

Hi Andrea74,

Please see FAQ #31 from the FAQs menu above.

Bob


Ciao Bob, sorry but I didn't see before.
I have just tried to do it following the example, but I have question: is it necessary to set something in the "Setup Email" tab (To/ Dynamic To) or not?
Thank you.
GreyHead 22 Nov, 2010
Hi andrea74,

You need a Dynamic To with the name of the post variable that you've put the email address into.

Bob
andrea74 23 Nov, 2010

Hi andrea74,

You need a Dynamic To with the name of the post variable that you've put the email address into.

Bob


Thank you Bob for your good support: now it works.
I have a last question for you: in my case, the select has 150 item options (world country name) and I would like to use one e-mail address for 149 items, and another for only one item.
Is it possible to change the php code suggested in FAQ#31 to avoid to have a very long Array?

Similar to:

<?php

if ( $emails_2[$_POST['select_8']] == "United States of America") {
$emails_2 = array('United States of America'=>'email_1@email.com');
$MyForm =& CFChronoForm::getInstance('GeneralInfo');
$MyFormEmails =& CFEMails::getInstance($MyForm->formrow->id);
$MyFormEmails->setEmailData(1, 'to', $emails_2[$_POST['select_8']]);

} else {

$emails_2 = 'email_2@email.com';
$MyForm =& CFChronoForm::getInstance('GeneralInfo');
$MyFormEmails =& CFEMails::getInstance($MyForm->formrow->id);
$MyFormEmails->setEmailData(1, 'to', $emails_2[$_POST['select_8']]);
}
?>

But doesn't work....
GreyHead 23 Nov, 2010
Hi andrea74,

Please try this
<?php
$country = JRequest::getString('select_8', 'United States of America', 'post');
if ( $country == "United States of America") {
  $emails_2 = 'email_1@email.com';
} else {
  $emails_2 = 'email_2@email.com';
}
$MyForm =& CFChronoForm::getInstance('GeneralInfo');
$MyFormEmails =& CFEMails::getInstance($MyForm->formrow->id);
$MyFormEmails->setEmailData(1, 'to', $emails_2);
?>

Bob
andrea74 23 Nov, 2010
Dear Bob: it works fine!
I use a lot of Joomla Extensions, but the best customer support received is from ChronoEngine.
Thank you very much.
Andrea
This topic is locked and no more replies can be posted.

VPS & Email Hosting 20% discount
hostinger