Re: [PHP] bulk mail

2002-08-27 Thread Justin French

on 28/08/02 9:17 AM, Pupeno ([EMAIL PROTECTED]) wrote:


 I know a lot has been discussed in this topic, but I still don't find any
 solution.
 What I want to do is send a lot of mails triggered from a web page using
 php.
 I've found diferent solutions but all of them has some problem:
 1) using set_time_limit() to allow the script to run longer while sending
 e-mails, my prefered solution but I won't let someone waiting a lot of time
 with a loading browser because they'll stop, reload, and at best, just not
 like it. So, I would like to launch a background process changing the
 set_time_limit() in that process (if needed), the problem is that I wasn't
 able to run a background process in PHP, were you ? I know I could use at
 (atd) to run a background process but in my shared server, there's no at
 available.

If you trigger it from a web page, eventually, no matter what you do, you
will hit the wall, because browsers may time out -- not just the PHP script.
The ONLY option is to Bcc: everyone in your email, rather than send
personalise emails.  This way you only send ONE email, not 1000's.

I've spent AGES researching this, and am convinced that Bcc is the only way
to get the performance you want.

There are many hacks work-arounds like:

- have the webpage only do batches of 50 emails, and refresh with META
refresh every 1 minute... come back in a few hours, and they'll all be sent.


The other option to consider is to write a PHP script which runs FROM the
command line.  Then possibly your webpage can trigger the command line
script, AND refresh to a thanks page, leaving the other command line
script still running.

Of course you need PHP as a command line executable for this.


I really suggest speaking to your host.  It's quite possible THEY have the
solution you want.  It's also quite possible that they HATE bulk mailing via
their web page servers, and will actually impose restrictions.

They may also have a dedicated mailing server (as my ISP does) which can
handle this sorta stuff.


 2) Queuing instead of sending. I've seen that some people improved the
 'sending' (well, it's not sending anymore) by queuin only. Then some people
 tell me that sendmails always queue and I'm a bit confused. Does sendmail
 queue or sends mails ? if it queue, why is it send imediatly if the queue
 is procesed once an hour or so ? I don't care if my mails are procesed once
 an hour for this mails, I don't need them to be sent imediatly. I can't
 change sendmail configuration (since it's a shared server) and I wouldn't
 want to because I have other 'mail cases' when I want to send the mails
 imediatly. I can't change the way PHP calls sendmail (again, it's a shared
 server) but I'm using PHPMailer and I can change the way PHPMailer uses
 sendmail, will `/usr/sbin/sendmail -O DeliveryMode=q` queue the mails I'm
 sending ?

The issue of queing is only there IF you wish to send personalised emails.
Queing is NOT an issue for sending an email with a Bcc of 50,000 people.


 3) Someone told me to do it using cron, do you have any idea of how to do it
 with cron ?

Cron is a way of executing a process at a certain time (eg 3am daily).  If
you were able to write a command-line PHP script to send you email (queries
a DB or text file to get the message body, then grabs the address', then
send the email(s)), you could set it to run at a time which the server is
less busy (eg 4am).

You could also use it to partially-send to the list in batches of 100
people, at 5 minute intervals or something.


The real answer to your question is:

If you are doing this on a shared host, use Bcc and keep it simple... your
host will probably see the huge system burden you are placing, and impose
restrictions on you.

If you want a dedicated mailing list with personalised emails, you should
look at a dedicated mailing list system on your host, or another host, which
tackles the issue properly.  There's sparklist.com, ezmlm, etc etc.


Your host may be interesting in setting up a program to do this...

Justin


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




RE: [PHP] bulk mail()

2002-06-14 Thread Jeff Field

I've been doing the following sending personalized mail to 600+ recipients,
so far without any signs of discomfort anywhere:

set_time_limit($total_rows * 1);  // up the script timeout 1 second per
email

BTW, I use qmail; not sendmail.  As I've never used sendmail, I don't know
if this is part of your problem or not.  I'm guessing a bit, but based on
600+ emails, I'd say that the script itself takes about 10-15 seconds; the
mail to be delivered takes a bit longer, perhaps another minute or two.

Jeff

 -Original Message-
 From: Justin French [mailto:[EMAIL PROTECTED]]
 Sent: Wednesday, June 12, 2002 6:45 AM
 To: php
 Subject: [PHP] bulk mail()


 Hi all,

 I've got a mailing on a website, with email address' / names / etc in a
 MySQL table.

 I think there's around 120 on it at the moment.

 I've been noticing a growing lag on the sending of mail though...
 I've got a
 script which takes a message from a form, then runs a while loop
 through the
 rows of the mailing_list table, replacing a special string with the
 subscribers name, and sending using the mail() command.

 However, this time, the script actually failed, with a failure when
 attempting to access blah.com/foo.php (the sending script).  I
 have no idea
 if SOME people got the email, or what, and have no idea how to check.

 So, I make the assumption that as the mailing list has grown, the script
 time has slowed... now it's too big (or the server was too busy)
 to process
 all the emails before the script timed out.


 If I didn't want to personalise the emails, I'm sure the script
 would run a
 lot quicker with every address in the Bcc header, but since we personalise
 each email, I can't see any option other than using mail() 200
 times...  and
 it's only going to get a lot worse as we climb to 1000+.

 So, what options do I have?

 Break the mailing list up into batches of 40 or so?  How would I implement
 something like this?


 Any advice / concepts / ideas welcome!


 Justin French
 
 Creative Director
 http://Indent.com.au
 


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




RE: [PHP] bulk mail()

2002-06-14 Thread Pawel


  -Original Message-
  From: Justin French [mailto:[EMAIL PROTECTED]]
  Sent: Wednesday, June 12, 2002 6:45 AM
  To: php
  Subject: [PHP] bulk mail()
 
 
  Hi all,
 
  I've got a mailing on a website, with email address' / names / etc in a
  MySQL table.
 
  I think there's around 120 on it at the moment.
 
  I've been noticing a growing lag on the sending of mail though...
  I've got a
  script which takes a message from a form, then runs a while loop
  through the
  rows of the mailing_list table, replacing a special string with the
  subscribers name, and sending using the mail() command.
 

You're using something like mysql_fetch_array and not querying the db 120 
times I hope.

  However, this time, the script actually failed, with a failure when
  attempting to access blah.com/foo.php (the sending script).  I
  have no idea
  if SOME people got the email, or what, and have no idea how to check.

go through the your MTA's logs (long and painful process)


  So, I make the assumption that as the mailing list has grown, the script
  time has slowed... now it's too big (or the server was too busy)
  to process
  all the emails before the script timed out.

The time your MTA takes to process the emails has nothing to do with this.
120 calls to mail() should not time out, maybe you have a complicated 
regexp for fixing that name in the emails
what's the body of your while() loop ?


 
  If I didn't want to personalise the emails, I'm sure the script
  would run a
  lot quicker with every address in the Bcc header, but since we personalise
  each email, I can't see any option other than using mail() 200
  times...  and
  it's only going to get a lot worse as we climb to 1000+.
 

putting 120 email addresses in one bcc will surely get your email 
classified as spam

  So, what options do I have?
 
  Break the mailing list up into batches of 40 or so?  How would I implement
  something like this?
 

you could try adding a column in your db that will reflect the last time 
you've sent an email to that person. Then you could just append LIMIT 40 
to your select query, but updating the column requires a separate query (1 
update per email if you want to know exactly how got the email and who didn't)

Pawel


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




Re: [PHP] bulk mail()

2002-06-14 Thread Justin French

on 15/06/02 5:32 AM, Pawel ([EMAIL PROTECTED]) wrote:

 You're using something like mysql_fetch_array and not querying the db 120
 times I hope.

of course! :)


 The time your MTA takes to process the emails has nothing to do with this.
 120 calls to mail() should not time out, maybe you have a complicated
 regexp for fixing that name in the emails
 what's the body of your while() loop ?

nothing too complex at all:

while($myrow = mysql_fetch_array($result))
{
$to = $myrow[email];
$name = $myrow[name];

$this_message = eregi_replace('#name#',$name,$message);
$this_message = stripslashes($this_message);
$this_message .= $email_footer;
   
$headers = From: mailinglist@{$domain_name};

mail($to, $subject, $this_message.$email_footer, $headers);
}


 putting 120 email addresses in one bcc will surely get your email
 classified as spam

good point


 you could try adding a column in your db that will reflect the last time
 you've sent an email to that person. Then you could just append LIMIT 40
 to your select query, but updating the column requires a separate query (1
 update per email if you want to know exactly how got the email and who didn't)

I think i'll write a simple log file for each send-out

Based on everyone's advice, I'm going to break the sending process into
batches of 10 or 20 rows using a redirect, encorporate a log (so that I can
remove bad address' that may slow it down), and then see where to go from
there.


Thanks for everyone's help.


Justin French


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




RE: [PHP] bulk mail()

2002-06-12 Thread Niklas Lampén

One solution could be this:

You only need on page for this:

1) create an array of recipients

2) get value from array like array[$pos];

3) send mail to this receiver

4) now some javascript, unless ofcourse if $pos is bigger than
count($array): location.href = http://blah.com/foo.php?pos=?=$pos+1?


And keep some log on sending. Even simple text file will do, if you are
sending mails in some known order. Log file is very handy if cpu
crashes, or something else happens.


Niklas


-Original Message-
From: Justin French [mailto:[EMAIL PROTECTED]] 
Sent: 12. kesäkuuta 2002 14:45
To: php
Subject: [PHP] bulk mail()


Hi all,

I've got a mailing on a website, with email address' / names / etc in a
MySQL table.

I think there's around 120 on it at the moment.

I've been noticing a growing lag on the sending of mail though... I've
got a script which takes a message from a form, then runs a while loop
through the rows of the mailing_list table, replacing a special string
with the subscribers name, and sending using the mail() command.

However, this time, the script actually failed, with a failure when
attempting to access blah.com/foo.php (the sending script).  I have no
idea if SOME people got the email, or what, and have no idea how to
check.

So, I make the assumption that as the mailing list has grown, the script
time has slowed... now it's too big (or the server was too busy) to
process all the emails before the script timed out.


If I didn't want to personalise the emails, I'm sure the script would
run a lot quicker with every address in the Bcc header, but since we
personalise each email, I can't see any option other than using mail()
200 times...  and it's only going to get a lot worse as we climb to
1000+.

So, what options do I have?

Break the mailing list up into batches of 40 or so?  How would I
implement something like this?


Any advice / concepts / ideas welcome!


Justin French

Creative Director
http://Indent.com.au



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

###
This message has been scanned by F-Secure Anti-Virus for Internet Mail.
For more information, connect to http://www.F-Secure.com/

###
This message has been scanned by F-Secure Anti-Virus for Internet Mail.
For more information, connect to http://www.F-Secure.com/

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




Re: [PHP] bulk mail()

2002-06-12 Thread 1LT John W. Holmes

Do it just like you would with prev/next links. Use LIMIT in your query to
get out 50 or so at a time. Loop through them, sending mail, then use header
to automatically redirect to the next page, incrementing the number to use
in LIMIT.

---John Holmes...

- Original Message -
From: Justin French [EMAIL PROTECTED]
To: php [EMAIL PROTECTED]
Sent: Wednesday, June 12, 2002 7:44 AM
Subject: [PHP] bulk mail()


 Hi all,

 I've got a mailing on a website, with email address' / names / etc in a
 MySQL table.

 I think there's around 120 on it at the moment.

 I've been noticing a growing lag on the sending of mail though... I've got
a
 script which takes a message from a form, then runs a while loop through
the
 rows of the mailing_list table, replacing a special string with the
 subscribers name, and sending using the mail() command.

 However, this time, the script actually failed, with a failure when
 attempting to access blah.com/foo.php (the sending script).  I have no
idea
 if SOME people got the email, or what, and have no idea how to check.

 So, I make the assumption that as the mailing list has grown, the script
 time has slowed... now it's too big (or the server was too busy) to
process
 all the emails before the script timed out.


 If I didn't want to personalise the emails, I'm sure the script would run
a
 lot quicker with every address in the Bcc header, but since we personalise
 each email, I can't see any option other than using mail() 200 times...
and
 it's only going to get a lot worse as we climb to 1000+.

 So, what options do I have?

 Break the mailing list up into batches of 40 or so?  How would I implement
 something like this?


 Any advice / concepts / ideas welcome!


 Justin French
 
 Creative Director
 http://Indent.com.au
 


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




Re: [PHP] bulk mail()

2002-06-12 Thread Paul Roberts

I find a few bad addresses can slow mail() down, i write to a log file if mail returns 
true or to a bad mail file if false, try the bad emails later and then take them off 
the list if still bad. you can increase your time out with set_time_limit(), i'd also 
send when the server isn't too busy.

bcc is faster but will usually end up getting binned as Spam as they are not addressed 
to the recipient and fail junk mail filters as used by hotmail.

if 1 of your 100 emails is bad the whole lot can be rejected by the server and not 
sent.

Paul Roberts
[EMAIL PROTECTED]

- Original Message - 
From: Niklas Lampén [EMAIL PROTECTED]
To: Php-General [EMAIL PROTECTED]
Sent: Wednesday, June 12, 2002 1:08 PM
Subject: RE: [PHP] bulk mail()


One solution could be this:

You only need on page for this:

1) create an array of recipients

2) get value from array like array[$pos];

3) send mail to this receiver

4) now some javascript, unless ofcourse if $pos is bigger than
count($array): location.href = http://blah.com/foo.php?pos=?=$pos+1?


And keep some log on sending. Even simple text file will do, if you are
sending mails in some known order. Log file is very handy if cpu
crashes, or something else happens.


Niklas


-Original Message-
From: Justin French [mailto:[EMAIL PROTECTED]] 
Sent: 12. kesäkuuta 2002 14:45
To: php
Subject: [PHP] bulk mail()


Hi all,

I've got a mailing on a website, with email address' / names / etc in a
MySQL table.

I think there's around 120 on it at the moment.

I've been noticing a growing lag on the sending of mail though... I've
got a script which takes a message from a form, then runs a while loop
through the rows of the mailing_list table, replacing a special string
with the subscribers name, and sending using the mail() command.

However, this time, the script actually failed, with a failure when
attempting to access blah.com/foo.php (the sending script).  I have no
idea if SOME people got the email, or what, and have no idea how to
check.

So, I make the assumption that as the mailing list has grown, the script
time has slowed... now it's too big (or the server was too busy) to
process all the emails before the script timed out.


If I didn't want to personalise the emails, I'm sure the script would
run a lot quicker with every address in the Bcc header, but since we
personalise each email, I can't see any option other than using mail()
200 times...  and it's only going to get a lot worse as we climb to
1000+.

So, what options do I have?

Break the mailing list up into batches of 40 or so?  How would I
implement something like this?


Any advice / concepts / ideas welcome!


Justin French

Creative Director
http://Indent.com.au



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

###
This message has been scanned by F-Secure Anti-Virus for Internet Mail.
For more information, connect to http://www.F-Secure.com/

###
This message has been scanned by F-Secure Anti-Virus for Internet Mail.
For more information, connect to http://www.F-Secure.com/

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