How to block a user from sending emails

You may come to a situation where you want to block a user from sending emails. You don’t want to block the ability to check for emails, only the ability to sent emails.

DirectAdmin through SpamBlocker has 3 blocking files that you can use:


Once the username is on /etc/virtual/blacklist_usernames, no emails can be sent – via SMTP or via a PHP script on the server. The user will be able to access the control panel, email accounts but will not be able to send emails.

– /etc/virtual/blacklist_usernames (does not need to exist). Must contain a DA Username, eg “fred” followed by the unix time it was added to the blacklist, eg: fred:1409557166 (may change it to be fred:1409557166:more=info&in=the&url=format, which won’t affect exim as it stops at the first : character) Will drop authorized smtp connections if DA User is in that file for the given smtp auth id (username or Also applies to script based sends.. email will not make it into the queue, will be discarded and message logged to mainlog.

The command to use is:

echo "USERNAME:`date +%s`" >> /etc/virtual/blacklist_usernames

If the file doesn’t exist it will be created automatically by the above command. If you’ll try to send an email from the webmail, you will see a message like:

SMTP Error (550): Failed to add recipient “” (User account (plothost16) is not allowed to send emails. E-Mail delivery blocked.).

SMTP warning message

The same thing will happen if you are using an SMTP client like Microsoft Outlook or Mozilla Thunderbird:

block user email 1
Sending emails is blocked in DirectAdmin

The two other files that you can use (added in DirectAdmin SpamBlocker 4.4.6) are:

 /etc/virtual/blacklist_smtp_usernames – for blocking only SMTP access; the file allows the use of usernames or specific email addresses.

/etc/virtual/blacklist_script_usernames – for blocking only scripts by specific users; the file should contain the usernames.

DirectAdmin clarifies the addition of the two new blocking files:

 The SMTP/SCRIPT versions are used for specific items, while BLACKLIST_USERNAMES still blocks both, so you never need to add Users to more than 1 of the 3 files.

SpamBlocker changelog

Leave a Reply