File: //opt/sharedrads/setmaxemails
#!/bin/bash
# Sets max_emails_per_hour for a user
# Updated by Laura S. 12/8/2023
# checks for input
if [ "$1" == "" ];
then
echo ""
echo "Missing user name..."
exit 1
elif ! /bin/ls -A /var/cpanel/users/"$1" > /dev/null 2>&1;
then
echo ""
echo "User does not exist"
exit 1
elif [ "$2" == "" ];
then
echo ""
echo "You need to specify an hourly limit"
exit 1
elif [ "$2" -gt "750" ];
then
echo ""
echo "You are not allowed to set maxemails higher than 750 - please ask a system admin"
exit 1
# sets limit
elif grep MAX_EMAIL_PER_HOUR /var/cpanel/users/"$1" >/dev/null
then
echo ""
sed -e '/MAX_EMAIL_PER_HOUR/d' -i /var/cpanel/users/"$1" >/dev/null
echo "MAX_EMAIL_PER_HOUR=$2" >> /var/cpanel/users/"$1"
/scripts/updateuserdomains
echo "$1 enabled to send up to $2 emails per hour"
touch /home/"$1"/.senderlimit /home/"$1"/.imh/.exim_bulk && echo "$2" > /home/"$1"/.senderlimit
echo ""
else
echo ""
echo "MAX_EMAIL_PER_HOUR=$2" >> /var/cpanel/users/"$1"
/scripts/updateuserdomains
echo "$1 added to send up to $2 emails per hour"
touch /home/"$1"/.senderlimit /home/"$1"/.imh/.exim_bulk && echo "$2" > /home/"$1"/.senderlimit
fi