How Can I Generate an Email List from a MySQL Table
Roger Lewis 18 August 2002 06:10:02
I have a MySQL table named "users" in which there is a column named "email_address" and another named "is_subscribed". I would like to send an email to all of the addresses for which "is_subscribed" is true. I think I know how to send the email, i.e.,
mail($to, $subject, $message, $headers);
I tested this out and it works fine when, for instance, $to = "recipient1@abc.com, recipient2@xyz.com" or some such collection of addresses.
My problem is how do you create the variable, $to, from the MySQL table so that it contains all of the addresses separated by commas.
Be careful however. Most SMTP servers has a limit on the number of recipients you can send one email to. It's a very easy way to trigger spam alerts and stuff.
-- me
----- Original Message ----- From: "Roger Lewis" <re.lewis@attbi.com> To: "Php-General" <php-general@lists.php.net> Sent: Sunday, August 18, 2002 5:10 AM Subject: [PHP] How Can I Generate an Email List from a MySQL Table
I have a MySQL table named "users" in which there is a column named> "email_address" and another named "is_subscribed". I would like to send
email to all of the addresses for which "is_subscribed" is true. I think
know how to send the email, i.e.,>
mail($to, $subject, $message, $headers);>
I tested this out and it works fine when, for instance, $to => "recipient1@abc.com, recipient2@xyz.com" or some such collection of> addresses.>
My problem is how do you create the variable, $to, from the MySQL table so> that it contains all of the addresses separated by commas.>
Thanks for the quick responses from Chris, Daren, and Kevin. I didn't know so many would be up Sat night. This looks like it might do the trick since I only have 20 to 30 recipients and I have a dedicated server. I'll check it out and let you know. Thanks again, Roger
-----Original Message----- From: Chris Knipe [mailto:savage@savage.za.org] Sent: Saturday, August 17, 2002 8:37 PM To: Roger Lewis; Php-General Subject: Re: [PHP] How Can I Generate an Email List from a MySQL Table
Be careful however. Most SMTP servers has a limit on the number of recipients you can send one email to. It's a very easy way to trigger spam alerts and stuff.
-- me
----- Original Message ----- From: "Roger Lewis" <re.lewis@attbi.com> To: "Php-General" <php-general@lists.php.net> Sent: Sunday, August 18, 2002 5:10 AM Subject: [PHP] How Can I Generate an Email List from a MySQL Table
I have a MySQL table named "users" in which there is a column named> "email_address" and another named "is_subscribed". I would like to send
email to all of the addresses for which "is_subscribed" is true. I think
know how to send the email, i.e.,>
mail($to, $subject, $message, $headers);>
I tested this out and it works fine when, for instance, $to => "recipient1@abc.com, recipient2@xyz.com" or some such collection of> addresses.>
My problem is how do you create the variable, $to, from the MySQL table so> that it contains all of the addresses separated by commas.>
On 08/18/2002 12:10 AM, Roger Lewis wrote:> I have a MySQL table named "users" in which there is a column named> "email_address" and another named "is_subscribed". I would like to send an> email to all of the addresses for which "is_subscribed" is true. I think I> know how to send the email, i.e.,>
mail($to, $subject, $message, $headers);>
I tested this out and it works fine when, for instance, $to => "recipient1@abc.com, recipient2@xyz.com" or some such collection of> addresses.>
My problem is how do you create the variable, $to, from the MySQL table so> that it contains all of the addresses separated by commas.
Your best solution is to put all recipients in separate Bcc: headers (one per line) and send just one message.
I like this method because it seems more elegant than above, but I don't seem to be able to create the array properly. I tried the following as well as many other combinations, but couldn't get anything to work: $sql = "SELECT email_address FROM users WHERE is_subscribed = 1"; $result = mysql_query($sql); $to = implode(",", mysql_fetch_array($result));
If you would like to report an abuse of our service, such as a spam message, please . Если Вы хотите пожаловаться на содержимое этой страницы, пожалуйста .