Disable the default (System) email account for new domains


Enter Your Query:
Use '%' for wildcards and quotes for "exact phrases"


Top Level » Email

Disable the default (System) email account for new domainsLast Modified: Jul 31, 2013, 3:08 pm
Since there will always be a system email account with any new DA User, sometimes Admin's do not wish it to be active, as many clients simply don't know it's there or don't use it. It can then fill up with a lot of email, causing disk usage issues.

One solution is to disable the account for any domain created under that User.  Note that the actual username@host.name.com value will still be active (can be disabled in /etc/aliases if you really want), but for the most part, disabling the alias username@domain.com -> username@host.name.com will be sufficient for most cases.

The username@domain.com is actually a forwarder to the hostname, so in this guide we're just going to disable that forwarder.

1) Create the following script:

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

and in it, add the following code:

#!/bin/sh
STR="perl -pi -e 's#^$username:[ ]*$username\$#$username: :fail:#' /etc/virtual/$domain/aliases"
eval $STR;
exit 0;


2) Chmod the script to 755:

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


3) You can manually test the script, and/or run it for existing accounts as follows:

cd /usr/local/directadmin/scripts/custom
username=fred domain=fredsdomain.com ./domain_create_post.sh

which does require a shell, like bash that supports setting variables in that manner.


4) Expanding on tip #3, you can run this for all existing accounts automatically with this script:


#!/bin/sh
for u in `ls /usr/local/directadmin/data/users`; do
{
      for d in `cat /usr/local/directadmin/data/users/$u/domains.list`; do
      {
             username=$u domain=$d /usr/local/directadmin/scripts/custom/domain_create_post.sh
      };
      done;
};
done;
exit 0;



 
Related Helpfiles
Disable "Local Mail Server" by default for new domains
Why is there a system email account for all domains I create?

© 2018 JBMC Software, Suite 173  3-11 Bellerose Drive, St Albert, AB  T8N 1P7  Canada.  Mon-Fri 9AM-5PM MST