Buy Now
Sign in

How can i send to a random email out of a list?

smdubs , October 11 2007, 03:49
smdubs 1
October 11 2007, 03:49 #2737
I have a group of people who will be responding to contact information from the form. How can i make it so it sends the email either a random address or have it so each time a form is submitted it goes to a different person.

GreyHead 64
October 11 2007, 15:53 #2739
Hi smdubs,

Try this in the 'Onsubmit - before email' code field
$emails = array('', '', . . .);
$email_count = array_count_values($emails);
if ( $rows[0]->$extraemail ) {
$rows[0]->extraemail .= ", ".$emails[mt_rand(0, $email_count)];
} else {
$rows[0]->extraemail = $emails[mt_rand(0,$email_count)];
Not tested, but the code looks OK. I suggest that you put some dummy emails in the first line (without the . . .) and run it a few times with debug on to see if all is well.

ChronoForms technical support
If you'd like to buy me a coffee or two, thank you very much