php_virgin Posted July 15, 2006 Share Posted July 15, 2006 I would like to be able to send email from a php from randomly to 4 different email addresses. Can this be done? If so, does anyone know how ? Quote Link to comment https://forums.phpfreaks.com/topic/14634-random-email-in-php/ Share on other sites More sharing options...
BillyBoB Posted July 15, 2006 Share Posted July 15, 2006 yea [code]<?phpmail("email1,email2,email3,email4",subject,message,headers) or die("somthing went wrong");?>[/code] Quote Link to comment https://forums.phpfreaks.com/topic/14634-random-email-in-php/#findComment-58230 Share on other sites More sharing options...
BillyBoB Posted July 15, 2006 Share Posted July 15, 2006 i think that is how u do it :) i will look it up if not :) Quote Link to comment https://forums.phpfreaks.com/topic/14634-random-email-in-php/#findComment-58231 Share on other sites More sharing options...
redarrow Posted July 15, 2006 Share Posted July 15, 2006 billybob finish the whole code then. Quote Link to comment https://forums.phpfreaks.com/topic/14634-random-email-in-php/#findComment-58240 Share on other sites More sharing options...
AndyB Posted July 15, 2006 Share Posted July 15, 2006 [code]<?php$receivers = array("addy1@domain.com","addy2@domain.com","addy3@some_domain.com","addy4@another_domain.com"); // as many as you want$to = $receivers[rand(0,count($receivers)-1)]; // a random address... more of your code// mail($to, $subject, $message, $headers);?>[/code] Quote Link to comment https://forums.phpfreaks.com/topic/14634-random-email-in-php/#findComment-58263 Share on other sites More sharing options...
redarrow Posted July 15, 2006 Share Posted July 15, 2006 what have i done wrong heres the error please help using mt_rand.Warning: mt_rand() expects parameter 2 to be long, array given in <?$a=array("john@john.com","lucy@lucy.com","kevin@kevin.com","dad@dad.com","mum@mum.com");shuffle($a);$r=mt_rand(1,$a);for($i=0; $i<count($r); $i++) {echo $r[$i];} ?> Quote Link to comment https://forums.phpfreaks.com/topic/14634-random-email-in-php/#findComment-58269 Share on other sites More sharing options...
AndyB Posted July 15, 2006 Share Posted July 15, 2006 [code]$r=mt_rand(1,count($a));for($i=0; $i<$r; $i++) {[/code] Quote Link to comment https://forums.phpfreaks.com/topic/14634-random-email-in-php/#findComment-58273 Share on other sites More sharing options...
BillyBoB Posted July 15, 2006 Share Posted July 15, 2006 when u do more then one email to send to it has to all be in one qoutemail("1,2,3,4",subject,message,header); Quote Link to comment https://forums.phpfreaks.com/topic/14634-random-email-in-php/#findComment-58282 Share on other sites More sharing options...
redarrow Posted July 15, 2006 Share Posted July 15, 2006 Thank you andy i got this together and understand it cheers.<?$a=array("john@john.com","lucy@lucy.com","kevin@kevin.com","dad@dad.com","mum@mum.com","stop");shuffle($a);for($i=5; $i<count($a); $i++) {echo $a[$i];if($a[$i]=="stop"){echo "<br><b>Refresh agin you have seen our five email address ok!</b>";exit;} }?> Quote Link to comment https://forums.phpfreaks.com/topic/14634-random-email-in-php/#findComment-58284 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.