Dovecot 的 grace_quota 不起作用

Dovecot 的 grace_quota 不起作用

我的邮件服务器正在运行:

  • Postfix 3.1
  • Dovecot 2.2.22
  • MySQL 5.7
  • Ubuntu 16.04

我配置了每个用户的配额,从邮件数据库用户表的以下列中读取quota

dovecot-sql.conf.ext

driver = mysql

connect = host=127.0.0.1  dbname=mail user=admin password=XIOVwxasxvD

default_pass_scheme = SHA512-CRYPT


user_query = SELECT CONCAT('/home/vmail/',CONCAT(SUBSTRING_INDEX(email,'@',-1),'/',SUBSTRING_INDEX(email,'@',1))) AS home, 5000 AS uid, 5000 AS gid, concat('*:bytes=', quota) AS quota_rule FROM users WHERE email='%u'


password_query = SELECT email as user, password, 5000 AS userdb_uid, 5000 AS userdb_gid, concat('*:bytes=', quota) AS userdb_quota_rule FROM users WHERE email='%u';

我进行了以下配置,以启用 80% 和 95% 的配额警告,并将宽限配额设置为 10%,每个用户的最大配额为 50 MB,

conf.d/90-quota.conf

plugin {
  quota_rule = *:bytes=1G
  quota_rule2 = Trash:storage=+100M
  quota_rule3 = Sent:storage=+100M
}

plugin {
  quota_warning = storage=95%% quota-warning 95 %u
  quota_warning2 = storage=80%% quota-warning 80 %u
}

service quota-warning {
  executable = script /usr/local/bin/quota-warning.sh
  user = vmail
  unix_listener quota-warning {
    user = vmail
  }
}

plugin {
  quota = maildir:User quota
}
plugin {
  quota_grace = 10%%
  quota_grace = 50M
}
plugin {
  quota_over_flag_value = TRUE



  quota_over_script = quota-warning mismatch %u
}

警告消息工作正常,但一旦用户达到“101%”配额大小,它会拒绝任何新邮件,并向发件人显示“超出配额”错误消息,而不应用宽限配额配置,

在调试模式日志中我得到:

Jul 12 18:48:57 mail postfix/smtp[23827]: 22A7FE884: to=<[email protected]>, relay=127.0.0.1[127.0.0.1]:10024, conn_use=178, delay=17, delays=0.01/16/0.01/1.7, dsn=2.0.0, status=sent (250 2.0.0 from MTA(smtp:[127.0.0.1]:10025): 250 2.0.0 Ok: queued as 490A8D627)
Jul 12 18:48:57 mail postfix/qmgr[25020]: 22A7FE884: removed
Jul 12 18:48:57 mail postfix/pickup[24689]: 5C653E898: uid=5000 from=<[email protected]>
Jul 12 18:48:57 mail postfix/cleanup[25288]: warning: connect to Milter service inet:localhost:9001: Cannot assign requested address
Jul 12 18:48:57 mail postfix/cleanup[25288]: 5C653E898: message-id=<[email protected]>
Jul 12 18:48:57 mail postfix/qmgr[25020]: 5C653E898: from=<[email protected]>, size=418, nrcpt=1 (queue active)
Jul 12 18:48:58 mail postfix/smtpd[25228]: 389E6D627: client=localhost[127.0.0.1]
Jul 12 18:48:58 mail postfix/cleanup[25288]: 389E6D627: message-id=<[email protected]>
Jul 12 18:48:58 mail postfix/qmgr[25020]: 389E6D627: from=<[email protected]>, size=877, nrcpt=1 (queue active)
Jul 12 18:48:58 mail dovecot: lmtp(24483): Debug: Quota root: name=User quota backend=maildir args=
Jul 12 18:48:58 mail dovecot: lmtp(24483): Debug: Quota rule: root=User quota mailbox=* bytes=1073741824 messages=0
Jul 12 18:48:58 mail dovecot: lmtp(24483): Debug: Quota rule: root=User quota mailbox=Trash bytes=+104857600 messages=0
Jul 12 18:48:58 mail dovecot: lmtp(24483): Debug: Quota rule: root=User quota mailbox=Sent bytes=+104857600 messages=0
Jul 12 18:48:58 mail dovecot: lmtp(24483): Debug: Quota warning: bytes=1020054732 (95%) messages=0 reverse=no command=quota-warning 95 raw mail user
Jul 12 18:48:58 mail dovecot: lmtp(24483): Debug: Quota warning: bytes=858993459 (80%) messages=0 reverse=no command=quota-warning 80 raw mail user
Jul 12 18:48:58 mail dovecot: lmtp(24483): Debug: Quota grace: root=User quota bytes=52428800
Jul 12 18:48:58 mail dovecot: lmtp(24483): Debug: none: root=, index=, indexpvt=, control=, inbox=, alt=
Jul 12 18:48:58 mail dovecot: lmtp(24483): Connect from local
Jul 12 18:48:58 mail dovecot: auth: Debug: master in: USER#011104#[email protected]#011service=lmtp
Jul 12 18:48:58 mail dovecot: auth-worker(15471): Debug: sql([email protected]): SELECT CONCAT('/home/vmail/',CONCAT(SUBSTRING_INDEX(email,'@',-1),'/',SUBSTRING_INDEX(email,'@',1))) AS home, 5000 AS uid, 5000 AS gid, concat('*:bytes=', quota) AS quota_rule FROM users WHERE email='[email protected]'
Jul 12 18:48:58 mail dovecot: auth: Debug: userdb out: USER#011104#[email protected]#011home=/home/vmail/mydomain.com/user#011uid=5000#011gid=5000#011quota_rule=*:bytes=102400
Jul 12 18:48:58 mail dovecot: lmtp([email protected]): Debug: auth input: [email protected] home=/home/vmail/mydomain.com/user uid=5000 gid=5000 quota_rule=*:bytes=102400
Jul 12 18:48:58 mail dovecot: lmtp([email protected]): Debug: Added userdb setting: plugin/quota_rule=*:bytes=102400
Jul 12 18:48:58 mail dovecot: lmtp(24483, [email protected]): Debug: Effective uid=5000, gid=5000, home=/home/vmail/mydomain.com/user
Jul 12 18:48:58 mail dovecot: lmtp(24483, [email protected]): Debug: Quota root: name=User quota backend=maildir args=
Jul 12 18:48:58 mail dovecot: lmtp(24483, [email protected]): Debug: Quota rule: root=User quota mailbox=* bytes=102400 messages=0
Jul 12 18:48:58 mail dovecot: lmtp(24483, [email protected]): Debug: Quota rule: root=User quota mailbox=Trash bytes=+104857600 messages=0
Jul 12 18:48:58 mail dovecot: lmtp(24483, [email protected]): Debug: Quota rule: root=User quota mailbox=Sent bytes=+104857600 messages=0
Jul 12 18:48:58 mail dovecot: lmtp(24483, [email protected]): Debug: Quota warning: bytes=97280 (95%) messages=0 reverse=no command=quota-warning 95 [email protected]
Jul 12 18:48:58 mail dovecot: lmtp(24483, [email protected]): Debug: Quota warning: bytes=81920 (80%) messages=0 reverse=no command=quota-warning 80 [email protected]
Jul 12 18:48:58 mail dovecot: lmtp(24483, [email protected]): Debug: Quota grace: root=User quota bytes=52428800
Jul 12 18:48:58 mail dovecot: lmtp(24483, [email protected]): Debug: Namespace inbox: type=private, prefix=, sep=, inbox=yes, hidden=no, list=yes, subscriptions=yes location=maildir:/home/vmail/mydomain.com/user
Jul 12 18:48:58 mail dovecot: lmtp(24483, [email protected]): Debug: maildir++: root=/home/vmail/mydomain.com/user, index=, indexpvt=, control=, inbox=/home/vmail/mydomain.com/user, alt=
Jul 12 18:48:58 mail dovecot: lmtp(24483, [email protected]): Debug: quota: quota_over_flag check: STORAGE ret=1 value=101 limit=100
Jul 12 18:48:58 mail dovecot: lmtp(24483, [email protected]): Debug: quota: quota_over_flag check: MESSAGE ret=0 value=99 limit=0
Jul 12 18:48:58 mail dovecot: lmtp(24483, [email protected]): Debug: quota: quota_over_flag=0((null)) vs currently overquota=1
Jul 12 18:48:58 mail dovecot: lmtp(24483, [email protected]): Debug: quota: Executing warning: quota-warning mismatch [email protected]
Jul 12 18:48:58 mail dovecot: lmtp([email protected]): 4GRuG8FuZlmjXwAAPxyzFw: msgid=<[email protected]>: save failed to INBOX: Quota exceeded (mailbox for user is full)

答案1

Dovecotgrace_quota无法像您预期的那样工作。从Dovecot 配额手册

在 v2.2+ 中,默认情况下,最后一封邮件会使用户超出配额。这很有用,因为它可以让用户真正明确地超出配额,而不是让最后几封较大的邮件失败,并让一些较小的邮件通过。当然,不应该允许最后一封邮件使用户大大超出配额,因此在 v2.2+ 中,默认情况下此限制是用户配额限制的 10%。(在 v2.1 中,默认情况下禁用此功能。)

换句话说,quota_grace可以避免出现令人困惑的情况,即由于邮件超出用户配额而被拒绝(大型邮件),但随后成功发送了较新的(和较小的)邮件(因为它们仍然符合用户的配额)。使用quota_grace,Dovecot 允许发送最后一封大型邮件,但随后会阻止其他邮件,因为用户超出了 100% 的配额使用率。

Dovecot 不知道您正在寻找的功能 - 虽然您可以简单地发送具有转移配额使用值的邮件(例如,发送“您使用了 100% 的配额”尽管用户实际上仍为 90%并相应地调整实际限制),但实际配额仍然通过 IMAP 传输,用于显示您的配额使用情况的邮件客户端。

相关内容