Complete Guide to User-Level Customization in DirectAdmin: Backup Limits, Email Restrictions, Template Editing, and Email-Only Systems

This article provides a comprehensive guide to customizing user behavior in DirectAdmin. It covers limiting the number of backups per user, enforcing email quota restrictions, blocking specific email usernames, customizing IMAP/POP/SMTP settings, managing daily email limits through packages, and building an email only hosting environment using DirectAdmin’s hooks, templates, and API.

Level Customization in DirectAdminBackup LimitsTemplate Editing

~3 min read • Updated Mar 1, 2026

1. Limiting the Number of Backups per User


If you want to restrict how many backups a user can create (e.g., a maximum of 5), create the following script:

/usr/local/directadmin/scripts/custom/user_backup_pre.sh

Content:

#!/bin/sh
MAX_BACKUPS=5
U=`echo $file | cut -d/ -f3`
if [ "$U" != "$username" ]; then
   exit 0;
fi
C=`ls /home/$username/backups | wc -l`
if [ "$C" -ge "$MAX_BACKUPS" ]; then
   echo "Too many backups. Delete some from /home/$username/backups before creating another.";
   exit 1;
fi
exit 0;

Make it executable:

chmod 755 /usr/local/directadmin/scripts/custom/user_backup_pre.sh

You can test it manually:

file=/home/fred/backups/backup.tar.gz username=fred ./user_backup_pre.sh; echo $?;
---

2. Limiting Email Quota per Account


To prevent users from setting an email quota higher than 50MB, create:

/usr/local/directadmin/scripts/custom/email_create_pre.sh

Content:

#!/bin/sh
if [ "$quota" != "" ]; then
   if [ "$quota" -gt "50" ]; then
       echo "Cannot set quota greater than 50MB";
       exit 1;
   fi
fi
exit 0;

Make executable and link to modification hook:


cd /usr/local/directadmin/scripts/custom/
chmod 755 email_create_pre.sh
ln -s email_create_pre.sh email_change_pass_pre.sh
---

3. Preventing Certain Email Usernames


To block creation of sensitive email names like root, webmaster, or postmaster, use:

/usr/local/directadmin/scripts/custom/all_pre.sh

Content:

#!/bin/sh

blockaccount()
{
   if [ "$user" = "$1" ] || [ "$newuser" = "$1" ]; then
      echo "You cannot create an account named $1";
      exit 1;
   fi
}

if [ "$command" = "/CMD_EMAIL_POP" ]; then
   if [ "$action" = "create" ] || [ "$action" = "modify" ]; then
      blockaccount root;
      blockaccount webmaster;
      blockaccount postmaster;
   fi
fi
exit 0;

Make executable:

chmod 755 /usr/local/directadmin/scripts/custom/all_pre.sh
---

4. Customizing IMAP/POP/SMTP Settings Shown After Email Creation


You can modify the template that displays connection settings after an email account is created:


cd /usr/local/directadmin/data/templates/custom
cp ../mail_settings.html .
vi mail_settings.html

Common use case:

  • Replace mail.|DOMAIN| with server.yourhostname.com for global SSL setups.

Language Tokens

Instead of editing English text directly, use |LANG_*| tokens.

Language strings are stored in:

/usr/local/directadmin/data/skins/enhanced/lang/en/internal/email.txt
---

5. Customizing Daily Email Limits Based on Package


New Method (Recommended)

Packages now support:

email_daily_limit=-1

Meaning:

  • -1 → use global default (/etc/virtual/limit)
  • unlimited → no limit (not recommended)

Per-user limits are stored in:

/etc/virtual/limit_USERNAME

Updating a package automatically updates all users assigned to it.

---

6. Old Method: Using Custom Package Items


Create a custom package item named user_email_limit, then create:

/usr/local/directadmin/scripts/custom/user_create_post.sh

Content:

#!/bin/sh
if [ "$user_email_limit" != "" ] && [[ $user_email_limit =~ ^-?[0-9]+$ ]] && [ "$user_email_limit" -gt 0 ]; then
    echo -n "$user_email_limit" > /etc/virtual/limit_$username
fi
exit 0;

Make executable:

chmod 755 /usr/local/directadmin/scripts/custom/user_create_post.sh
---

7. Creating an Email Only System


Option 1: Using DirectAdmin’s Built In System (Simplest)

  1. Create a custom skin:

cd /usr/local/directadmin/data/skins
cp -Rp enhanced emailonly

Remove FileManager and other non email features.

  1. Create a package with all non email features disabled (FTP=0, DB=0, etc.)
  2. Use all_pre.sh or commands.allow to restrict access to email related commands only.

This ensures users cannot bypass restrictions using custom forms or API calls.

Option 2: Build Your Own Interface Using the DirectAdmin API

You can create your own login system and UI using PHP, and interact with DirectAdmin exclusively through its API.


Written & researched by Dr. Shahin Siami