CodeIgniter Forums
Send e-mail from form to random people - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: Send e-mail from form to random people (/showthread.php?tid=54370)



Send e-mail from form to random people - El Forum - 09-05-2012

[eluser]Elias Rufino[/eluser]
Hello again.

Is there a way to send an e-mail from a form, but when I have a list of two or three people, to random this 3 e-mail address and send it to just one of those 3 peoples?

I need to send it to a fix e-mail address too, so, I need to random and I have one more address that can not be random, this person must receive the e-mail, doesn't matter who was random in addiction to it.

I would like to thank you in advance,


Elias


Send e-mail from form to random people - El Forum - 09-06-2012

[eluser]Elias Rufino[/eluser]
Hello guys. I solved it just using PHP, and here is the way I used:

Code:
<?php
// my list of emails
$my_array = array("[email protected]", "[email protected]", "[email protected]");
        for ($i=0; $i<=10; $i++)
        {
            $random = array_rand($my_array);
            $rand_mail = $my_array[$random];
        }

// my fixed mail
$fixed_mail = "[email protected]";

$send_to = $fixed_mail.", ".$rand_mail;


echo $send_to;
?&gt;

Thank you for the attention, hope this can help someone too.



Elias


Send e-mail from form to random people - El Forum - 09-10-2012

[eluser]Elias Rufino[/eluser]
Guys, when I tried this code I posted, it worked great.

But now, I'm using this in the controller, and there are errors there.
Could someone please help me how to put it inside a controller?


Thanks,

Elias