Link to home
Start Free TrialLog in
Avatar of psimation
psimationFlag for South Africa

asked on

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
Avatar of bebonham
bebonham

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.

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.


psimation,

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 matters...ie...if you are passing a big or small message...

just wondering...

of course you can do something like
send(popSomeArray(\@refToArray,100))
sleep(60)
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

send.pl - 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 send.pl using
system('send.pl &'). 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 send.pl - to inform you that the programm was successfully finished


 use Mail::Sendmail;

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

sub kill_time {
  # do something as simple as wait or
  # as complicated as checking that system is not overburdened...
}
Avatar of psimation

ASKER

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...
ASKER CERTIFIED SOLUTION
Avatar of builder110697
builder110697

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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.
 
PLEASE DO NOT AWARD THE POINTS TO ME.
 
____________________________________________
 
 
 
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:  https://www.experts-exchange.com/jsp/cmtyHelpDesk.jsp  
Builder
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.

Moondancer
Community Support Moderator @ Experts Exchange