我们使用Postfix 2.11.0和Dovecot 2.2.9作为MTA / MDA的组合。 作为pipe理邮件域和邮箱的前端,使用了postfix.admin。
由于允许用户添加邮箱到他们的域可以很容易地失去控制我想设置每个域的最大邮箱大小。
举个例子:
domain example.com >> Domain quoata = 20000 MB
这将允许用户以任意大小自由设置他们的邮箱,但不允许他们使用超过20 GB(通过所有邮箱传播)。
为了澄清我不想设置每个邮箱配额,这是强制性的。 pipe理员获得x MB的空间,并可以将其分配给他们的喜好。
我的第一个想法是将这个function添加到我自己的postfix.admin,添加一个新的列到存储域配额的域表的方式。 然后每次向特定的域添加一个新的邮箱,包含当前邮箱配额的列将被查询和总结,然后检查这个示例代码(这不是真正的代码!):
if (SUM(mailbox_quota) + to_add_mailbox_quota > domain_qouta) { throw_warning and don't proceed }
但也许我错过了一些function,我很高兴能够了解这方面的几种方法。
编辑:
通过评估postfix.admins代码,我发现这个:
# TODO: detailed error message ("domain quota exceeded", "mailbox quota too big" etc.) via flash_error? Or "available quota: xxx MB"? if ( !Config::bool('domain_quota') ) { return true; # enforcing domain_quota is disabled - just allow it } elseif ($limit['quota'] <= 0) { # TODO: CHECK - 0 (unlimited) is fine, not sure about <= -1 (disabled)... $rval = true; } elseif ($quota == 0) { # trying to create an unlimited mailbox, but domain quota is set return false; } else { $table_mailbox = table_by_key('mailbox'); $query = "SELECT SUM(quota) FROM $table_mailbox WHERE domain = '" . escape_string($domain) . "'"; $query .= " AND username != '" . escape_string($this->id) . "'"; $result = db_query ($query); $row = db_row ($result['result']); $cur_quota_total = divide_quota($row[0]); # convert to MB if ( ($quota + $cur_quota_total) > $limit['quota'] ) { $rval = false; } else { $rval = true; } } return $rval;
这应该如果我理解它是正确的,做正是我所说的,如果它在这样的configuration(它是这样)设置:
// If you want to enforce domain-level quotas set this to 'YES'. $CONF['domain_quota'] = 'YES';
但是,我可以添加带有4 GB配额的邮箱到强制configuration2 GB的域,但是为什么呢?
解决scheme!
要使用postfix 2.3.8的域配额function,您不仅必须强制域quouta,还必须强制邮箱用户的配额。
从pipe理员的angular度来看,这是非常严重的logging/无证/不清楚。 我希望这将有助于未来的人。
这需要在你的config.inc.php
:
// When you want to enforce quota for your mailbox users set this to 'YES'. $CONF['quota'] = 'YES'; // If you want to enforce domain-level quotas set this to 'YES'. $CONF['domain_quota'] = 'YES';