Jump to content

Archived

This topic is now archived and is closed to further replies.

php_virgin

random email in php

Recommended Posts

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 ?

Share this post


Link to post
Share on other sites
yea
[code]
<?php
mail("email1,email2,email3,email4",subject,message,headers) or die("somthing went wrong");
?>
[/code]

Share this post


Link to post
Share on other sites
[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]

Share this post


Link to post
Share on other sites

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];
}
?>

Share this post


Link to post
Share on other sites
[code]$r=mt_rand(1,count($a));

for($i=0; $i<$r; $i++) {[/code]

Share this post


Link to post
Share on other sites
when u do more then one email to send to it has to all be in one qoute

mail("1,2,3,4",subject,message,header);

Share this post


Link to post
Share on other sites
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;
}
}
?>

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.