Adding Quotas to an Exim Configuration

This note is a supplement to the virtual domain mail setup. I assume that you are delivering to a Maildir, I have not tried this with other delivery formats.

In my configuration I have added a fixed, global quota for all virtual users. This involves two changes:

  1. In the virtual_delivery transport I have added the quota definition
    virtual_delivery:
    driver = appendfile
    directory=${extract {homedir}{${lookup mysql{USER_QUERY}}}{$value}fail}/Maildir
    delivery_date_add
    envelope_to_add
    return_path_add
    user =  mail
    maildir_format
    maildir_use_size_file
    quota = 20M
    quota_warn_threshold = 75% 
    
    Exim will automatically create the control files that are needed also by Courier-IMAP.
  2. In the retry section I have added a line to say what to do when an over-quota condition is detected.
    
    # Immediate bounce of over-quota messages
    *                       quota
    #Catchall rule for other errors
    *                       *           F,2h,15m; G,16h,1h,1.5; F,4d,6h
    
    The ordering of the lines is important.

If you want per domain or per user quotas you will have to replace quota = 20M by a suitable lookup e.g.

quota = ${lookup mysql{select quota from Domains where domain='$domain'}{$value}{10M}}
assuming that you have the appropriate table structure set up.
Creative Commons License

This work is licenced under a Creative Commons Licence.