How to Use FAQ31 email to is set to em1

mrthrust 21 Apr, 2009
Hi there, Ive been searching this forum for ages looking through all the FAQ (ie:31) and others

the problem is my dropdown select, using the FAQ31 (How can I safely show a list of e-mail addresses?)
to list my options in the select statement so that each refrence an Email address to send to depending on Region selected.
ie:

em1 = Ayrshire, em2 = Central, em3 = Dumfries & Galloway, em4 = Dundee & Angus, em5 = Edinburgh, em6 = Fife, em7 = Glasgow,
em8 = Grampian, em9 = Highland, em10 = North Lanarkshire, em11 = South Lanarkshire,

we are using version Chrono Contact 3.1 RC4.11 in Joomla 1.5

basic form structure: Name: Email Address: Region: Enquiry: Security:

Region is the Dropdown list were it lists all the regions in our area..

The Form is setup as:

General Tab:
Form Name: Our Form Name
Email the results? Yes
Form tag attachment: Blank
Form method: POST
Submissions limit (in seconds) Blank
Date Format: Blank
Load Chronoforms CSS/JS Files? No
Debug: On
MYSQL Statement? Engine
Enable mambots? Yes

SETUP Emails Tab:
Dynamic To: recipients
Subject: Our Form Subject
BCC: Our BCC Email
Formname: Our Formname
FormEmail: Email to which its SENT FROM

Email Tempalte Tab :
This was generated its self..

<table border="0">
<tbody>
<tr class="sectiontableentry1">
<td class="titleCell"><label for="name">Name:</label></td>
<td class="fieldCell"><span>{name}</span></td>
</tr>
<tr class="sectiontableentry1">
<td class="titleCell"><label for="email">Email Address:</label></td>
<td class="fieldCell"><span>{email}</span></td>
</tr>
<tr class="sectiontableentry2">
<td class="titleCell"></td>
<td class="fieldCell"></td>
</tr>
<tr class="sectiontableentry1">
<td class="titleCell" valign="top"><label for="enquiry">Enquiry:</label></td>
<td class="fieldCell"><span>{enquiry}</span></td>
</tr>
<tr class="sectiontableentry2">
<td class="titleCell">Security</td>
<td class="fieldCell">{imageverification}</td>
</tr>
</tbody>
</table>


using the following HTML in form HTML box :

<table class="contentpane">
  <tr class="sectiontableentry1">
    <td class="titleCell"><label for="name">Name:</label></td>
    <td class="fieldCell"><input name="name" type="text" size="35"></td>
  </tr>
  <tr class="sectiontableentry1">
    <td class="titleCell"><label for="email">Email Address:</label></td>
    <td class="fieldCell"><input name="email" type="text" size="35"></td>
  </tr>
  <tr class="sectiontableentry2">
    <td class="titleCell"><label for="region">Region:</label></td>
    <td class="fieldCell">
      <select name="recipients" size="1" class="select">
        <option selected>Please select a Region</option>
        <option value="em1">Ayrshire</option>
        <option value="em2">Central</option>
        <option value="em3">Dumfries & Galloway</option>
        <option value="em4">Dundee & Angus</option>
        <option value="em5">Edinburgh</option>
        <option value="em6">Fife</option>
        <option value="em7">Glasgow</option>
        <option value="em8">Grampian</option>
        <option value="em9">Highland</option>
        <option value="em10">North Lanarkshire</option>
        <option value="em11">South Lanarkshire</option>
      </select>
    </td>
  </tr>
  <tr class="sectiontableentry1">
    <td valign="top" class="titleCell">
      <label for="enquiry">Enquiry:</label>
    </td>
    <td class="fieldCell">
      <textarea name="enquiry" cols="30" rows="12"></textarea>
    </td>
  </tr>
  <tr class="sectiontableentry2">
    <td class="titleCell">Security</td>
    <td class="fieldCell">{imageverification}</td>
  </tr>
  <tr class="sectiontableentry2">
    <td class="titleCell">
      <input type="submit" name="Submit" value="Send"></td>
    <td class="fieldCell"></td>
  </tr>
</table>


Then in the Onsubmit before email box this code:


<?php
$emails_2 = array('em1'=>'our1stemail@test.com', 'em2'=>'our2ndemail@test.com', 'em3'=>'our3rdemail@test.com',);
 $emails[0]->to .= ','.$emails_2[$_POST['recipients']];
?>


So i though when the post method is sent from the form the recipients loaded in the array would be replaced with what ever the value of the form recipients was ie: em1 would be equal to and sent to = [email]our1stemail@test.com[/email]

but on our tests its not sending out, now if i add a To: within the "SETUP Email tab:" and add a email to the field
the email is sent out and the debug information is displayed telling me its all good the to address has the email filled in

but when we use the "Dynamic to:" the to: address in the debug info is set to "em1" and the debug info will say that the email has been sent to em1,

Debug info (Image verification turned off)

From: Our Company Name [admin@oursite.org.uk]
To: em5
CC:
BCC: [email]us@test.com[/email]
Subject: Enquiry
Name: marty test
Email Address: [email]test@test.com[/email]

Enquiry: this is my test
Security {imageverification}


Submitted by xxx.xxx.xxx.xxx

Files:

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 ( [name] => marty test [email] => [email]test@test.com[/email] [recipients] => em5 [enquiry] => this is my test [Submit] => Send [a6124e6da8d6df235787399e1fc5f658] => 1 )
6. $_FILES Array: Array ( )
7. Form passed the plugins step (if enabled) OK
8. An email has been SENT successfully from (Our Company Name [admin@oursite.org.uk]) to em5
9. Debug End
10.
Redirect link set, click to test:



Has anyone figured out how to get the dropdown to populate the To: address ?

Thanks in advance
Max_admin 21 Apr, 2009
Hi mrthrust,

the issue is that the code has been changed in RC3.1 to a more standardized form, here is how you should do it in the onsubmit, replace the 2nd line with this:


$MyForm =& CFChronoForm::getInstance('form_name_here');
$MyFormEmails =& CFEMails::getInstance($MyForm->formrow->id);
$MyFormEmails->setEmailData(1, 'to', $emails_2[$_POST['recipients']]);


this should be in the onsubmit before email of course!

Cheers
Max
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
mrthrust 22 Apr, 2009
Max
thanks for your response m8..
that worked a treat...
If any other users out there are having similar issues, then im sure this will solve there issue.

following code was used in the HTML form part


      <select name="recipients" size="1" class="select">
        <option selected>Please select a Region</option>
        <option value="em1">Ayrshire</option>
        <option value="em2">Central</option>
        <option value="em3">Dumfries & Galloway</option>
        <option value="em4">Dundee & Angus</option>
        <option value="em5">Edinburgh</option>
        <option value="em6">Fife</option>
        <option value="em7">Glasgow</option>
        <option value="em8">Grampian</option>
        <option value="em9">Highland</option>
        <option value="em10">North Lanarkshire</option>
        <option value="em11">South Lanarkshire</option>
      </select>


The PHP Code before sending Emails was as follows:


<?php
$emails_2 = array('em1'=>'test@test.com','em2'=>'test2@test.com','em3'=>'test3@test.com','em4'=>'test4@test.com','em5'=>'test5@test.com','em6'=>'test6@test.com','em7'=>'test7@test.com','em8'=>'test8@test.com','em9'=>'test9@test.com','em10'=>'test10@test.com','em11'=>'test11@test.com',);
$MyForm =& CFChronoForm::getInstance('eventenquiry');
$MyFormEmails =& CFEMails::getInstance($MyForm->formrow->id);
$MyFormEmails->setEmailData(1, 'to', $emails_2[$_POST['recipients']]);
?>



cheers again max..

MartyπŸ˜‰

ps: keep up the excellent work.
Max_admin 22 Apr, 2009
No problems, Thanks for confirmation and posting the full code!πŸ™‚

Regards,
Max
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
Sandstone 30 Apr, 2009
Thank you for this thread! Hopefully the FAQ will be updated soon so there are less dents in the walls all over the world.πŸ˜‰

One point of clarification that I ran into:
In the Setup Emails tab, do NOT use a DynamicTo set to "recipients".
Instead, set up a To with any e-mail address you want. (I used the admin's real e-mail address in case for some strange reason the form defaulted to it in the future.)

Again, many thanks!
GreyHead 01 May, 2009
Hi Sandstone,

I've updated the FAQ with the code Max posted.

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

VPS & Email Hosting 20% discount
hostinger