[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

[FWP] Re: using perl to send a list message (with qmail)





Not tested.  May provoke unpleasent censure.  Use at own risk.



> > > open (LIST,"/home/justin/www/cgi-bin/lovely_people.list");
> > > foreach (<LIST>) {
> > >   #send mail to "$_"
> > >  }

> > 2)this list has about 1000 people, and it takes more than a couple minutes
> > for  perl to go through that all,making my program look like its hanging

There's always

fork and goto GLADTHATSOVER
close STDOUT;
open (LIST,"/home/justin/www/cgi-bin/lovely_people.list");
foreach (<LIST>) {
  #send mail to "$_"
}
exit;

GLADTHATSOVER:

And since you've now got all the time you need to process the list,
you can even save bandwidth by arranging them by destination host
and invoking qmail-remote directly:

%Recipients=();
while(<LIST>){
	my($name,$host) = m/^\s*([^@]+)\@([^@]+)\s*\Z/ or next;
	$Recipients{$host} = [ $name.'@'.$host, @{$Recipients{$host}}];
};
for(keys %Recipents){
  $/ = "\0";	#match qmail-remote's idea of how to end a report item
  open QR,"/var/qmail/bin/qmail-remote $_ justin\@summerspam.com
@{$Recipients{$_}}<lovelymessage|";
  while(<QR>){
		$This = shift @{$Recipients{$_}};
		next if $This =~ m/^K/; # delivery successful
		# otherwise, queue it up for later
		system"/var/qmail/bin/qmail-inject -r -fjustin\@summerspam.com
$This<lovelymessage|";
	};
};




Good lord!  I'm instructing the world how to send thousands of e-mails
from within a CGI!  Please use this for good and not for evil!  
I'd better insert some tactical syntactic problems...

While we're at it, would anyone like some blue prints for atomic
weapons?

==== Want to unsubscribe from Fun With Perl?  Well, if you insist...
==== Send email to <fwp-request@technofile.org> with message _body_
====   unsubscribe