Send to email address based on a drop down choice

ThatComputerDude 11 Jan, 2010
Is there a tutorial on how to do this?

I need the contact form to be sent to an email addresses associated to a drop down they select.

Thanks!
GreyHead 11 Jan, 2010
Hi ThatComputerDude,

The basic code is in FAQ 31 - that's probably enough, there are also several threads here with variants on the theme. Searching on the FAQ should find them.

Bob
ThatComputerDude 11 Jan, 2010
Hey Bob, thanks for the response.

I'm in the process of trying FAQ31 but I'm not sure I completely understand it. I'll play around with it and if I get stuck on something, I'll start asking questions.

Thanks!
ThatComputerDude 11 Jan, 2010
Form HTML
<div class="form_item">
  <div class="form_element cf_textbox">
    <label class="cf_label" style="width: 150px;">First Name</label>
    <input class="cf_inputbox required" maxlength="150" size="30" title="" id="text_0" name="text_0" type="text" />
  
  </div>
  <div class="cfclear"> </div>
</div>

<div class="form_item">
  <div class="form_element cf_textbox">
    <label class="cf_label" style="width: 150px;">Last Name</label>
    <input class="cf_inputbox required" maxlength="150" size="30" title="" id="text_1" name="text_1" type="text" />
  
  </div>
  <div class="cfclear"> </div>
</div>

<div class="form_item">
  <div class="form_element cf_textbox">
    <label class="cf_label" style="width: 150px;">Email</label>
    <input class="cf_inputbox required validate-email" maxlength="150" size="30" title="" id="text_7" name="text_7" type="text" />
  
  </div>
  <div class="cfclear"> </div>
</div>

<div class="form_item">
  <div class="form_element cf_textbox">
    <label class="cf_label" style="width: 150px;">Phone</label>
    <input class="cf_inputbox" maxlength="150" size="30" title="" id="text_2" name="text_2" type="text" />
  
  </div>
  <div class="cfclear"> </div>
</div>

<div class="form_item">
  <div class="form_element cf_textarea">
    <label class="cf_label" style="width: 150px;">Comments</label>
    <textarea class="cf_inputbox required" rows="3" id="text_5" title="" cols="30" name="text_5"></textarea>
    
  </div>
  <div class="cfclear"> </div>
</div>

<div class="form_item">
  <div class="form_element cf_dropdown">
    <label class="cf_label" style="width: 150px;">Type of Request</label>
    <select class="cf_inputbox validate-selection" id="select_4" size="1" title=""  name="select_4">
    <option value="">Choose Option</option>
      <option value="General">General</option>
<option value="Service Support">Service Support</option>
<option value="Sales">Sales</option>
<option value="Job Opportunity">Job Opportunity</option>
<option value="Speaking Engagement">Speaking Engagement</option>

    </select>
    
  </div>
  <div class="cfclear"> </div>
</div>

<div class="form_item">
  <div class="form_element cf_multiholder" style="margin-left:0px!important;">

    <table cellspacing="0" cellpadding="0" width="95%" title="" class="multi_container">
        <tbody width="100%">
            <tr width="100%">
                
            </tr>
        </tbody>
    </table>
  </div>
  <div class="cfclear"> </div>
</div>

<div class="form_item">
  <div class="form_element cf_button">
    <input value="Submit" name="button_6" type="submit" />
  </div>
  <div class="cfclear"> </div>
</div>


On Submit code - before sending email:
<?php
$emails_2 = array('Service Support'=>'mike.mayleben@intrustgroup.com', 'Sales'=>'mike.mayleben@intrustgroup.com', 'Job Opportunity'=>'mike.mayleben@intrustgroup.com', 'Speaking Engagement'=>'mike.mayleben@intrustgroup.com', . . .);
$MyForm =& CFChronoForm::getInstance('contact');
$MyFormEmails =& CFEMails::getInstance($MyForm->formrow->id);
$MyFormEmails->setEmailData(1, 'to', $emails_2[$_POST['recipients']]);
?>


Setup Emails

Dynamic To - select_4

Dynamic Subject - select_4

Dynamic Fromname - text_0

Dynamic FromEmail - text_7




What am I doing wrong that isn't allowing this to work? (i'm guessing it's in the way I setup, Setup Emails...? **** the email addresses are all the same just for testing purposes, they'll be changed to different names once I get this working.
This topic is locked and no more replies can be posted.