Limit the number of emails received per hour to an account

Limit the number of emails received per hour to an account

am 16.11.2006 15:09:14 von news

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.=20

Any idea?

Thanks in advance
// Martin R=E5dbo
Teknologia

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

am 16.11.2006 20:48:33 von patrick

In news:1163686154.825610.275020@k70g2000cwa.googlegroups.com,
news@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.

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

am 16.11.2006 21:47:47 von Alan Clifford

On Thu, 16 Nov 2006 news@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. )

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

am 17.11.2006 06:17:45 von AK

Alan Clifford wrote:

> On Thu, 16 Nov 2006 news@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

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

am 17.11.2006 16:46:17 von Frank Slootweg

Alan Clifford 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.").

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

am 17.11.2006 16:49:56 von Frank Slootweg

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]

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

am 17.11.2006 19:14:51 von news

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]

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

am 20.11.2006 15:08:33 von AK

news@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