Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

i have an exim + dovecot mailserver setup with per-user quota (via mysql lookup) running. the server rejects incoming mail from non-local senders when the targeted local mailbox is over quota. the local user can send out mails without restrictions eventho his mailbox is over quota.

i'd prefer the quota to be checked when the local user tries to send an email and return an error like "your account is over quota, please remove some mails first". incoming mails from non-local senders to a local mailbox should be accepted no matter of the quota.

there is a similar configuration described on "Setting up exim":

  # Deny sending for local users if almost at quota
        # only run for local domains
  deny  sender_domains = +local_domains
        # list all addresses that are aliases
        # though people shouldn't be sending as
        # them, many scripts do
        !senders = ^postmaster@.*:\
        # might need to exclude webmail server here
        # if it does not report the error message
        # note: squirrelmail tested ok for me
        hosts = +local_hosts
        # verify your email client expunges on emptying the trash
        message = You have too much email stored. Please delete some\n\
                  and empty the trash. Then you can send.
        log_message = $sender_address_local_part is over send quota
        condition = ${run{sudo -u root /etc/exim/ $sender_address_local_part}{no}{yes}}

it uses a custom script to check the mailbox size - for performance reasons i'd rather use the already existing quota files/system, but i can't figure out the correct "condition" line. i can't see from the current config where exim actually checks for the mailbox size. the current config contains among other things:


    driver = appendfile
    user = mailserv
    group = mailserv
    mode = 0660
    mode_fail_narrower = false
    envelope_to_add = true
    return_path_add = true
    maildir_tag = ,S=$message_size
    quota_size_regex = ,S=(\d+)
    quota =  ${lookup mysql{SELECT CONCAT(quota, "M") FROM users WHERE account='${local_part}@${domain}'}{$value}{7M}}
    directory = ${lookup mysql{SELECT maildir FROM users WHERE account='${local_part}@${domain}'}}


protocol imap {
    mail_plugins = quota imap_quota
plugin {
    quota = maildir:user
    quota_rule = *:storage=5GB
share|improve this question

You need to add a similar quota check to your acl_not_smtp acl, this acl is used for all none smtp mail submitted by local users / processes

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.