Page 1 of 1
Multiple Recipients with mail()
Posted: Thu Dec 11, 2003 5:39 am
by AnsonM
Code: Select all
<?php
/* recipients */
$to = "email1@hotmail.com" . ", ", ", ", ", " ; // note the comma
$to .= "email2@hotmail.com";
$to .= "email3@hotmail.com";
$to .= "email4@hotmail.com";
$to .= "email5@hotmail.com";
$to .= "email6@hotmail.com";
/* subject */
$subject = ":: SHUT UP EMAIL ::";
/* message */
$message = '
<html>
<body>
<p>This Email Has Been Sent From 8th-Dimension . Net from people that hate you.</p>
</body>
</html>
';
/* To send HTML mail, you can set the Content-type header. */
$headers = "MIME-Version: 1.0\r\n";
$headers .= "Content-type: text/html; charset=iso-8859-1\r\n";
/* additional headers */
$headers .= "To: email <email@hotmail.com\r\n";
$headers .= "From: Mail() PHP Script <rubbish@8th-dimension.net>\r\n";
/* and now mail it */
mail($to, $subject, $message, $headers);
?>
<font color="FF0000">Thank You! Your Email has been sent 5 times to
emails@hotmail.com</font>
Theres something wrong with:
Code: Select all
<?php
$to = "email1@hotmail.com" . ", ", ", ", ", " ; // note the comma
?>
...
Whats wrong with the commas?[/php_man]
Posted: Thu Dec 11, 2003 5:41 am
by AnsonM
Code: Select all
<?php
$to = "email1@hotmail.com" . ", " . ", " . ", " . ", " . ", " ; // note the comma
?>
EDIT: hmmmm.... still doesnt work.. but it doesnt show any parse error..
i think it does send... but not to all the 6 emails...
Posted: Thu Dec 11, 2003 5:47 am
by twigletmac
The output of:
Code: Select all
$to = "email1@hotmail.com" . ", " . ", " . ", " . ", " . ", " ;
$to .= "email2@hotmail.com";
$to .= "email3@hotmail.com";
$to .= "email4@hotmail.com";
$to .= "email5@hotmail.com";
$to .= "email6@hotmail.com";
echo $to;
is
Code: Select all
email1@hotmail.com, , , , , email2@hotmail.comemail3@hotmail.comemail4@hotmail.comemail5@hotmail.comemail6@hotmail.com
Maybe this is more what you are looking for:
Code: Select all
$to = array();
$to[] = "email1@hotmail.com";
$to[] = "email2@hotmail.com";
$to[] = "email3@hotmail.com";
$to[] = "email4@hotmail.com";
$to[] = "email5@hotmail.com";
$to[] = "email6@hotmail.com";
$to = implode('; ', $to);
echo $to;
Code: Select all
email1@hotmail.com; email2@hotmail.com; email3@hotmail.com; email4@hotmail.com; email5@hotmail.com; email6@hotmail.com
Mac
Posted: Thu Dec 11, 2003 5:56 am
by AnsonM
its just meant to send it to every one of those emails each time the script is executed.. thats all...
its just weird how it doesnt send to all the 6 emails listed there..
Posted: Thu Dec 11, 2003 6:03 am
by AnsonM
Code: Select all
$to = array();
$to[] = "sshh_d0nt_tell@hotmail.com";
$to[] = "sshh_d0nt_tell@hotmail.com";
$to[] = "sshh_d0nt_tell@hotmail.com";
$to[] = "sshh_d0nt_tell@hotmail.com";
$to[] = "sshh_d0nt_tell@hotmail.com";
$to[] = "sshh_d0nt_tell@hotmail.com";
$to = implode('; ', $to);
Doesn't even send 1 email..
Posted: Thu Dec 11, 2003 6:06 am
by Nay
I think it was supposed to be more of:
-Nay
Posted: Thu Dec 11, 2003 6:14 am
by AnsonM
lol, still nothing.. this is odd..
Posted: Thu Dec 11, 2003 6:18 am
by AnsonM
AnsonM wrote:Code: Select all
<?php
$to = "email1@hotmail.com" . ", " ; // note the comma
$to .= "email1@hotmail.com";
?>
Thats the original... It says note the comma..hmmm...
But I need to add more emails to send it to... so i have to add more lines of:
but i dont know what to do with the adding of the commas..

Posted: Thu Dec 11, 2003 6:22 am
by JayBird
can you echo the $o variable to see what it contains
Mark
Posted: Thu Dec 11, 2003 1:58 pm
by AnsonM
Code: Select all
<?php
email1@hotmail.com;email2@hotmail.com;email3@hotmail.com;email4@hotmail.com;email5@hotmail.com;email6@hotmail.com
?>
it doesnt send...
how does PHP want the format of the emails to be like??
Posted: Thu Dec 11, 2003 2:03 pm
by AnsonM
Code: Select all
<?php
/* recipients */
$to = array();
$to[] = "sshh_d0nt_tell@hotmail.com";
$to[] = "sshh_d0nt_tell@hotmail.com";
$to[] = "sshh_d0nt_tell@hotmail.com";
$to[] = "sshh_d0nt_tell@hotmail.com";
$to[] = "sshh_d0nt_tell@hotmail.com";
$to[] = "sshh_d0nt_tell@hotmail.com";
$to = implode("; ", $to);
/* subject */
$subject = ":: SHUT UP EMAIL ::";
/* message */
$message = '
<html>
<body>
<p>This Email Has Been Sent From 8th-Dimension . Net from people that hate you.</p>
</body>
</html>
';
/* To send HTML mail, you can set the Content-type header. */
$headers = "MIME-Version: 1.0\r\n";
$headers .= "Content-type: text/html; charset=iso-8859-1\r\n";
/* additional headers */
$headers .= "To: Some1 <email@hotmail.com\r\n";
$headers .= "From: Mail() PHP Script <rubbish@8th-dimension.net>\r\n";
/* and now mail it */
mail($to, $subject, $message, $headers);
?>
<font color="FF0000">Thank You! Your Email has been sent 5 times to sshh_d0nt_tell@hotmail.com</font>
Thats the whole thing..
Replace those emails with yours, and test out the script.... it doesnt work...
Posted: Fri Dec 12, 2003 2:32 am
by twigletmac
Did you try it with:
instead of
so that you have a comma instead of a semi-colon, sorry I should have checked the manual before posting:
http://php.net/manual/en/function.mail.php
PHP Manual - mail() wrote:Multiple recipients can be specified by putting a comma between each address in to.
If that still doesn't work, have you tried taking out this line:
Code: Select all
$headers .= "To: Some1 <email@hotmail.com\r\n";
and if it's still not working, you may have to loop the e-mail sending script 5 times to get the desired effect.
Mac
Posted: Fri Dec 12, 2003 6:29 am
by AnsonM
I've tried all that..... and it doesnt ive an error.. but it doesnt work still...
I don't know how to loop it

Posted: Fri Dec 12, 2003 6:53 am
by twigletmac
Can you send a simple email:
Code: Select all
mail('yourname@youremailhost.com', 'testing e-mail sending', 'just testing this works');
Mac