Page 1 of 1

Assign multiple addresses to a BCC in PHP mail

Posted: Wed Sep 23, 2009 5:09 am
by simonmlewis

Code: Select all

$result = mysql_query ("SELECT * FROM stocknotification WHERE title = '$title'"); 
 
        while ($row = mysql_fetch_object($result))
        {
        $to = "info@domain.co.uk";
        $bcc = "        
        $subject =  "New Stock Arrival Notification";
        $headers = "From: info@domain.co.uk";
        $body = "
Dear customer.
 
A Support Email has been assigned to you.
 
Email Reference ID $id.
 
Best regards
COMPANY";
mail ($to, $subject, $body, $headers);   
        }
How can I get this to work?

I have posted something related to this query already, but this is different. I have a number of rows with the same title, but different email addresses. I want to query the db table, and assign the email address into one $bcc, so ONE email can go out, without going thru a loop and sending 200+ emails.

Anyone know a way, coz I have thought "outside the box" but cannot come up with the answer.

Re: Assign multiple addresses to a BCC in PHP mail

Posted: Wed Sep 23, 2009 6:05 am
by simonmlewis

Code: Select all

$result = mysql_query ("SELECT * FROM stocknotification WHERE title = '$title'"); 
 
        while ($row = mysql_fetch_object($result))
        {
        $emails = ($emails += $row->email += ",");
        $url = $row->url;
        $titlename = $row->title;  
        }
        mysql_free_result($result);
        
        $to = "info@domain.co.uk";
        $bcc = "$emails";
I wonder if this is getting close, though I think the += method is for adding in mathematics not putting a load of email addresses together.

I need a way to put all the addresses together so they'll work in a $bcc.