email all users in database help

I have a guestbook which has a field that basically asks "join mailing
list?". Can someone please point me to a code snippet somewhere that can
help me figure out where to start on this? My database (MySQL) already
collects all the user's contact info and the 'yes or no' response for the
mailing list question so I'm hoping this is not incredibly difficult to do.
I have a contact form on my site so maybe I can copy/paste that code for the
actual mass mailing function?

thanks!
trashed [ Mo, 12 Februar 2007 12:08 ] [ ID #1626699 ]

Re: email all users in database help

On Mon, 12 Feb 2007 12:08:45 +0100, trashed <ahhhno [at] .com> wrote:

> I have a guestbook which has a field that basically asks "join mailing=

> list?". Can someone please point me to a code snippet somewhere that c=
an
> help me figure out where to start on this? My database (MySQL) already=

> collects all the user's contact info and the 'yes or no' response for =
the
> mailing list question so I'm hoping this is not incredibly difficult t=
o =

> do.
> I have a contact form on my site so maybe I can copy/paste that code f=
or =

> the
> actual mass mailing function?
>
> thanks!

$result =3D mysql_query('SELECT `mail` FROM `table` WHERE `mailinglist` =
=3D =

\'yes\'') or die(mysql_error());
while($row =3D mysql_fetch_assoc($result){
mail($row['mail'],'This is the title','And here is the text body');
}

Or possibly:

$mails =3D array();
while($row =3D mysql_fetch_assoc($result) $mails[] =3D $row['mail'];
mail('you_own_emailadress [at] example.com','Title','Text','Bcc: =

'.implode(',',$mails));
-- =

Rik Wasmus
Rik [ Mo, 12 Februar 2007 12:19 ] [ ID #1626700 ]

Re: email all users in database help

Thanks, that's all there is to it? I thought there would be gobs of code
involved! But I kind of understand what you have.

Is it possible you can post more of that code so I can see how I can
integrate my mail script with it? Would you mind??
I'm not sure how you can but I'm unclear where/how to put it all together.

thanks again for your help


"Rik" <luiheidsgoeroe [at] hotmail.com> wrote in message
news:op.tnmu1ya0qnv3q9 [at] misant...
On Mon, 12 Feb 2007 12:08:45 +0100, trashed <ahhhno [at] .com> wrote:

> I have a guestbook which has a field that basically asks "join mailing
> list?". Can someone please point me to a code snippet somewhere that can
> help me figure out where to start on this? My database (MySQL) already
> collects all the user's contact info and the 'yes or no' response for the
> mailing list question so I'm hoping this is not incredibly difficult to
> do.
> I have a contact form on my site so maybe I can copy/paste that code for
> the
> actual mass mailing function?
>
> thanks!

$result = mysql_query('SELECT `mail` FROM `table` WHERE `mailinglist` =
\'yes\'') or die(mysql_error());
while($row = mysql_fetch_assoc($result){
mail($row['mail'],'This is the title','And here is the text body');
}

Or possibly:

$mails = array();
while($row = mysql_fetch_assoc($result) $mails[] = $row['mail'];
mail('you_own_emailadress [at] example.com','Title','Text','Bcc:
'.implode(',',$mails));
--
Rik Wasmus
trashed [ Mo, 12 Februar 2007 12:29 ] [ ID #1626701 ]

Re: email all users in database help

Also Rik , you provided 2 examples. What is the difference? Why would there
be two possibilities?

thanks



"Rik" <luiheidsgoeroe [at] hotmail.com> wrote in message
news:op.tnmu1ya0qnv3q9 [at] misant...
On Mon, 12 Feb 2007 12:08:45 +0100, trashed <ahhhno [at] .com> wrote:

> I have a guestbook which has a field that basically asks "join mailing
> list?". Can someone please point me to a code snippet somewhere that can
> help me figure out where to start on this? My database (MySQL) already
> collects all the user's contact info and the 'yes or no' response for the
> mailing list question so I'm hoping this is not incredibly difficult to
> do.
> I have a contact form on my site so maybe I can copy/paste that code for
> the
> actual mass mailing function?
>
> thanks!

$result = mysql_query('SELECT `mail` FROM `table` WHERE `mailinglist` =
\'yes\'') or die(mysql_error());
while($row = mysql_fetch_assoc($result){
mail($row['mail'],'This is the title','And here is the text body');
}

Or possibly:

$mails = array();
while($row = mysql_fetch_assoc($result) $mails[] = $row['mail'];
mail('you_own_emailadress [at] example.com','Title','Text','Bcc:
'.implode(',',$mails));
--
Rik Wasmus
trashed [ Mo, 12 Februar 2007 12:38 ] [ ID #1626702 ]

Re: email all users in database help

trashed wrote:

Please don't toppost.

> "Rik" <luiheidsgoeroe [at] hotmail.com> wrote in message
> news:op.tnmu1ya0qnv3q9 [at] misant...
> On Mon, 12 Feb 2007 12:08:45 +0100, trashed <ahhhno [at] .com> wrote:
>
>> I have a guestbook which has a field that basically asks "join mailing
>> list?". Can someone please point me to a code snippet somewhere that can
>> help me figure out where to start on this? My database (MySQL) already
>> collects all the user's contact info and the 'yes or no' response for
>> the
>> mailing list question so I'm hoping this is not incredibly difficult to
>> do.
>> I have a contact form on my site so maybe I can copy/paste that code for
>> the
>> actual mass mailing function?

This is really all there is to it (aside from maybe setting some headers
for the reply-to adress etc.). How it would be integrated on your site is
totally dependant on the code of your site, I cannot see that from here.

> Also Rik , you provided 2 examples. What is the difference? Why would
> there
> be two possibilities?

The 2 possibilities I gave were:
- Send a seperate email to everyone in the list.
- Send 1 e-mail, with everyone in the bcc.

The first has the advantage of making 'personalised' emails possible,
using your users name etc., and it will less likely be considerd spam.

The second will ease the load on the server, as there's only 1 mail sent,
but could be considered spam by some filters.

For more examples using the function check the manual (and don't forget
the user contributed notes, often a wealth of information):
<http://nl2.php.net/manual/en/function.mail.php>

For more 'advanced' emails you might consider using the PEAR class:
http://pear.php.net/package/Mail

--
Rik Wasmus
Rik [ Mo, 12 Februar 2007 12:50 ] [ ID #1626703 ]

Re: email all users in database help

"Rik" <luiheidsgoeroe [at] hotmail.com> wrote in message
news:op.tnmwhxdiqnv3q9 [at] misant...
> trashed wrote:
>
> Please don't toppost.
>
>> "Rik" <luiheidsgoeroe [at] hotmail.com> wrote in message
>> news:op.tnmu1ya0qnv3q9 [at] misant...
>> On Mon, 12 Feb 2007 12:08:45 +0100, trashed <ahhhno [at] .com> wrote:
>>
>>> I have a guestbook which has a field that basically asks "join mailing
>>> list?". Can someone please point me to a code snippet somewhere that can
>>> help me figure out where to start on this? My database (MySQL) already
>>> collects all the user's contact info and the 'yes or no' response for
>>> the
>>> mailing list question so I'm hoping this is not incredibly difficult to
>>> do.
>>> I have a contact form on my site so maybe I can copy/paste that code for
>>> the
>>> actual mass mailing function?
>
> This is really all there is to it (aside from maybe setting some headers
> for the reply-to adress etc.). How it would be integrated on your site is
> totally dependant on the code of your site, I cannot see that from here.
>
>> Also Rik , you provided 2 examples. What is the difference? Why would
>> there
>> be two possibilities?
>
> The 2 possibilities I gave were:
> - Send a seperate email to everyone in the list.
> - Send 1 e-mail, with everyone in the bcc.
>
> The first has the advantage of making 'personalised' emails possible,
> using your users name etc., and it will less likely be considerd spam.
>
> The second will ease the load on the server, as there's only 1 mail sent,
> but could be considered spam by some filters.
>
> For more examples using the function check the manual (and don't forget
> the user contributed notes, often a wealth of information):
> <http://nl2.php.net/manual/en/function.mail.php>
>
> For more 'advanced' emails you might consider using the PEAR class:
> http://pear.php.net/package/Mail
>
> --
> Rik Wasmus


Ok, thank you Rik... The info you provided hopefully will be enough for me
to get this off the ground. I appreciate your time.
trashed [ Mo, 12 Februar 2007 12:55 ] [ ID #1626704 ]

Re: email all users in database help

trashed wrote:
> Rik wrote:

Please don't top-post and use a news-client that can quote properly too.

>> $result = mysql_query('SELECT `mail` FROM `table` WHERE `mailinglist` =
>> \'yes\'') or die(mysql_error());
>> while($row = mysql_fetch_assoc($result){
>> mail($row['mail'],'This is the title','And here is the text body');
>> }
>>
>> Or possibly:
>>
>> $mails = array();
>> while($row = mysql_fetch_assoc($result) $mails[] = $row['mail'];
>> mail('you_own_emailadress [at] example.com','Title','Text','Bcc:
>> '.implode(',',$mails));

> Is it possible you can post more of that code so I can see how I can
> integrate my mail script with it? Would you mind??
> I'm not sure how you can but I'm unclear where/how to put it all together.

All you need is to add the connecting to the database code which you should
have already experience of.

> What is the difference? Why would there be two possibilities?

The first one sends a mail to each one of the user, this will be okey for
small lists of users, as your script will time out after a while, you can add
some output each time a mail has been sent (see to disable buffering).

The second one does use send a carbon copy each user, this works for a mid
range list of users, most mail servers have a limit on how many you can have
in a Cc: or Bcc:, but this goes quite fast as you have only one mail sent
(seen from the PHP scripts point of view).

The best is really make a thing in between, that groups users into groups of
~20 and Bcc: to those and then next group and so on.

Keep in mind that your mail can be thought as spam, so create a proper mail
header, don't try to copy what your mail client creates, as this will more
likely heighten the risk for your mail to be caught by spamfilters.

Do read http://www.php.net/manual/en/function.mail.php


--

//Aho
Shion [ Mo, 12 Februar 2007 12:58 ] [ ID #1626705 ]

Re: email all users in database help

"J.O. Aho" <user [at] example.net> wrote in message
news:53b343F1rcfpjU1 [at] mid.individual.net...
| trashed wrote:
| > Rik wrote:
|
| Please don't top-post and use a news-client that can quote properly too.

aho,

isn't top-posting when you intentionally set your date/time to the future
and then post so that your post will be the top post for an extended period
of time?

as for replying and making your response the first text seen, i prefer that.
i also prefer not including the entire message to which i'm replying. a good
new reader keeps the thread in order. i hate having to scroll to see if
someone answered in line or at the bottom of a post...especially the longer
the post.

other than true top-posting, all else is six-one-half-dozen-the-other...it's
all preference.

cheers.
Steve [ Mo, 12 Februar 2007 22:50 ] [ ID #1626715 ]

Re: email all users in database help

Steve wrote:
> "J.O. Aho" wrote
> | trashed wrote:
> | > Rik wrote:
> |
> | Please don't top-post and use a news-client that can quote properly
> too.
>
> isn't top-posting when you intentionally set your date/time to the future
> and then post so that your post will be the top post for an extended
> period
> of time?

That too, that's even more evil if done intentionally :P
<http://en.wikipedia.org/wiki/Toppost>

> as for replying and making your response the first text seen, i prefer
> that.

I do not. This is not email. This is usenet. Messages get lost, or a reply
can appear on a particular newsserver earlier then the original post. I've
had some problems with newsservers in the past, and quoting correctly
really was very welcome.

> i also prefer not including the entire message to which i'm replying. a
> good
> new reader keeps the thread in order.

Quote with care, long enough to get the main subject, short enough to be
easily handled. A good newsreader will not only keep the threads in order
(if they indeed arrived on the server correctly), they'll also indicate
very clearly what's a quote and what isn't

> i hate having to scroll to see if
> someone answered in line or at the bottom of a post...especially the
> longer the post.

Quoting everything is not the solution as some might think, no.

> other than true top-posting, all else is
> six-one-half-dozen-the-other...it's
> all preference.

It's something we've agreed on. Not following this shows a lack of respect
for the readers IMHO.

--
Rik Wasmus
Rik [ Mo, 12 Februar 2007 23:15 ] [ ID #1626716 ]

OT: Topposting (Was: email all users in database help)

Steve wrote:
> "J.O. Aho" <user [at] example.net> wrote in message
> news:53b343F1rcfpjU1 [at] mid.individual.net...
> | trashed wrote:
> | > Rik wrote:
> |
> | Please don't top-post and use a news-client that can quote properly too.
>
> aho,
>
> isn't top-posting when you intentionally set your date/time to the future

No, it's when you type your response above the text you are replying to, see
the link Rik gave.


> as for replying and making your response the first text seen, i prefer that.

You may, but not everyone and it a no if you would follow the netiquette.


> i hate having to scroll to see if
> someone answered in line or at the bottom of a post...especially the longer
> the post.

Yes, it's bad and against netiquette, to keep the whole original post and give
a short answer, you only keep the text you are replying to.
Something that is really annoying is that there are news clients that don't
filter away post footers, it starts to look really bad when a post has 3-4
previous posts footers too.


--

//Aho
Shion [ Di, 13 Februar 2007 08:30 ] [ ID #1628037 ]

Re: Topposting (Was: email all users in database help)

"J.O. Aho" <user [at] example.net> wrote in message
news:53d7o3F1s9c2fU1 [at] mid.individual.net...
| Steve wrote:
| > "J.O. Aho" <user [at] example.net> wrote in message
| > news:53b343F1rcfpjU1 [at] mid.individual.net...
| > | trashed wrote:
| > | > Rik wrote:
| > |
| > | Please don't top-post and use a news-client that can quote properly
too.
| >
| > aho,
| >
| > isn't top-posting when you intentionally set your date/time to the
future
|
| No, it's when you type your response above the text you are replying to,
see
| the link Rik gave.


actually, i was trying to be polite. what i gave *is* the original
definition of top-posting. rik's wiki confirms this with the first line (in
italics). it also shows that it has another meaning which is making your
response text appear at the top of a reply. the former definition is a
cardinal sin while the latter is a matter of preference...usually agreed
upon by those in a ng.

| > as for replying and making your response the first text seen, i prefer
that.
|
| You may, but not everyone and it a no if you would follow the netiquette.

netiquette is set by those in a ng and differs between the many ng's out
there. though posts aren't email, a good news reader (not web based shit
like google groups) will keep a thread in order even when a message has been
removed from a usenet server. if you are active in a group where threads are
naturally deeply nested, top-posting is the order of the day. and at a
minimum, in-line follows in preference.


| > i hate having to scroll to see if
| > someone answered in line or at the bottom of a post...especially the
longer
| > the post.
|
| Yes, it's bad and against netiquette, to keep the whole original post and
give
| a short answer, you only keep the text you are replying to.
| Something that is really annoying is that there are news clients that
don't
| filter away post footers, it starts to look really bad when a post has 3-4
| previous posts footers too.

it is neither bad nor against netiquette. sometimes the whole op is needed
for context to the response...further, if you are in a debate and snip a
portion of the op, you will surely be accused of doing so on purpose because
you cannot debate the point because of its correctness.

'bad' is relative to context...'netiquette' is not a religious dication like
the hummarabi or ten commandments. both are agreed to by a concenting group.
'bad' becomes the violation of said agreement.

either way, i appreciate your perspective.

cheers
Steve [ Di, 13 Februar 2007 16:07 ] [ ID #1628045 ]

Re: Topposting (Was: email all users in database help)

Steve wrote:
> "J.O. Aho" <user [at] example.net> wrote in message
> news:53d7o3F1s9c2fU1 [at] mid.individual.net...
> | Steve wrote:
> | > "J.O. Aho" <user [at] example.net> wrote in message
> | > news:53b343F1rcfpjU1 [at] mid.individual.net...
> | > | trashed wrote:
> | > | > Rik wrote:

> | > i hate having to scroll to see if
> | > someone answered in line or at the bottom of a post...especially the
> | > longer the post.
> |
> | Yes, it's bad and against netiquette, to keep the whole original post and
> | give
> | a short answer, you only keep the text you are replying to.
> | Something that is really annoying is that there are news clients that
> | don't
> | filter away post footers, it starts to look really bad when a post has 3-4
> | previous posts footers too.
>
> it is neither bad nor against netiquette. sometimes the whole op is needed
> for context to the response

It's really uncommon you need the whole the whole contest and specially not
footers of the previous posts.


> ...further, if you are in a debate and snip a
> portion of the op, you will surely be accused of doing so on purpose because
> you cannot debate the point because of its correctness.

In most cases it's just trolling and why discuss with them, as no matter what
you say or write they will try to turn everything against you, no matter if
they top-post, quote small portions of the original post.


--

//Aho
Shion [ Di, 13 Februar 2007 16:51 ] [ ID #1628052 ]
PHP » alt.php » email all users in database help

Vorheriges Thema: New 2 PHP
Nächstes Thema: To Koncept: Followup - How to generate multiple web pages with onePHP script