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

Related Articles

Email Client Configuration & Dovecot Quota/Monitoring Guide for DirectAdmin Users

This guide explains how to configure popular email clients (iPhone Mail, Thunderbird, Gmail POP/SMTP), enable Dovecot LMTP quota warnings, and check the last login time for all email accounts on a DirectAdmin server. It includes step by step instructions, recommended IMAP/SMTP settings, and useful administrative scripts.

Continue

Troubleshooting Dovecot in DirectAdmin – Fixing IMAP Errors, Authentication Issues, and SSL Certificate Checks

Dovecot is the IMAP/POP3 server used by DirectAdmin. Sometimes users encounter errors such as “Connection dropped by IMAP server” or “unknown user” during authentication. This guide explains how to fix corrupted Dovecot indexes, understand authentication logs, hide unnecessary warnings, and manually inspect SSL certificates on IMAP ports 143 and 993.

Continue

DNS Troubleshooting in DirectAdmin – When named is Running but Domains Do Not Resolve

Sometimes the named (BIND) service runs normally, yet DNS queries fail or domains do not resolve from outside. This guide provides a complete troubleshooting workflow for checking named listeners, firewall rules, named.conf configuration, DNS propagation issues, subdomain problems, resolv.conf errors, and common Apache/Nginx misconfigurations.

Continue

Managing DNS Records in DirectAdmin – Complete Practical Guide for Administrators

DirectAdmin provides a powerful DNS management system that allows administrators to control TTL values, create SRV records, enable DNSSEC, manage subdomain delegation, automate TLSA records, and perform mass DNS updates. This guide explains all essential DNS operations in DirectAdmin with real-world examples and best practices.

Continue

DNS and Nameservers in DirectAdmin – Complete, Practical, and Professional Guide

DNS is the backbone of the internet, responsible for translating domain names into IP addresses. DirectAdmin allows you to create private nameservers (ns1/ns2), manage DNS zones, configure DNS clustering, use external DNS, and troubleshoot common issues. This guide provides a complete, clear, and practical explanation of DNS concepts and their implementation in DirectAdmin.

Continue

CustomBuild in DirectAdmin – Complete Guide to Installation, Updates, Configuration, and Advanced Customization

CustomBuild is DirectAdmin’s primary software management system. It installs, updates, configures, and rebuilds essential services such as Apache, Nginx, PHP, MariaDB/MySQL, Exim, Dovecot, FTP servers, and more. Because most components are compiled from source, CustomBuild offers exceptional flexibility, fast access to new versions, and optimized performance.

Continue