adding the bcc line...

the mail() function

Moderators: macek, egami, gesf

kazaa13
New php-forum User
New php-forum User
Posts: 2
Joined: Thu Jan 06, 2005 11:00 am

adding the bcc line...

Postby kazaa13 » Thu Jan 06, 2005 11:06 am

hi there.
im a newbie to php. wondering if anyone could me. below is the code for the email php. was wondering where shall i place the bcc line, which is to be sent to a different email add. thanks a million.


<?

$to = "test@yahoo.com";
$subject = "test Mailing List";


$msg .= "Email: " . $HTTP_POST_VARS["email"] . "\n\n";

mail($to, $subject, $msg, "From: me\nReply-To: $email\n");

?>

User avatar
Alexej Kubarev
Site Admin
Site Admin
Posts: 2223
Joined: Fri Mar 05, 2004 7:15 am
Location: Täby, Stockholms län
Contact:

Postby Alexej Kubarev » Thu Jan 06, 2005 11:12 am

Moving this topic to PHP=>Mail

User avatar
Alexej Kubarev
Site Admin
Site Admin
Posts: 2223
Joined: Fri Mar 05, 2004 7:15 am
Location: Täby, Stockholms län
Contact:

Postby Alexej Kubarev » Thu Jan 06, 2005 11:16 am

Anyway...

You should put it to the headers section...the same place where you put From and Reply-to...

However you may even specify several reciepients by simply writing them into as the first argument..

kazaa13
New php-forum User
New php-forum User
Posts: 2
Joined: Thu Jan 06, 2005 11:00 am

Postby kazaa13 » Thu Jan 06, 2005 9:04 pm

tried.. but the email was not sent..

User avatar
Alexej Kubarev
Site Admin
Site Admin
Posts: 2223
Joined: Fri Mar 05, 2004 7:15 am
Location: Täby, Stockholms län
Contact:

Postby Alexej Kubarev » Fri Jan 07, 2005 2:51 am

Tried What?

Multiple to adresses or bcc in headers?

Read the maual, might help to :)

http://se.php.net/manual/en/ref.mail.php
http://se.php.net/manual/en/function.mail.php

User avatar
Alexej Kubarev
Site Admin
Site Admin
Posts: 2223
Joined: Fri Mar 05, 2004 7:15 am
Location: Täby, Stockholms län
Contact:

Postby Alexej Kubarev » Fri Jan 07, 2005 2:54 am

Here is something that woks and will give you what you want (i think):

Code: Select all

<?php
/* recipients */
$to  = "mary@example.com" . ", " ; // note the comma
$to .= "kelly@example.com";

/* subject */
$subject = "Birthday Reminders for August";

/* message */
$message = '
<html>
<head>
 <title>Birthday Reminders for August</title>
</head>
<body>
<p>Here are the birthdays upcoming in August!</p>
<table>
 <tr>
  <th>Person</th><th>Day</th><th>Month</th><th>Year</th>
 </tr>
 <tr>
  <td>Joe</td><td>3rd</td><td>August</td><td>1970</td>
 </tr>
 <tr>
  <td>Sally</td><td>17th</td><td>August</td><td>1973</td>
 </tr>
</table>
</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: Mary <mary@example.com>, Kelly <kelly@example.com>\r\n";
$headers .= "From: Birthday Reminder <birthday@example.com>\r\n";
$headers .= "Cc: birthdayarchive@example.com\r\n";
$headers .= "Bcc: birthdaycheck@example.com\r\n";

/* and now mail it */
mail($to, $subject, $message, $headers);
?>


However note several things:

Note: Make sure you do not have any newline characters in the to or subject, or the mail may not be sent properly.

Note: The to parameter should not be an address in the form of "Something <someone@example.com>". The mail command may not parse this properly while talking with the MTA (Particularly under Windows).

**This example has been taken from PHP.net and therefore a manual should be consulted before asking questions**


Return to “PHP coding => Mail”

Who is online

Users browsing this forum: No registered users and 1 guest