Forums

How can I safely show a list of e-mail addresses with CFv4?

manes 28 Jun, 2011
Hello,

I am currently building a form using the procedure described in FAQ#31 "How can I safely show a list of e-mail addresses?"

The thing the PHP codes doesn't seem to work with CFv4...

Do someone have an answer for this ?

I would be eternally grateful if someone can help 😀

Manes.
manes 28 Jun, 2011
Hi Bob,

Thank you for your help 😀

I have taken a look at the other thread... Tried the new code, but still have problems : I have posted my question there.

If you have a bit of time can you take look and let me know what you think ?

Thanks.

Manes
GreyHead 28 Jun, 2011
Hi manes,

oops, apologies for the bad link :-(

Please try this:

If the select box options are like those in the FAQ; then this code in a Custom Code action in the On Submit event should work.
<?php
$email_to = $form->data['recipients'];
$emails = array(
  'em1'=>'sample1@email.com', 
  'em2'=>'sample2@email.com', 
  'em3'=>'name_3@example.com'
);
if ( $email_to ) {
  $form->data['email_to'] = $emails[$email_to];
} else {
  $form->data['email_to'] = 'admin@example.com';
}
?>

You'd need to put email_to in the Dynamic To bog in the Email configuration.

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