Limit the number of emails received per hour to an account

I know this might seem a bit odd but we need to set a limit for an
email account.

What we need to do is to limit the number of emails that this account
can receive per hour, i.e., maximum one email per hour, all other
emails should be forwarded to another account. But one hour later after
his "first" email ha should be able to recieve another email.

First idea was to use his .procmailrc and make some sort of rule there
(I'm quite familiar with procmailrc) but so far we have not found a
solution.

Any idea?

Thanks in advance
// Martin R=E5dbo
Teknologia
news [ Do, 16 November 2006 15:09 ] [ ID #1538749 ]

Re: Limit the number of emails received per hour to an account

In news:1163686154.825610.275020 [at] k70g2000cwa.googlegroups.com,
news [at] teknologia.com <news [at] teknologia.com> wrote:

> What we need to do is to limit the number of emails that this account
> can receive per hour, i.e., maximum one email per hour, all other
> emails should be forwarded to another account. But one hour later
> after his "first" email ha should be able to recieve another email.

It sounds absurdly Orwellian.
patrick [ Do, 16 November 2006 20:48 ] [ ID #1538750 ]

Re: Limit the number of emails received per hour to an account

On Thu, 16 Nov 2006 news [at] teknologia.com wrote:

> I know this might seem a bit odd but we need to set a limit for an
> email account.
>
> What we need to do is to limit the number of emails that this account
> can receive per hour, i.e., maximum one email per hour, all other
> emails should be forwarded to another account. But one hour later after
> his "first" email ha should be able to recieve another email.
>
> First idea was to use his .procmailrc and make some sort of rule there
> (I'm quite familiar with procmailrc) but so far we have not found a
> solution.
>
> Any idea?

In your procmail recipe, check for your flag file. If it exists, divert
the email. It the flag file does not exist, deliver the email, then
create the flag file with, say, touch.

Cron job, every few minutes or whatever granularity you want. If the flag
file is greater than one hour old, delete it.


--
Alan

( If replying by mail, please note that all "sardines" are canned.
There is also a password autoresponder but, unless this a very
old message, a "tuna" will swim right through. )
Alan Clifford [ Do, 16 November 2006 21:47 ] [ ID #1538751 ]

Re: Limit the number of emails received per hour to an account

Alan Clifford wrote:

> On Thu, 16 Nov 2006 news [at] teknologia.com wrote:
>
>> I know this might seem a bit odd but we need to set a limit for an
>> email account.
>>
>> What we need to do is to limit the number of emails that this account
>> can receive per hour, i.e., maximum one email per hour, all other
>> emails should be forwarded to another account. But one hour later after
>> his "first" email ha should be able to recieve another email.
>>
>> First idea was to use his .procmailrc and make some sort of rule there
>> (I'm quite familiar with procmailrc) but so far we have not found a
>> solution.
>>
>> Any idea?
>
>
> In your procmail recipe, check for your flag file. If it exists, divert
> the email. It the flag file does not exist, deliver the email, then
> create the flag file with, say, touch.
>
> Cron job, every few minutes or whatever granularity you want. If the
> flag file is greater than one hour old, delete it.
>
>

Alan,

Using a file to as a reference is the way to go. There is no need to
run cron to remove the file since you can always test with a simple perl
script the age of the file.

#!/usr/bin/perl
$filename="path_to_the_flag_file";

$elapsed_time=(stat($filename))[9];

if ($elapsed_time>=3600) {
print "an hour has passed\n";
exit 0;
}
else { exit 1; }

in the procmailrc file you would test for a clean exit code from running
the above script in order to deliver the email as well as touch the file
anew to reset its modify date.

AK
AK [ Fr, 17 November 2006 06:17 ] [ ID #1540056 ]

Re: Limit the number of emails received per hour to an account

Alan Clifford <sardines [at] purse-seine.net> wrote:
[deleted]
> In your procmail recipe, check for your flag file. If it exists, divert
> the email. It the flag file does not exist, deliver the email, then
> create the flag file with, say, touch.
>
> Cron job, every few minutes or whatever granularity you want. If the flag
> file is greater than one hour old, delete it.

No need to do that in a cron job. It can be done in the procmailrc
itself, i.e. before "If it exists, divert the email.".

BTW, if your (the OP's) shell doesn't have functions for determining
file age (in hours), the find(1) command may come in handy, provided it
has the (non-standard) "-?min n" options like "-mmin n" ("File's data
was last modified n minutes ago.").
Frank Slootweg [ Fr, 17 November 2006 16:46 ] [ ID #1540057 ]

Re: Limit the number of emails received per hour to an account

A little earlier, I wrote:
[deleted]

> No need to do that in a cron job. It can be done in the procmailrc
> itself, i.e. before "If it exists, divert the email.".

Sorry about that. I hadn't seen AK's response (while it was already in
the list of new articles)

Good that I posted a "BTW", so I don't look like a complete dork! :-)

[deleted]
Frank Slootweg [ Fr, 17 November 2006 16:49 ] [ ID #1540058 ]

Re: Limit the number of emails received per hour to an account

Thanks Guys.

I get all the logic in your thoughts but I am unable to get it right.
Could someone please give me an example of un procmailrc together with
a script file there this works?

// Martin


Frank Slootweg skrev:

> A little earlier, I wrote:
> [deleted]
>
> > No need to do that in a cron job. It can be done in the procmailrc
> > itself, i.e. before "If it exists, divert the email.".
>
> Sorry about that. I hadn't seen AK's response (while it was already in
> the list of new articles)
>
> Good that I posted a "BTW", so I don't look like a complete dork! :-)
>
> [deleted]
news [ Fr, 17 November 2006 19:14 ] [ ID #1540059 ]

Re: Limit the number of emails received per hour to an account

news [at] teknologia.com wrote:

> Thanks Guys.
>
> I get all the logic in your thoughts but I am unable to get it right.
> Could someone please give me an example of un procmailrc together with
> a script file there this works?
>
> // Martin
>
>
> Frank Slootweg skrev:
>
>
>>A little earlier, I wrote:
>>[deleted]
>>
>>
>>> No need to do that in a cron job. It can be done in the procmailrc
>>>itself, i.e. before "If it exists, divert the email.".
>>
>> Sorry about that. I hadn't seen AK's response (while it was already in
>>the list of new articles)
>>
>> Good that I posted a "BTW", so I don't look like a complete dork! :-)
>>
>>[deleted]
>
>

Let say the perl script below is named check.pl
#!/usr/bin/perl
$filename="path_to_the_flag_file";
if ( -e $filename ) {
$elapsed_time=(stat($filename))[9];
}
else {
system "touch $filename";
$elapsed_time=3700;
}

if ($elapsed_time>=3600) {
print "an hour has passed\n";
exit 0;
}
else { exit 1; }


The recipe
:0
* test check.pl
$deliver_locally

:0
! anotheremailaddress

AK
AK [ Mo, 20 November 2006 15:08 ] [ ID #1542531 ]
Miscellaneous » comp.mail.misc » Limit the number of emails received per hour to an account

Vorheriges Thema: [Rant] Gmail
Nächstes Thema: Stats comp.mail.misc (last 7 days)