Forums

Selection field that triggers Dynamic Email&Subject-RESOLVED

geekazoids 12 Mar, 2010
I need a custom chronoform configured that will allow a site visitor to select 1 of 6 reasons why they are contacting us. When they hit Submit, we need the form to use the visitor's selection to trigger an email to a particular email address, and then set the email subject to the selection.
Ex: selectionvalue1 => send to email1 with dynamic subject "selectionvalue1"
selectionvalue2=> send to email2 with dynamic subject "selectionvalue2"

So far, I was able to use FAQ31 to code a chronoform to translate a select value to an email address. The roadblock is that I need the email subject to reflect the value that was shown on the website, but it comes through as the translated email address🙂 So close! Willing to pay $40-50 for a quick fix. Please respond and I will provide all the details you need.
GreyHead 12 Mar, 2010
Hi geekazoids,

You can set a subject in the OnSubmit Before Box.
<?php
$subject = JRequest::getString('select', 'some default', 'post');
JRequest::setVar('subject', $subject);
?>

Then put subject in the Dynamic Subject box.

Bob

(who's PayPal account is available on request)
geekazoids 12 Mar, 2010
:D Let me try that and if successful I will make sure you are compensated!
geekazoids 12 Mar, 2010
Bob, I apologize in advance for my lack of understanding!

Was I supposed to modify the snippet you gave me? I just c&p it into the OnSubmit before box with the existing code so this was the end result:
<?php
$subject = JRequest::getString('select', 'some default', 'post');
JRequest::setVar('subject', $subject);
?>
<?php 
$emails_2 = array(
  'DSMMEwebmaster@sistersofmary.org'=>'DSMMEwebmaster@sistersofmary.org', 
  'vocationsinquiry@sistersofmary.org'=>'vocationsinquiry@sistersofmary.org', 
  'info@spiritussanctus.org'=>'info@spiritussanctus.org', 
  'sjab@sistersofmary.org,DSMMEwebmaster@sistersofmary.org' =>
    'sjab@sistersofmary.org,DSMMEwebmaster@sistersofmary.org');
$MyForm =& CFChronoForm::getInstance('ContactUs');
$MyFormEmails =& CFEMails::getInstance($MyForm->formrow->id);
$MyFormEmails->setEmailData(1, 'to', $emails_2[$_POST['recipients']]);
?>

I send through a test, and got an email with a subject line of "some default".
GreyHead 12 Mar, 2010
Hi geekazoinds,

You need to change 'select' to match the name of the select box you are using.

Bob

PS The email array you are using still displays the email addresses in the Form HTML - not a good idea, they will probably be stolen and spammed.
geekazoids 12 Mar, 2010
I am SO sorry but I have not gotten it to work right. The selection field is labeled "Subject" and the field name for it is "select_3"

I have tried
<?php
$subject = JRequest::getString('select_3', 'Contact Us Web Form Submission', 'post');
JRequest::setVar('subject', $subject);
?>
and
<?php
$subject = JRequest::getString('Subject', 'Contact Us Web Form Submission', 'post');
JRequest::setVar('subject', $subject);
?>

and the Email subject comes through blank. in the Email Setup I have Dynamic Subject set to Subject. What am I doing wrong? Is there any info that I can provide that will help clarify?

Now if we keep pursuing this only to build a form that will allow spammers to steal email, then I would not be proud of the results. Can you recommend a more secure way? Please PM me to discuss compensation, this is very important to the organization.

Going offline for 30 mins...
GreyHead 13 Mar, 2010
Hi geekazoid,

The label has nothing to do with it so we can forget that Subject.

I think that the problem is that you have Subject in your Dynamic Subject instead of subject (no capital S).

Bob
geekazoids 15 Mar, 2010
Got it - the form html was like this:
<option value="email@email.com">General Inquiry</option>
and the onSubmit code was like this:
[email]'email@email.com[/email]'=>'email@email.com'

and that is why I was getting the email address in the subject.

I changed it to say:

<option value="General Inquiry from website">General Inquiry</option>

'General Inquiry from website'=>'email@email.com'

And the email gets sent to the proper subject, and the subject line is correct now. Solved!!!
This topic is locked and no more replies can be posted.