On our shared web hosting account, we are limited to 600 outbound e-mails per hour (subscribers only, we're a spam free zone). We have several thousand people in our database who need to receive our publication every day. Since 500 e-mails go out in under 10 minutes, Exim gets crabby and bounces back a bunch of "unroutable mail domain" messages and the they don't get through to subscribers. One possible solution is to control the number of e-mails per hour that we are sending, and I'm wondering if
sleep is the correct approach. Here's the code block where I'm thinking of placing it. Is this the right thing to do?
foreach (@{$userinfo}) {
$sendmail_info->{EmailAddress} = $_->{EmailAddress};
SendIt($sendmail_info);
# Here is where I think we should say
sleep 15;
# (or other interval, 4 emails per
# minute equals 240 e-mails per hour)
}
sub SendIt {
my $info = shift @_;
my $msg = MIME::Lite->new(
'From' =>'foo@foobar.com'
'To' => $info->{EmailAddress},
'Subject' => $info->{EmailSubject},
'Type' =>'multipart/mixed'
);
$msg->attach(Type =>'TEXT',
Data => $info->{EmailMessage}
);
$msg->attach(Type =>$info->{MimeType},
Path => $info->{Attachment},
Filename => $info->{AttachmentName},
Disposition => 'attachment'
);
$msg->send_by_sendmail('SetSender'=>1,'FromSender'=>'foo@foobar.com
+');
}
I bet there's a Monk out there who recognizes this. :-)