I just have a simple question regarding the mail function. We have a need to send a mail to to about 20 people. I know my options do include Cc'ing them but I haven't seen any good samples to be able to use To: or Cc: field with multiple entries.
Can someone point me in a direction on this. What is the proper format?
TIA,
Gary Smith
mail question (php 4.3.2+Apache+Postfix)
Moderator: General Moderators
Code: Select all
$to = "Bob<bob@home.com>, Dan<dan@job.com>, Jane<jane@toohot.org>";
$subject = "test";
$body = "something";
$from = "From: Me <me@home.co.uk>\n";
$cc = "Cc: Dude<dude@beach.com>, Boss<boss@work.net>\n";
$bcc = "Bcc: Ghost<ghost@house.woo>, Spook<spook@house.com>\n";
$headers = $from . $cc . $bcc;
mail($to, $subject, $body, $headers);-
gavinbsocom
- Forum Commoner
- Posts: 71
- Joined: Tue Sep 30, 2003 9:51 pm
what does cc and the bcc do for you? and i tried using that code it isnt turning out to good, what information are you supposed toput for the cc and bcc? heres what i set up so far. from your guys code. just changed the names.
<html>
<body>
<?php
$to = "gavin<gavinbflip@hotmail.com>";
$subject = "test";
$body = "something";
$from = "From: Me <russian@bniclan.com>\n";
$cc = "Cc: Dude<dude@beach.com>, Boss<boss@work.net>\n";
$bcc = "Bcc: Ghost<ghost@house.woo>, Spook<spook@house.com>\n";
$headers = $from . $cc . $bcc;
mail($to, $subject, $body, $headers);
?>
</body>
</html>
<html>
<body>
<?php
$to = "gavin<gavinbflip@hotmail.com>";
$subject = "test";
$body = "something";
$from = "From: Me <russian@bniclan.com>\n";
$cc = "Cc: Dude<dude@beach.com>, Boss<boss@work.net>\n";
$bcc = "Bcc: Ghost<ghost@house.woo>, Spook<spook@house.com>\n";
$headers = $from . $cc . $bcc;
mail($to, $subject, $body, $headers);
?>
</body>
</html>
-
gavinbsocom
- Forum Commoner
- Posts: 71
- Joined: Tue Sep 30, 2003 9:51 pm
\r\n is carriage return and newline and is required to separate headers (though _some_ unix MTA's will work with just \n).
You can't use /r/n
=> is used in arrays to associate keys with values, like:
$foo = array('age' => 32, 'name' => 'Bill');
Then you can do echo $foo['name'] and it will return 'Bill'
You can't use /r/n
=> is used in arrays to associate keys with values, like:
$foo = array('age' => 32, 'name' => 'Bill');
Then you can do echo $foo['name'] and it will return 'Bill'
-
gavinbsocom
- Forum Commoner
- Posts: 71
- Joined: Tue Sep 30, 2003 9:51 pm