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. :-)

In reply to Controlling e-mails sent per hour by insite2000

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.