mail function for batch mails

Hi, I have a client that has about 17000 clients on his mailing list. The addresses are all in a mysql table and currently he is attempting to send it all with a php routine, but that causes the mail system to crash as php tries to send all 17000 at one time... Waht I ned is a perl routine that can wait a while after each batch of xxx (what are your suggestions?) and even to keep an eye on the system load and not to send anything unless the system load is below yyy (again, what is a good value?). I would ideally still want to incorporate php in this in parts, maybe to get the addresses from the mysql table and then write them to a text file where perl can read them and then send the mail...
Can someone give me an example of how to do this, it's rather urgent.
Server = linux redhat 7.0 with latest patches etc.
and running sendmail/cyrus
LVL 17
Who is Participating?
Not knowing mysql is then my big disadvantage ;-)  I can assume that the query
can be invoked such that the return is an array...  then it is only to rewrite the
script to "talk to" the database...  How 'bout retrieving entries in parcels of 100?

While ( not complete ) {
  get a parcel
  process the addresses
  check to see if the sendmail is complete

Sorry I can't help more,
I can't seem to send out more than 100 at a time without problems.  But my server is a 486
i think u can use same approach in php too. I mean proceess some mails and then some other and soo on.

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

yeah, but I am kinda interested in what others will say...

I'm sure others do this...

you'd expect to throw sendmail a list of x (memory allowable)
and you'd think it would handle it, in a queue like behaviour.


I would say this is the solution you are looking for...

in other words, if someone can tell you how to create a queue or buffer that will hold all the email vars, and them pass then as sendmail can accept them would be ideal...

like if you could get a value from sendmail as to how many more emails it could handle, or at least how many it had waiting...or even still workable, when it sent the mail and returned to a waiting state.

so, then you could pop off variable sets to sendmail.

I wonder if the amount of data you are passing to sendmail you are passing a big or small message...

just wondering...

of course you can do something like
and loop it.

but that is a hack, right, we need a sendmail xpert here...
cross post a q in the unix area or linux...I don't think there is a sendmail area...if there is...that's the place...

but post a q like "sendmail limits".

Good luck!!!
we all hate these types of problems!
usually I use perl programm for such things, but it should work not as CGI script (otherwise timeout errors can happens and so on) but as server side programm. You can call it from CGI script and leave on background, don't wait until it finish work.

So, you should write - usual Perl programm for running from shell, it will send out your mails (use SMTP to send them out - it works nice)
and run.cgi - Perl scripg which calls using
system(' &'). You can add web interface for mail body here

It will a good idea to send a message to yourself in the end of the - to inform you that the programm was successfully finished

 use Mail::Sendmail;

  $hesitate = 0;
  $bulk_message = "this is a test";
  @addresses = ( "", "" );
  foreach $addr ( @addresses ) {
    if ( $hesitate >= 99 ) {
      $hesitate =0;
    else {
       my %mail = (
          To => $addr,
          Subject =>'Bulk Mailing',
          Message => $message );
       sendmail( %mail ) or die $Mail::Sendmail::error;

sub kill_time {
  # do something as simple as wait or
  # as complicated as checking that system is not overburdened...
psimationAuthor Commented:
Hi builder
Thanks, your solution is by far the most "complete" so far. I would like to ask you a couple of thing if I may though.
Firstly, as I already mentioned, I already have all the addresses in a mysql table, and since it's easy to (and I already know how to) get those addresses out of the tables and into a file, I would like the perl program to read the list of addresses from a file. I see you create a list @addresses and then fill it by hand, but I would be interested to see how it would look when you pull the addresses from a file and then "populate" the list with whatever is in the file...
It's time to clean up this topic area and that means taking care of this question. Your options at this point are:
1. Award points to the Expert who provided an answer, or who helped you most. Do this by clicking on the "Accept Comment as Answer" button that lies above and to the right of the appropriate expert's name.
2. PAQ the question because the information might be useful to others, but was not useful to you. To use this option, you must state why the question is no longer useful to you, and the experts need to let me know if they feel that you're being unfair.
3.  Ask Community Support to help split points between participating experts.  Just comment here with details.
4.  Delete the question because it is of no value to you or to anyone else.  To use this option, you must state why the question is no longer useful to you, and the experts need to let me know if they feel that you're being unfair.
If you elect for option 2, 3 or 4, just post comment with details here and I'll take it from there.  We also request that you review any other open questions you might have and update/close them.  Display all your question history from your Member Profile to view details.
Hi Experts:
In the event that the Asker does not respond, I would very much appreciate your opinions as to which Expert ought to receive points (if any) as a result of this question.  Likewise, you can also suggest that I PAQ or delete the question.
Experts, please do not add further "answer" information to this question.  I will be back in about one week to finalize this question.
Thank you everyone.
Moondancer :)
Community Support Moderator @ Experts Exchange
P.S.  REGARDING POINTS, Question/Answer processes, Grades , Guidelines and more:  
psimationAuthor Commented:
I am still far away from being able to say " WOW, it's working, but I have obtained various Perl books, and I believe that with your proposed solution and some imagination, I should come right after all...
In the event you collaborate further and ultimately achieve your goal and wish to change this grade from a B to an A, let me know via comment.

Community Support Moderator @ Experts Exchange
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.