Forums

How to set contact form to choose recipient?

Cikiriki 16 Nov, 2017
Hello,

I'm trying to set up contact form where you choose one of the recipients and I want that only chosen recipient gets email. My problem is that I used options that I found on these forums however even when one of recipients is chosen every recipients gets email in the end.

I have CF5 installed on my joomla 2.5 site and I'm using demo-basic-contact-captcha form where I added radio buttons with recipients to choose, in these buttons I have set values in 'option' section :

em1=email@email.com
em2=email2@email.com
em3=email3@email.com
em4=email4@email.com

Then I have placed costume code in 'setup' tab with next code:

<?php
// set a default recipient
$recipient = 'em1';
if ( isset($form->data['recipients']) && $form->data['recipients'] ) {
$recipient = $form->data['recipients'];
}
$emails = array (
'em1' => 'email@email.com',
'em2' => 'email2@email.com',
'em3' => 'email3@email.com',
'em4' => 'email4@email.com');
$form->data['email_to_use'] = $emails[$recipient];
?>

Then I put Email event with email_to_use action lable.
In it, on 'To' section I placed emails separated with comma.

What did I do wrong? I want that only chosen recipient gets email and not all of them after sending a a message.

Thanks!

Cikiriki
GreyHead 17 Nov, 2017
Hi Cikiriki,

Please check the FAQ - you need to add email_to_use in the Dynamic To box of the Email action.

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