Forums

Dynamic to (email adress value) not working

Wicher 05 Feb, 2011
Hi,

First of all, a very big THANKS for this wonderfull superb joomla component! I love it!

However I have the following issue.

I use a dropdown list in the beginning of my form that has two options with as value an email adress. Depending on which option they select, the email should be sent to the correct email adress.

So I use this code:
<select name="contactwith" title="Nothing selected" id="contactwith">
        <option selected value="">Select</option><br>
          <option value="email1@domain.nl">Bestuur</option>
          <option value="email2@domain.nl">Steunpunt</option>
      </select>


And in the email setup, I just have a "dynamic to" in which I enter "contactwith" (I also have a bcc in which I have my own adress).

In my eyes this should work. But the email only arrives on the BCC adress, and not on the email adress value of the "contacwith" field.

Any help would be greatly appreciated.

Many thanks in advance.

Best regards,
Wicher
GreyHead 05 Feb, 2011
Hi Wicher,

Please see FAQ #31 which has the code for doing this without showing the email addresses in the browser.

That said the code you have looks OK and should work as it is. If you turn Form Debug on you may get more info that will help pin down the problem. In particular the contactwith in the Dynamic To box should have no quotes or brackets.

Bob
Wicher 05 Feb, 2011
Dear Greyhead,

Thanks for your reply.

I didn't even know about the debug function. Thanks for learning me this usefull option!

According to the debug function, the form was sent to the email of the dynamic to. However it really doesn't arrive there.

----------------------------------------------------------

1.Form passed first SPAM check OK
2.Form passed the submissions limit (if enabled) OK
3.Form passed the Image verification (if enabled) OK
4.Form passed the server side validation (if enabled) OK
5.$_POST Array: Array ( [contactwith] => [email]email1@domain.nl[/email] This e-mailadres is protected against spambots. U need Javascript to be able to see it. [aanhef] => Dhr. [voornaam] => Test [achternaam] => Test [adres] => test [postcode] => test [plaats] => test [telefoon] => test [fax] => test [email] => [email]emailofvisitor@hisdomain.nl[/email] [levenseindebesluit] => te willen ontvangen [onderwerp] => Dit is een test [bericht] => Dit is een test [Submit] => Bericht verzenden [9df277f04fab00d57948c3206b3cb570] => 1 [1cf1] => dabf1de4d60a1bea801f0c6e2f4ecb16 [chronoformname] => contact )
6.$_FILES Array: Array ( )
7.Form passed the plugins step (if enabled) OK
8.An email has been SENT successfully from (domain.nl)noreply@domain.nl to [email]email1@domain.nl[/email] This e-mailadres is protected against spambots. U need Javascript to be able to see it.
9.An email has been SENT successfully from (This website) [email]noreply@domain.nl[/email] to [email]emailofvisitor@hisdomain.nl[/email]
10.Debug End
11.Redirect link set, click to test:
index.php?option=com_content&view=article&id=42:bericht-verzonden&catid=1

------------------------------------------------------------------------------------


I entered the On submit code from FAQ#31
I have it like this:
<?php$emails_2 = array('em1'=>'email1@domain.nl', 'em2'=>'email2@domain.nl', . . .);$MyForm =& CFChronoForm::getInstance('contact');$MyFormEmails =& CFEMails::getInstance($MyForm->formrow->id);$MyFormEmails->setEmailData(1, 'to', $emails_2[$_POST['recipients']]);?


And ofcourse I adjusted the form code like this:
 <select name="contactmet" title="Geen keuze gemaakt" id="contactmet">
        <option selected value="">Selecteer</option><br>
          <option value="em1">Bestuur</option>
          <option value="em2">Steunpunt</option>
      </select{/code]


But now I get the following parse error:

Parse error: syntax error, unexpected T_VARIABLE in /home/XXX/domains/domain.nl/public_html/components/com_chronocontact/libraries/customcode.php(64) : eval()'d code on line 1>


Help for both issues would be greatly appreciated.

Many thanks in advance.

With best regards,
Wicher
GreyHead 05 Feb, 2011
Hi Wicher,

Please can you also paste in the 'dummy emails' from the debug page.

You have the Email cloaking plug-in running on this page. It's possible that is causing a problem. Please can you test using the Form Link from the Forms Manager.

Bob
Wicher 05 Feb, 2011
Wow Greyhead you are fast!

Btw while you where answering my reply before this one, I was editing that post to add a new problem with that I get with the code from FAQ #31. Any idea where that comes from?

Ok here the dummy emails:

---------------------------------------

From: domain.nl [noreply@domain.nl]
To: em1
CC: [email]myemail@gmail.com[/email]
BCC: [email]myemail2@domain.com[/email]
Subject: Ingevuld contact formulier
Onderstaand bericht is verzonden door:

Dhr. Test Test

Test
Test
Adres:
Test
Test Test

Email: [email]emailofvisitor@domain.com[/email]

Telefoonnummer: Test
Faxnummer: Test
Test Test heeft aangegeven een exemplaar van het Levenseindebesluit te willen ontvangen.
________________________________________
Het bericht:


Submitted by ip adress

Files:


E-MAIL MESSAGE
From: This website [noreply@domain.nl]
To: [email]emailofvisitor@domain.com[/email]
CC:
BCC:
Subject: Ontvangst bevestiging van uw bericht aan WEBSITE
Geachte Test Test,

Wij hebben van u onderstaande gegevens en bericht ontvangen.

Wij zullen zo spoedig mogelijk reageren.

Met vriendelijke groet,
Website.
Uw gegevens:
Aanhef: Dhr.
Voornaam: Test
Achternaam: Test
Adres: Test
Postcode: Test
Plaats: Test
Telefoonnummer: Test
Faxnummer: Test
E-mail adres: [email]emailofvisitor@domain.com[/email]

U heeft aangegeven een exemplaar van het levenseindebesluit te willen ontvangen

Uw bericht:
Onderwerp: Test
Bericht: Test

GreyHead 05 Feb, 2011
Hi Wicher,

First of all the dummy emails show "To: em1" so it looks as though you aren't using a Dynamic To element here.

The FAQ code has got a little mangled with the copy and paste:
<?php
$emails_2 = array('em1'=>'email1@domain.nl', 'em2'=>'email2@domain.nl', . . .);
$MyForm =& CFChronoForm::getInstance('contact');
$MyFormEmails =& CFEMails::getInstance($MyForm->formrow->id);
$MyFormEmails->setEmailData(1, 'to', $emails_2[$_POST['recipients']]);
?>

The array in the second line needs completing without . . . in it.
In line 3 ('contact') needs to match the name of your form.
In line 5 the ['recipients'] needs to match the name of your select box.

Bob
Wicher 12 Feb, 2011
Hey Greyhead,

Thanks again for your reply.

I see the mistake I made with the code yeah. However doing it right didn't solve the problem. For some reason when the "Dynamic to" is a value that can be selected from a dropdown list it doesn't work. It does work when the value is something that is filled in the form in a text field.

I have solved my problem by just making two forms.

Thanks for your help, and perhaps this is something the Chronoforms team could look into. Would be nice if it is possible to do it like I originally wanted.

Best regards,
Wicher
GreyHead 12 Feb, 2011
Hi Wicher,

The code has been used often and works perfectly but may need some adjusting to your form. Please post your version so that we can see what is happening.

Bob
This topic is locked and no more replies can be posted.