mail question (php 4.3.2+Apache+Postfix)

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
itbegary
Forum Commoner
Posts: 34
Joined: Sun Jan 05, 2003 2:50 am

mail question (php 4.3.2+Apache+Postfix)

Post 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
Gen-ik
DevNet Resident
Posts: 1059
Joined: Mon Aug 12, 2002 7:08 pm
Location: London. UK.

Post 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);
gavinbsocom
Forum Commoner
Posts: 71
Joined: Tue Sep 30, 2003 9:51 pm

Post 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>
User avatar
markl999
DevNet Resident
Posts: 1972
Joined: Thu Oct 16, 2003 5:49 pm
Location: Manchester (UK)

Post by markl999 »

You should really use \r\n instead of \n on the headers.
gavinbsocom
Forum Commoner
Posts: 71
Joined: Tue Sep 30, 2003 9:51 pm

Post by gavinbsocom »

what does \r\n\ mean and can you write it /r/n/ ? also in php what does => mean ? thanks.
User avatar
markl999
DevNet Resident
Posts: 1972
Joined: Thu Oct 16, 2003 5:49 pm
Location: Manchester (UK)

Post 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'
gavinbsocom
Forum Commoner
Posts: 71
Joined: Tue Sep 30, 2003 9:51 pm

Post 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.
User avatar
markl999
DevNet Resident
Posts: 1972
Joined: Thu Oct 16, 2003 5:49 pm
Location: Manchester (UK)

Post 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.
Post Reply