Other ways than quotas to limit mail files size ??
Jez Hancock
jez.hancock at munk.nu
Mon Jan 12 00:00:14 PST 2004
On Mon, Jan 12, 2004 at 08:34:53AM +0100, Greg Bernard wrote:
> Le 11/01/04 23:12, ??Mike Maltese?? <mike at pcmedx.com> a ?crit?:
> >> Is there another way to limit the amount of space occupied by mail files
> > on
> >> a per user basis using another method than quotas ?
> >> I would like to limit the amount of space available for each user's e.mail
> >> so e.mail file size will not go crazy.
> > Is there an option to limit message size with the MTA you are using?
> Well I don't know, that's my question...
> I am using sendmail.
Exim can do quotas.
http://www.exim.org/
also in the ports:
/usr/ports/mail/exim/
I've never actually used the quota system myself in Exim but it sounds
relatively straightforward - from the specifications for Exim:
quota Type: string* Default: unset
This option imposes a limit on the size of the file to which Exim is
appending, or to the total space used in the directory tree when the
"directory" option is set. In the latter case, computation of the space
used is expensive, because all the files in the directory (and any sub-
directories) have to be individually inspected and their sizes summed (but
see "quota_size_regex" below). Also, there is no interlock against two
simultaneous deliveries into a multi-file mailbox. For single-file
mailboxes, of course, an interlock is a necessity.
A file's size is taken as its "used" value. Because of blocking effects,
this may be a lot less than the actual amount of disk space allocated to
the file. If the sizes of a number of files are being added up, the
rounding effect can become quite noticeable, especially on systems that
have large block sizes. Nevertheless, it seems best to stick to the "used"
figure, because this is the obvious value which users understand most
easily.
The value of the option is expanded, and must then be a numerical value
(decimal point allowed), optionally followed by one of the letters K or M.
A value of zero unsets the option. The expansion happens while Exim is
running as root, before it changes uid for the delivery. This means that
files which are inaccessible to the end user can be used to hold quota
values that are looked up in the expansion. When delivery fails because
this quota is exceeded, the handling of the error is as for system quota
failures.
By default, Exim's quota checking mimics system quotas, and restricts the
mailbox to the specified maximum size, though the value is not accurate to
the last byte, owing to separator lines and additional headers that may
get added during message delivery. When a mailbox is nearly full, large
messages may get refused even though small ones are accepted, because the
size of the current message is added to the quota when the check is made.
This behaviour can be changed by setting "quota_is_inclusive" false. When
this is done, the check for exceeding the quota does not include the
current message. Thus, deliveries continue until the quota has been
exceeded; thereafter, no further messages are delivered. See also
"quota_warn_threshold".
quota_directory Type: string* Default: unset
This option defines the directory to check for quota purposes when
delivering into individual files. The default is the delivery directory,
or, if a file called maildirfolder exists in a maildir directory, the
parent of the delivery directory.
quota_filecount Type: string* Default: 0
This option applies when the "directory" option is set. It limits the
total number of files in the directory (compare the inode limit in system
quotas). It can only be used if "quota" is also set. The value is
expanded; an expansion failure causes delivery to be deferred.
quota_is_inclusive Type: boolean Default: true
See "quota" above.
quota_size_regex Type: string Default: unset
This option applies when one of the delivery modes that writes a separate
file for each message is being used. When Exim wants to find the size
of one of these files in order to test the quota, it first checks
"quota_size_regex". If this is set to a regular expression that matches
the file name, and it captures one string, that string is interpreted as a
representation of the file's size. The value of "quota_size_regex" is not
expanded.
This feature is useful only when users have no shell access to their
mailboxes - otherwise they could defeat the quota simply by renaming the
files. This facility can be used with maildir deliveries, by setting
"maildir_tag" to add the file length to the file name. For example:
maildir_tag = ,S=$message_size
quota_size_regex = ,S=(\d+)
The regular expression should not assume that the length is at the end of
the file name (even though "maildir_tag" puts it there) because maildir
MUAs sometimes add other information onto the ends of message file names.
quota_warn_message Type: string* Default: see below
See below for the use of this option. If it is not set when
"quota_warn_threshold" is set, it defaults to
quota_warn_message = "\
To: $local_part@$domain\n\
Subject: Your mailbox\n\n\
This message is automatically created \
by mail delivery software.\n\n\
The size of your mailbox has exceeded \
a warning threshold that is\n\
set by the system administrator.\n"
quota_warn_threshold Type: string* Default: 0
This option is expanded in the same way as "quota" (see above). If the
resulting value is greater than zero, and delivery of the message causes
the size of the file or total space in the directory tree to cross the
given threshold, a warning message is sent. If "quota" is also set, the
threshold may be specified as a percentage of it by following the value
with a percent sign. For example:
quota = 10M
quota_warn_threshold = 75%
If "quota" is not set, a setting of "quota_warn_threshold" that ends with
a percent sign is ignored.
The warning message itself is specified by the "quota_warn_message"
option, and it must start with a To: header line containing the
recipient(s). A Subject: line should also normally be supplied. The
"quota" option does not have to be set in order to use this option; they
are independent of one another except when the threshold is specified as a
percentage.
--
Jez Hancock
- System Administrator / PHP Developer
http://munk.nu/
http://jez.hancock-family.com/ - personal weblog
http://ipfwstats.sf.net/ - ipfw peruser traffic logging
More information about the freebsd-questions
mailing list