Exim
exim 和 dovecot 使用者超過配額:發送時拒絕?
我有一個 exim + dovecot 郵件伺服器設置,每個使用者配額(通過 mysql 查找)正在執行。當目標本地郵箱超過配額時,伺服器會拒絕來自非本地發件人的傳入郵件。本地使用者可以不受限制地發送郵件,即使他的郵箱超過配額。
我希望在本地使用者嘗試發送電子郵件並返回諸如“您的帳戶已超過配額,請先刪除一些郵件”之類的錯誤時檢查配額。無論配額如何,都應該接受來自非本地發件人到本地郵箱的傳入郵件。
“設置 exim”中描述了類似的配置:
acl_check_rcpt: #... # 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@.*:\ ^root@.*:\ ^webmaster@.*:\ ^error-.*@.*:\ ^bounce-.*@.* # 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/check-sendquota.sh $sender_address_local_part}{no}{yes}}
它使用自定義腳本來檢查郵箱大小 - 出於性能原因,我寧願使用已經存在的配額文件/系統,但我無法找出正確的“條件”行。我無法從目前配置中看到 exim 實際檢查郵箱大小的位置。目前配置包含以下內容:
exim4.conf:
local_delivery: driver = appendfile maildir_format 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}'}}
dovecot.conf:
protocol imap { mail_plugins = quota imap_quota } plugin { quota = maildir:user quota_rule = *:storage=5GB }
您需要在您的 acl_not_smtp acl 中添加類似的配額檢查,此 acl 用於本地使用者/程序送出的所有無 smtp 郵件
http://www.exim.org/exim-html-current/doc/html/spec_html/ch40.html