#1
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2000
    Posts
    26
    Rep Power
    0
    Hello all,

    Iam using the following code for sending email to users that are stored in my database. The code works fine but when it sends the mail out it does not send blind carbon copies of the email addresses. In other words all mail receivers see each others email addresses. I have been through the php manual and searched on devshed forum to find no reference on my question. Does someone have any ideas?

    Regards

    Richard
    <?

    // First make connection to the server

    $con=mysql_connect('localhost','username','password');

    // Make connection to the database

    mysql_select_db('databasename',$con) or die( "Unable to select database");


    $sql = "SELECT email FROM contact";

    $result = mysql_query($sql);
    $to="";

    while ($myrow = mysql_fetch_array($result))
    {
    $to.=($myrow["email"].",");
    }

    mail("$to","$subject","$message","$from");

    echo "$to";

    echo "The results have been sent";
    ?>
  2. #2
  3. No Profile Picture
    Apprentice Deity
    Devshed Loyal (3000 - 3499 posts)

    Join Date
    Jul 1999
    Location
    Niagara Falls (On the wrong side of the gorge)
    Posts
    3,237
    Rep Power
    18
    You aren't setting them as BCC but as To:

    You need to set CC and BCC in the additional headers portion of the mail() function (where you currently have $from).

    You'll want that to look like this:

    $from="From: someone@somewhere.comnnBCC: them@someplace.com, someoneelse@overthere.net";

  4. #3
  5. No Profile Picture
    Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2000
    Location
    England, UK
    Posts
    83
    Rep Power
    14
    I use this code:

    <BLOCKQUOTE><font size="1" face="Verdana,Arial,Helvetica">code:</font><HR><pre>
    $email = "webmaster@mysite.com";

    mysql_connect(localhost, user, pass);
    mysql_select_db(database);
    $query = "SELECT * FROM table";
    $result = mysql_query($query);

    while ($rega = mysql_fetch_array($result)) {
    mail($rega["email"],
    $subject,
    "$message n
    -------------------------
    To unsubscribe from the Mailing List go ton <A HREF="http://www.yoursite/mailinglist/unsubscribe.php3?id="" TARGET=_blank>http://www.yoursite/mailinglist/unsubscribe.php3?id="</A> .$rega["id"],
    "From: $emailnReply-To:$emailnX-mailer:PHP/". phpversion());
    }
    mysql_free_result($result);
    [/code]

    Girish Gupta

    [This message has been edited by girish_gupta (edited October 08, 2000).]

Similar Threads

  1. Uploading Files
    By vivekjain in forum ASP Programming
    Replies: 0
    Last Post: February 16th, 2004, 11:21 PM
  2. database access using thread
    By padmini in forum Visual Basic Programming
    Replies: 3
    Last Post: February 6th, 2004, 12:38 AM
  3. Win32::API Help!!!
    By robbydooo in forum Perl Programming
    Replies: 5
    Last Post: February 2nd, 2004, 02:25 PM
  4. Code Benchmarking Tests
    By infamous41md in forum C Programming
    Replies: 4
    Last Post: December 27th, 2003, 04:15 PM
  5. class boolean
    By dbrag in forum C Programming
    Replies: 7
    Last Post: December 11th, 2003, 02:25 PM

IMN logo majestic logo threadwatch logo seochat tools logo