Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

mail function for batch mails

Posted on 2001-08-02
10
Medium Priority
?
228 Views
Last Modified: 2010-03-05
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
0
Comment
Question by:psimation
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
  • 2
  • +3
10 Comments
 
LVL 8

Expert Comment

by:bebonham
ID: 6344687
I can't seem to send out more than 100 at a time without problems.  But my server is a 486
0
 
LVL 2

Expert Comment

by:shirjeel
ID: 6346821
i think u can use same approach in php too. I mean proceess some mails and then some other and soo on.

0
 
LVL 8

Expert Comment

by:bebonham
ID: 6346900
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!
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 6

Expert Comment

by:andreif
ID: 6347916
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


0
 
LVL 1

Expert Comment

by:builder110697
ID: 6376102
 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...
}
0
 
LVL 17

Author Comment

by:psimation
ID: 6376399
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...
0
 
LVL 1

Accepted Solution

by:
builder110697 earned 150 total points
ID: 6376426
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,
0
 
LVL 1

Expert Comment

by:Moondancer
ID: 6426466
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:  http://www.experts-exchange.com/jsp/cmtyHelpDesk.jsp  
0
 
LVL 17

Author Comment

by:psimation
ID: 6426692
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...
0
 
LVL 1

Expert Comment

by:Moondancer
ID: 6426748
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
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Email validation in proper way is  very important validation required in any web pages. This code is self explainable except that Regular Expression which I used for pattern matching. I originally published as a thread on my website : http://www…
In the distant past (last year) I hacked together a little toy that would allow a couple of Manager types to query, preview, and extract data from a number of MongoDB instances, to their tool of choice: Excel (http://dilbert.com/strips/comic/2007-08…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
Six Sigma Control Plans

721 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question