#!/bin/bash

# Report a quota usage warning to a user.
# Dovecot invokes this as: <percent-or-below> %{user}

PERCENT="${1}"
USER="${2}"
DOMAIN="${USER#*@}"

cat << EOF | /usr/lib/dovecot/dovecot-lda -d "${USER}" -o quota_enforce=no
From: postmaster@${DOMAIN}
Subject: quota warning

Your mailbox is now ${PERCENT}% full.
EOF
