Jump to content


Photo

random email in php


  • Please log in to reply
8 replies to this topic

#1 php_virgin

php_virgin
  • New Members
  • Pip
  • Newbie
  • 1 posts

Posted 15 July 2006 - 01:10 AM

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 ?

#2 BillyBoB

BillyBoB
  • Members
  • PipPipPip
  • Advanced Member
  • 630 posts

Posted 15 July 2006 - 01:13 AM

yea
<?php
mail("email1,email2,email3,email4",subject,message,headers) or die("somthing went wrong");
?>


#3 BillyBoB

BillyBoB
  • Members
  • PipPipPip
  • Advanced Member
  • 630 posts

Posted 15 July 2006 - 01:14 AM

i think that is how u do it :) i will look it up if not :)

#4 redarrow

redarrow
  • Members
  • PipPipPip
  • Advanced Member
  • 7,308 posts
  • Locationlondon

Posted 15 July 2006 - 01:32 AM

billybob finish the whole code then.
Wish i new all about php DAM i will have to learn
((EMAIL CODE THAT WORKS))
http://simpleforum.ath.cx/mail2.inc
((PAYPAL INTEGRATION THAT WORKS))
http://simpleforum.a...aypal1_info.inc

#5 AndyB

AndyB
  • Staff Alumni
  • Advanced Member
  • 5,465 posts
  • LocationToronto

Posted 15 July 2006 - 02:05 AM

<?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);
?>

Legend has it that reading the manual never killed anyone.
My site

#6 redarrow

redarrow
  • Members
  • PipPipPip
  • Advanced Member
  • 7,308 posts
  • Locationlondon

Posted 15 July 2006 - 02:14 AM


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];
}
?>
Wish i new all about php DAM i will have to learn
((EMAIL CODE THAT WORKS))
http://simpleforum.ath.cx/mail2.inc
((PAYPAL INTEGRATION THAT WORKS))
http://simpleforum.a...aypal1_info.inc

#7 AndyB

AndyB
  • Staff Alumni
  • Advanced Member
  • 5,465 posts
  • LocationToronto

Posted 15 July 2006 - 02:24 AM

$r=mt_rand(1,count($a));

for($i=0; $i<$r; $i++) {

Legend has it that reading the manual never killed anyone.
My site

#8 BillyBoB

BillyBoB
  • Members
  • PipPipPip
  • Advanced Member
  • 630 posts

Posted 15 July 2006 - 02:46 AM

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);

#9 redarrow

redarrow
  • Members
  • PipPipPip
  • Advanced Member
  • 7,308 posts
  • Locationlondon

Posted 15 July 2006 - 02:48 AM

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;
}
}
?>
Wish i new all about php DAM i will have to learn
((EMAIL CODE THAT WORKS))
http://simpleforum.ath.cx/mail2.inc
((PAYPAL INTEGRATION THAT WORKS))
http://simpleforum.a...aypal1_info.inc




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users