#!/bin/sh
### Copyright 1999-2026. WebPros International GmbH. All rights reserved.

export PATH=/bin:/usr/bin

recipient="$1"

if [ -z "$recipient" ]; then
	echo "User was not specified."
	exit 1
fi

msg_path="/var/qmail/mailnames/.quotawarnmsg"

if [ ! -f "$msg_path" ]; then
	echo "Unable to find warning report message '$msg_path'"
	exit 1
fi

sender_domain="`hostname -f`"
sender="postmaster@$sender_domain"
date="`date --rfc-2822`"

cat $msg_path | \
	sed -e "s|@SENDER@|$sender|" \
	    -e "s|@RECIPIENT@|$recipient|" \
		-e "s|@DATE@|$date|" \
	| /usr/lib/dovecot/dovecot-lda -d $recipient -o quota_enforce=no
