Forums

Send email to a different recipient based on selection

sagraphics 26 Sep, 2012
I have followed the instructions in the faws for trying to send a form to a different person dependant on a selection within the form (we're sending to different branches based on branch selection). But when i try to test the form i get

You must provide at least one recipient email address.

I really don't know what I am doing wrong. I am using Joomla 1.7.3 and Chronoforms 4.0 RC2.0

Thanks :?
GreyHead 26 Sep, 2012
Hi saragraphics,

Please post the code you are using and the entry you have in the Email Static and Dynamic To Email boxes.

You might also want to upgrade the the latest release of ChronoForms as there have been several bug-fixes - though I don't think that is the problem here.

Bob
sagraphics 27 Sep, 2012
I have used the wizard to build the form, but here is the code in the form itself and I have attached some screenshots of how I have set it up:

<div class="ccms_form_element cfdiv_text" id="name_container_div"><label>Name</label><input maxlength="150" size="30" class=" validate['required','alpha']" title="" label_over="0" hide_label="0" type="text" value="" name="Name" />
<div class="clear"></div><div id="error-message-Name"></div></div><div class="ccms_form_element cfdiv_text" id="email_container_div"><label>Email</label><input maxlength="150" size="30" class=" validate['email']" title="" label_over="0" hide_label="0" type="text" value="" name="Email" />
<div class="clear"></div><div id="error-message-Email"></div></div><div class="ccms_form_element cfdiv_text" id="telephone_container_div"><label>Telephone</label><input maxlength="150" size="30" class=" validate['required','number']" title="" label_over="0" hide_label="0" type="text" value="" name="Telephone" />
<div class="clear"></div><div id="error-message-Telephone"></div></div><div class="ccms_form_element cfdiv_text" id="vehicle_type_container_div"><label>Vehicle Type</label><input maxlength="150" size="30" class="" title="" label_over="0" hide_label="0" type="text" value="" name="Vehicle_Type" />
<div class="clear"></div><div id="error-message-Vehicle_Type"></div></div><div class="ccms_form_element cfdiv_text" id="max_price_container_div"><label>Max Price</label><input maxlength="150" size="30" class="" title="" label_over="0" hide_label="0" type="text" value="" name="Max_Price" />
<div class="clear"></div><div id="error-message-Max_Price"></div></div><div class="ccms_form_element cfdiv_text" id="vehicle_max_age_container_div"><label>Vehicle Max Age</label><input maxlength="150" size="30" class="" title="" label_over="0" hide_label="0" type="text" value="" name="Vehicle_Max_Age" />
<div class="clear"></div><div id="error-message-Vehicle_Max_Age"></div></div><div class="ccms_form_element cfdiv_select" id="branch_container_div"><label for="recipients">Branch</label><select size="1" label_over="0" hide_label="0" id="recipients" class=" validate['required']" title="" type="select" name="recipients">
<option value="r1">Airdire</option>
<option value="r2">Ashford</option>
<option value="r3">Brigend</option>
<option value="r4">Castle Gresley</option>
<option value="r5">Doncaster</option>
<option value="r6">Exeter</option>
<option value="r7">Gloucester</option>
<option value="r8">Manchester</option>
<option value="r9">Shrewsbury</option>
<option value="r10">Southall</option>
<option value="r11">Forest Tractors</option>
<option value="r12">Newcastle</option>
<option value="r13">Norfolk</option>
</select>
<div class="clear"></div><div id="error-message-recipients"></div></div><div class="ccms_form_element cfdiv_textarea" id="additional_requirements_container_div"><label>Additional Requirements</label><textarea cols="45" rows="12" class="" title="" label_over="0" hide_label="0" type="textarea" name="Additional_Requirements"></textarea>
<div class="clear"></div><div id="error-message-Additional_Requirements"></div></div><div class="ccms_form_element cfdiv_submit" id="send_container_div"><input name="Send" class="" value="Send" type="submit" />
<div class="clear"></div><div id="error-message-Send"></div></div>

[attachment=0]Screen shot 2012-09-27 at 11.05.20.png[/attachment]
sagraphics 27 Sep, 2012
another shot (why can we only upload 1 at a time or am i being silly?)
sagraphics 27 Sep, 2012
more screenshots showing custom code (i was being silly)
GreyHead 27 Sep, 2012
Hi sagraphics,

Everything so far looks OK.

Bob
sagraphics 27 Sep, 2012
and this is the dynamic send to
GreyHead 27 Sep, 2012
Hi sagraphics,

Still no obvious problems. Please drag a Debugger action into the On Submit event, then submit the form and post the debug - including the 'dummy emails' results here.

Bob
sagraphics 27 Sep, 2012
debug info below

You must provide at least one recipient email address. Data Array:
Array
(
[Name] => sarah
[Email] => [email]info@sagraphics.co.uk[/email]
[Telephone] => 01200441734
[Vehicle_Type] =>
[Max_Price] =>
[Vehicle_Max_Age] =>
[recipients] => r2
[Additional_Requirements] => testing
[Send] => Send
[1e52e3ca2673fdd40c28248950a6e660] => 1
[chronoform] => SalesEnquiry
[event] => submit
[Itemid] => 421
[option] => com_chronoforms
[view] => form
)
Debug Data
An email has been SENT successfully from (SHB Hire Ltd)info@shb.co.uk to
Email template:

Name sarah
Email [email]info@sagraphics.co.uk[/email]
Telephone 01200441734
Vehicle Type
Max Price
Vehicle Max Age
Branch {Branch}
Additional Requirements testing


Submitted by 146.255.107.30
Thank you for your enquiry.
We will be in touch soon to discuss your vehicle requirement in more detail.
GreyHead 27 Sep, 2012
Hi segraphics,

Hmm, I missed it earlier, r2 has two email addresses in the emails array. I don't think that will work unless you use my custom Email [GH] action.

Please try another recipient and see if that works. If now please take a Form Backup using the icon in the Forms Manager and post it here (as a zipped file) or PM or email it to me and I'll take a closer look.

Bob
sagraphics 28 Sep, 2012
I remove the second recipient for r2, and still the same error

You must provide at least one recipient email address. Data Array:
Array
(
[Name] => sarah
[Email] => [email]info@sagraphics.co.uk[/email]
[Telephone] => 01200441734
[Vehicle_Type] =>
[Max_Price] =>
[Vehicle_Max_Age] =>
[recipients] => r2
[Additional_Requirements] => testing
[Send] => Send
[2ab815184446d3a0e44cc3aa0de88136] => 1
[chronoform] => SalesEnquiry
[event] => submit
[format] => html
[Itemid] => 421
[option] => com_chronoforms
[view] => form
)
Debug Data
An email has been SENT successfully from (SHB Hire Ltd)info@shb.co.uk to
Email template:

Name sarah
Email [email]info@sagraphics.co.uk[/email]
Telephone 01200441734
Vehicle Type
Max Price
Vehicle Max Age
Branch {Branch}
Additional Requirements testing


Submitted by 146.255.107.30
Thank you for your enquiry.
We will be in touch soon to discuss your vehicle requirement in more detail.

I have attached the form backup.
GreyHead 28 Sep, 2012
Hi sagraphics,

Thanks for the backup, I think I have found the problem:
<?php
$recipient = JRequest::getString('recipients', '1', 'post');
. . .
$form->data['email_to_use'] = $emails[$recipients];
?>

The second line has $recipient (singular) the fourth line has $recipients (plural)

Bob

PS Where you have '1' in the second line you can set a default value e.g. r99 and assign an address to that.
sagraphics 28 Sep, 2012
I have changed the missing s, but still have the same error.....
GreyHead 29 Sep, 2012
Hi Sarah,

I checked this and it works OK for me apart from the r8 line which still has the problem with multiple addresses.
<?php
$recipient = JRequest::getString('recipients', '1', 'post');
$emails = array (
	'r1' => 'info+r1@example.com',
	'r2' => 'info+r2@example.com',
	'r3' => 'info+r3@example.com',
	'r4' => 'info+r4@example.com',
	'r5' => 'info+r5@example.com',
	'r6' => 'info+r6@example.com',
	'r7' => 'info+r7@example.com',
	'r8' => 'info+r8@example.com, info+r99@example.com',
	'r9' => 'info+r9@example.com',
	'r10' => 'info+r10@example.com',
	'r11' => 'info+r11@example.com',
	'r12' => 'info+r12@example.com',
	'r13' => 'info+r13@example.com'
);
$form->data['email_to_use'] = $emails[$recipient];
?>

You should see the correct address in the Debug htough and you are reporting empty entries here:
An email has been SENT successfully from (SHB Hire Ltd)info@shb.co.uk to info+r8@example.com

Bob
Nuvelle 01 Nov, 2012

Hmm, I missed it earlier, r2 has two email addresses in the emails array. I don't think that will work unless you use my custom Email [GH] action.



I am having the same issue but sending to multiple emails is critical (3 different options sending to 2, 3 and 6 emails)

Where can I find said "custom Email [GH] action" ?

I have tried to go to your website but get the error "Database Error: Unable to connect to the database:Could not connect to MySQL"

Please advise🙂
GreyHead 01 Nov, 2012
Hu nuvelle,

You can get it here - the site is up right now.

Bob
Nuvelle 01 Nov, 2012
Perfect, thank you!!
Nuvelle 01 Nov, 2012
A beer is on its way to you! Chronoforms would have been a lost cause for me without your fix!
This topic is locked and no more replies can be posted.