One change which I would make would be the following which implements a variable
sleep such that the sending of mail is more evenly timed to match 15 second intervals - I have used something similar for a dispatch of mail to our (many thousand) local users in order to stagger the load on the mail server.
eval "use Time::HiRes qw( time sleep )";
foreach (@{ $userinfo }) {
my $time = time();
...
sleep 15 - ((time() - $time) % 15);
}
However, if you are employing sendmail as a local MTA, you may be interested in taking a look at
vthrottle which is a rate throttling mechanism for Sendmail implemented via the milter interface (which can also be interfaced in Perl by way of
Sendmail::Milter or
PMilter). This may constitute a longer term solution for your mail throttling.
perl -le "print unpack'N', pack'B32', '00000000000000000000001011000000'"