Exim 4.x with Courier's Maildir++ Quota (deliverquota)
This is how I use deliverquota with exim. As you can see, I use a mysql lookup to find the value of the quota. The returned value must in the format that deliverquota expects obviously, check the man page for more information.
testing_pipe:
driver = pipe
command = /usr/sbin/deliverquota -c /home/mail/${domain}/${local_part} '${lookup mysql {MYSQL_VIRTUAL_QUOTA}{$value}}'
return_fail_output
user = mail
group = mail
The ‘return_file_output’ option tells exim to return the output of deliverquota if the process returns a non zero error code. In other words, if delivery fails due to quota exceed, the sender will be notified.