#!/bin/bash
PERCENT=$1
USER=$2
DOMAIN=${USER##*@}

if [ "$PERCENT" -eq '95' ] ; then
  MSG="Your mailbox is now $PERCENT% full. Please delete some messages immediately to avoid email service interruptions."
else
  MSG="Your mailbox is now $PERCENT% full. Please delete some messages to avoid exceeding your quota."
fi

echo "$MSG" | mail -s "Email quota warning" $USER -aFrom:postmaster@$DOMAIN