Page 1 of 1

mail question (php 4.3.2+Apache+Postfix)

Posted: Mon Oct 20, 2003 3:14 pm
by itbegary
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

Posted: Mon Oct 20, 2003 4:54 pm
by Gen-ik

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

Posted: Mon Oct 20, 2003 7:42 pm
by gavinbsocom
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>

Posted: Mon Oct 20, 2003 8:00 pm
by markl999
You should really use \r\n instead of \n on the headers.

Posted: Mon Oct 20, 2003 8:54 pm
by gavinbsocom
what does \r\n\ mean and can you write it /r/n/ ? also in php what does => mean ? thanks.

Posted: Mon Oct 20, 2003 9:29 pm
by markl999
\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'

Posted: Mon Oct 20, 2003 9:54 pm
by gavinbsocom
oh thankyou so much,,,i never understood that, you think i could get your email, and ask you a few things about mysql databases? I have been posting in database section but no reply, thankyou.

Posted: Mon Oct 20, 2003 10:05 pm
by markl999
Might be best just to PM me link to the database post you'd like help with ;)
I'll see if i can help though databases arn't my strong point.