Quata-VDA
-------
Updated Postfix + VDA (maildir++ quota support) for Centos/RHEL 6 packages
I've uploaded them to packagecloud.io so anyone could use them: https://packagecloud.io/nstorm/postfix-vda-el6
Installing these packages are as easy, as running couple of commands to add a custom repo and install a package, thanks to packagecloud.io (https://packagecloud.io/nstorm/postfix-vda-el6/install):
CODE: SELECT ALL
curl -s https://packagecloud.io/install/repositories/nstorm/postfix-vda-el6/script.rpm.sh | sudo bash
Then you just install postfix and optionally perl scripts:
CODE: SELECT ALL
yum install postfix postfix-perl-scripts
Source RPM are also available on packagecloud.io.
----------------------------------------------------------------------------------------------------------------------------------------------------
quick install
curl -s https://packagecloud.io/install/repositories/nstorm/postfix-vda-el6/script.deb.sh | sudo bash
full script.deb.sh
----
#!/bin/bash unknown_os () { echo "Unfortunately, your operating system distribution and version are not supported by this script." echo echo "You can override the OS detection by setting os= and dist= prior to running this script." echo "You can find a list of supported OSes and distributions on our website: https://packagecloud.io/docs#os_distro_version" echo echo "For example, to force Ubuntu Trusty: os=ubuntu dist=trusty ./script.sh" echo echo "Please email support@packagecloud.io and let us know if you run into any issues." exit 1 } curl_check () { echo "Checking for curl..." if command -v curl > /dev/null; then echo "Detected curl..." else echo "Installing curl..." apt-get install -q -y curl fi } install_debian_keyring () { if [ "${os}" = "debian" ]; then echo "Installing debian-archive-keyring which is needed for installing " echo "apt-transport-https on many Debian systems." apt-get install -y debian-archive-keyring &> /dev/null fi } detect_os () { if [[ ( -z "${os}" ) && ( -z "${dist}" ) ]]; then # some systems dont have lsb-release yet have the lsb_release binary and # vice-versa if [ -e /etc/lsb-release ]; then . /etc/lsb-release if [ "${ID}" = "raspbian" ]; then os=${ID} dist=`cut --delimiter='.' -f1 /etc/debian_version` else os=${DISTRIB_ID} dist=${DISTRIB_CODENAME} if [ -z "$dist" ]; then dist=${DISTRIB_RELEASE} fi fi elif [ `which lsb_release 2>/dev/null` ]; then dist=`lsb_release -c | cut -f2` os=`lsb_release -i | cut -f2 | awk '{ print tolower($1) }'` elif [ -e /etc/debian_version ]; then # some Debians have jessie/sid in their /etc/debian_version # while others have '6.0.7' os=`cat /etc/issue | head -1 | awk '{ print tolower($1) }'` if grep -q '/' /etc/debian_version; then dist=`cut --delimiter='/' -f1 /etc/debian_version` else dist=`cut --delimiter='.' -f1 /etc/debian_version` fi else unknown_os fi fi if [ -z "$dist" ]; then unknown_os fi # remove whitespace from OS and dist name os="${os// /}" dist="${dist// /}" echo "Detected operating system as $os/$dist." } main () { detect_os curl_check # Need to first run apt-get update so that apt-transport-https can be # installed echo -n "Running apt-get update... " apt-get update &> /dev/null echo "done." # Install the debian-archive-keyring package on debian systems so that # apt-transport-https can be installed next install_debian_keyring echo -n "Installing apt-transport-https... " apt-get install -y apt-transport-https &> /dev/null echo "done." gpg_key_url="https://packagecloud.io/nstorm/postfix-vda-el6/gpgkey" apt_config_url="https://packagecloud.io/install/repositories/nstorm/postfix-vda-el6/config_file.list?os=${os}&dist=${dist}&source=script" apt_source_path="/etc/apt/sources.list.d/nstorm_postfix-vda-el6.list" echo -n "Installing $apt_source_path..." # create an apt config file for this repository curl -sSf "${apt_config_url}" > $apt_source_path curl_exit_code=$? if [ "$curl_exit_code" = "22" ]; then echo echo echo -n "Unable to download repo config from: " echo "${apt_config_url}" echo echo "This usually happens if your operating system is not supported by " echo "packagecloud.io, or this script's OS detection failed." echo echo "You can override the OS detection by setting os= and dist= prior to running this script." echo "You can find a list of supported OSes and distributions on our website: https://packagecloud.io/docs#os_distro_version" echo echo "For example, to force Ubuntu Trusty: os=ubuntu dist=trusty ./script.sh" echo echo "If you are running a supported OS, please email support@packagecloud.io and report this." [ -e $apt_source_path ] && rm $apt_source_path exit 1 elif [ "$curl_exit_code" = "35" ]; then echo "curl is unable to connect to packagecloud.io over TLS when running: " echo " curl ${apt_config_url}" echo "This is usually due to one of two things:" echo echo " 1.) Missing CA root certificates (make sure the ca-certificates package is installed)" echo " 2.) An old version of libssl. Try upgrading libssl on your system to a more recent version" echo echo "Contact support@packagecloud.io with information about your system for help." [ -e $apt_source_path ] && rm $apt_source_path exit 1 elif [ "$curl_exit_code" -gt "0" ]; then echo echo "Unable to run: " echo " curl ${apt_config_url}" echo echo "Double check your curl installation and try again." [ -e $apt_source_path ] && rm $apt_source_path exit 1 else echo "done." fi echo -n "Importing packagecloud gpg key... " # import the gpg key curl -L "${gpg_key_url}" 2> /dev/null | apt-key add - &>/dev/null echo "done." echo -n "Running apt-get update... " # update apt on this system apt-get update &> /dev/null echo "done." echo echo "The repository is setup! You can now install packages." } main
-----
Configure Postfix VDA
1. Edit the postfix configuration file /etc/postfix/main.cf and add the lines below
virtual_mailbox_limit_override = yes virtual_overquota_bounce = yes virtual_mailbox_limit_maps = hash:/etc/postfix/vquota
2. Create the file /etc/postfix/vquota containing the mapping from an email address to the maximum mailbox quota in bytes. If you wish to be exact, 1KB equals 1024 bytes while 1MB equals 1024KB or 1048576 bytes.
johndoe@acme.local 10485760 janedoe@acme.local 2097152
John Doe got a 10MB quota while Jane Doe got 2MB.
After creating this file, execute postmap /etc/postfix/vquota. This will generate/etc/postfix/vquota.db, the actual file that will be used for the lookup.
--------
POSTFIX VDA
Features
Brings per mailbox/maildir quota support to Postfix VDA
Support for Courier style maildir format, including maildirsize file
Limit either only INBOX or whole maildir
Customizable bounce message, used if mails are bounced (it's also an option)
Customisable suffix for Maildir support, sometimes needed for Courier IMAP
Enhanced patch delivery abilities using vfilter
News (ChangeLog)
2016-03-23: New patches for 2.10.x
2014-10-08: Dropped support for 2.6.x
2014-10-08: New patches for 2.9.0 - 2.9.9 added, it's new version v12! See ChangeLog for details
2013-06-07: Patch for 2.10.0 added
Support
Our mailing list is used for user queries, development and news - simply everything about this patch.
Feel free to contact us on our mailing list with any questions, feedback, bug report or even patch.
Subscribe to our mailing list, or see the list archive .
Download
If you are not able to find the proper patch bellow, you can try to apply the older version to the new Postfix source tree
by using command "patch -p0 < vda-patch-file"
Available options and examples
These are only the options available in our VDA patch. Look into the Postfix documentation to see how to setup Postfix
to use virtual transport. If you use other transport than virtual, this patch is not for you.
# Basic map of the maildir/mailbox quotas # Default: not set virtual_mailbox_limit_maps = hash:/etc/postfix/vquota # Limit only inbox or whole maildir? # Default: no virtual_mailbox_limit_inbox = no # If set to 'no' and if the delivered message size is smaller than # message_size_limit (see Postfix doc for details), the quota will # be set to virtual_mailbox_limit (see Postfix doc for details) # So, this enables limits smaller than maximum message size. # Default: yes virtual_mailbox_limit_override = yes # Do we use Courier maildir++ quotas? # Default: no virtual_maildir_extended = yes # Will the message be bounced with 5xx code when user over quota? Otherwise # the temporary failure 4xx will raise and message will be queued # Default: no virtual_overquota_bounce = yes # When set, the per recipient limit message is search in the map, otherwise # the message in 'virtual_maildir_limit_message' is used # Default: not set virtual_maildir_limit_message_maps = hash:/etc/postfix/limit_messages # This message is used when the user is over quota and if the # 'virtual_maildir_limit_message_maps' is not set. # This is the per server message, unlike the # 'virtual_maildir_limit_message' - that's the per recipient message. # If both are set, the 'virtual_maildir_limit_message_maps' will precede # and this option will not be used. # Default: "Sorry, the user's maildir has overdrawn his diskspace quota, please try again later." virtual_maildir_limit_message = "User over quota, try again" # Suffix added to the maildir/mailbox path, used motly with Courier, because # Courier reads the messages from the [path]/Maildir/ directory # Default: not set virtual_maildir_suffix = "Maildir/" # Will we count the trash folder (see the 'virtual_trash_name' option) # to the sum of the quota? # Default: no virtual_trash_count = yes # The name of of the trash folder (important for 'virtual_trash_count' option) # Default: ".Trash" virtual_trash_name = ".Trash" # Do we use virtual maildir filter rules? # Default: no virtual_maildir_filter = no # The per user maildir filter map # Default: not set virtual_maildir_filter_maps = hash:/etc/postfix/vfilter #######################################################################################################################################################
virtual_mailbox_limit_maps = hash:/etc/postfix/vquota virtual_mailbox_limit_inbox = no virtual_mailbox_limit_override = yes virtual_maildir_extended = yes virtual_overquota_bounce = yes virtual_maildir_limit_message_maps = hash:/etc/postfix/limit_messages virtual_maildir_limit_message = "User over quota, try again" virtual_maildir_suffix = "Maildir/" virtual_trash_count = yes virtual_trash_name = ".Trash" virtual_maildir_filter = no virtual_maildir_filter_maps = hash:/etc/postfix/vfilter
######################################################################################### ------------------------------------------------------------------------- # This is example of hash file of virtual_mailbox_maps directive # # This is for maibox users user1@domain.com.br com/d/do/domain.com.br/user1 user2@domain.com.br com/d/do/domain.com.br/user2 # This is for Maidir users user1@domain.net.br net/d/do/domain.net.br/user1/ user2@domain.net.br net/d/do/domain.net.br/user2/ ------------------------------------------------------------------------- ------------------------------------------------------------------------- # This is example of hash file of virtual_mailbox_limit_maps directive # Every quota in this file is in bytes # user1@domain.com.br 2048000 user2@domain.com.br 2048000 user1@domain.net.br 5192000 # this user has no limit user2@domain.net.br 0 -------------------------------------------------------------------------