How to learn who reads my blog?
How Can I Generate an Email List from a MySQL Table
Hello Guest
  
  • Login
• Register…
• Start blog
  • Who, Where, When
• What is interesting here?
• Duels
  • Polls
• Avatars
• Interests
  • Cities and Countries
• Random blog
• Users search
  • Search
• Games
• Tests
• QAIX
  • Сообщества
• Talxy Chat
• Horoscope
• Online
 
Register!

QAIX > PHP web-programming > How Can I Generate an Email List from a MySQL Table 19 August 2002 06:05:54

  Top users: 
  Recent blog posts: 
  Forums:   
  Discuss: 
  Recent forum topics: 
  Recent forum comments:
  Модератор:

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.

Thanks for your help,

Roger Lewis


--
PHP General Mailing List (http://www.php.net­/)
To unsubscribe, visit: http://www.php.net/­unsub.php


Add comment
Chris Knipe 18 August 2002 06:36:34 permanent link ]
 $to = '';
while ($blah = mysql_fetch_row($re­f)) {
$to =+ $blah['address'];
};

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 your help,>
Roger Lewis>
--> PHP General Mailing List (http://www.php.net­/)> To unsubscribe, visit: http://www.php.net/­unsub.php>


--
PHP General Mailing List (http://www.php.net­/)
To unsubscribe, visit: http://www.php.net/­unsub.php


Add comment
Roger Lewis 18 August 2002 07:20:08 permanent link ]
 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

$to = '';
while ($blah = mysql_fetch_row($re­f)) {
$to =+ $blah['address'];
};

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 your help,>
Roger Lewis>
--> PHP General Mailing List (http://www.php.net­/)> To unsubscribe, visit: http://www.php.net/­unsub.php>


--
PHP General Mailing List (http://www.php.net­/)
To unsubscribe, visit: http://www.php.net/­unsub.php


Add comment
Justin French 18 August 2002 07:29:38 permanent link ]
 on 18/08/02 2:20 PM, Roger Lewis (re.lewis@attbi.com­) wrote:
Thanks for the quick responses from Chris, Daren, and Kevin. I didn't know> so many would be up Sat night.

It's not Saturday night everywhere :)­

Justin French


--
PHP General Mailing List (http://www.php.net­/)
To unsubscribe, visit: http://www.php.net/­unsub.php


Add comment
Manuel Lemos 18 August 2002 07:53:49 permanent link ]
 Hello,

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.


--

Regards,
Manuel Lemos


--
PHP General Mailing List (http://www.php.net­/)
To unsubscribe, visit: http://www.php.net/­unsub.php


Add comment
Roger Lewis 19 August 2002 06:05:54 permanent link ]
 On Sat, 17 Aug 2002 20:10:02 -0700
"Roger Lewis" <re.lewis@attbi.com­> wrote:
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.


Daren Cotter [mailto:daren_cotter@yahoo.com] responded
Saturday, August 17, 2002 8:42 PM
// Query database> $result = mysql_query("SELECT­ email_address FROM users> WHERE is_subscribed = 'Y'", $link);> while ($row = mysql_fetch_array($­result)) {> mail($row["email_address"], $SUBJECT, $BODY,> $HEADER);> }> mysql_free_result($­result);

Darren,
Thanks a lot. This works fine. Please have a virtual beer on me! :)­

To Chris Knipe [mailto:savage@savage.za.org] who responded
$to = '';> while ($blah = mysql_fetch_row($re­f)) {> $to =+ $blah['address'];> };


I tried this, but I got an index error. It doesn't understand 'address'
and I couldn't figure out what was going on.

To Kevin Waterson who responded> simply create your array and use implode.> There is an example of comma seperated lists in the manual> http://www.php.net/­manual/en/function.i­mplode.php

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));

Thanks again everyone for your help

Roger Lewis

PHP General Mailing List (http://www.php.net­/)> To unsubscribe, visit: http://www.php.net/­unsub.php>


___________________­____________________­___________
Do You Yahoo!?
HotJobs - Search Thousands of New Jobs
http://www.hotjobs.­com


--
PHP General Mailing List (http://www.php.net­/)
To unsubscribe, visit: http://www.php.net/­unsub.php


Add comment
 

Add new comment

As:
Login:  Password:  
 
 
  
 
Пожалуйста, относитесь к собеседникам уважительно, не используйте нецензурные слова, не злоупотребляйте заглавными буквами, не публикуйте рекламу и объявления о купле/продаже, а также материалы нарушающие сетевой этикет или законы РФ. Ваш ip-адрес записывается.


QAIX > PHP web-programming > How Can I Generate an Email List from a MySQL Table 19 August 2002 06:05:54

see also:
Student Record System in Access
finalizing ideas
Problem with Sub-Form and SQL-Server…
pass tests:
Do you really know yourself?
see also:
How to convert DVD to…
How to Put DVD/Video on iPod, PSP…

  Copyright © 2001—2010 QAIX
Идея: Монашёв Михаил.
Авторами текстов, изображений и видео, размещённых на этой странице, являются пользователи сайта.
See Help and FAQ in the community support.qaix.com.
Write in the community about the bugs you have noticedbugs.qaix.com.
Write your offers and comments in the communities suggest.qaix.com.
Information for parents.
Пишите нам на .
If you would like to report an abuse of our service, such as a spam message, please .
Если Вы хотите пожаловаться на содержимое этой страницы, пожалуйста .