# Help with Postfix/Cyrus quota issue

## overkll

I have 2 systems giving me grief in relation to user quotas and undeliverable bounce messages.  Seems that postfix doesn't check quotas until final delivery.  If the user is over quota, postfix tries to send a bounce message to the orignal sender.   Often these messages are deferred or even undeliverable.

One system uses Cyrus IMAP and uses LMTP.  Cyrus LMTP does have a quota mechinsism built in, but like I said, it isn't checked until final delivery.  User info is stored in MYSQL.  Quota data is stored in files on a per user basis in the format of total used in bytes on first line and user quota in kilobytes on second line. Example:

```
5602281

102400
```

This example shows that only 5.4% of quota is being used - 5,602,281 divided by 102,400,000

The second system uses postfix delivery to mbox files in /var/mail/.  mbox quota is system wide as set in main.cf.  Quota used is the size of the user's mbox file.

I'd like to setup a script to generate an access map file for over quota users, then drop the connection immediately via postfix ACL's instead of accepting the message.  So postfix main.cf would have something like

```

smtpd_recipient_restrictions =

   ...

   check_recipient_access hash:/etc/postfix/db/quota_check

   ...
```

/etc/postfix/db/quota_check would contain over quota users with the error text:

```
john_doe    550 User over quota

janesmith   550 User over quota

...
```

I don't want to reinvent the wheel, so my questions are:

Is there anyway to use current postfix features to do this without a script?

If not, are there scripts that already do this?

----------

## overkll

No one?

----------

## geforce

http://lists.andrew.cmu.edu/pipermail/info-cyrus/2007-May/025984.html ?

----------

## overkll

Yeah, I found that one too.  But it is limited to a single domain.  It can't do multiple or virtual domains.

I thought I'd test it, but it failed - it needs perl module "Text-Netstring".  Oddly enough, Text-Netstring IS NOT in portage.  WTF?

----------

## geforce

You could try directly by cpan shell ?

As for the script, the author specifies it would require little modifications to make it work with virtual domains..  Maybe someone will fix that.

I will check myself, but i'm no perl programmer.

----------

## overkll

 *geforce wrote:*   

> You could try directly by cpan shell ?

 

Yes, I was thinking the same.  It's would be nice to have the ebuild, then I wouldn't have to worry about missing it with an "emerge -e world"

 *Quote:*   

> As for the script, the author specifies it would require little modifications to make it work with virtual domains..  Maybe someone will fix that.
> 
> I will check myself, but i'm no perl programmer.

 

That'd be nice.  I'm not perl scripter either... yet. LOL

I wonder if Text-Net is included in another ebuild...

I wish postfix would have this pre-acceptance quota check feature.

----------

## overkll

Works well, just for main domain.  Too bad about multiple/virtual domains.  Documentation is lacking wrt aliases.  There is a config parameter for aliasfile, but it doesn't mention if this should be normal aliases (/etc/mail/aliases) or virtual aliases or both.

It'd be nice if mydomain could be defined as an array.

----------

