Featured Posts

Breaking News

How to Set Mail Server in DirectAdmin?

 In this tutorial, we are going to see how to set the mail server in DirectAdmin.

DirectAdmin helps the client for the easier administration of their websites, as it has a graphical web-based control panel. DirectAdmin is usually referred to as “DA” in the web hosting industry. They are mainly adaptable with Linux operating system, and the versions in which they are compatible are CloudLinux, Red Hat, Fedora Core, Red Hat Enterprise, CentOS, FreeBSD, Ubuntu, and Debian. In comparison with cPanel, DirectAdmin uses fewer server resources.

An e-mail server is a system that sends and receives e-mails using standard e-mail protocols through the internet. The server stores incoming mail for distribution to local users and sends out outgoing messages. It uses a client-server application model to send and receive messages using the Simple Mail Transfer Protocol (SMTP). The SMTP is a communication protocol commonly used by e-mail servers for e-mail transmission. An e-mail server can receive mail from a client system and can deliver it to another mail server or a client system based on the requirement.

Setup the Mail System in DirectAdmin

  1. To set up the mail system in DirectAdmin, the client needs to follow the below rules. The domain and hostname used on the system should be different.
  2. We need to add the hostname in /etc/virtual/domains file.
  3. Do not add the hostname details in/etc/virtual/domainowners file.
  4. The hostname must resolve. If not, then we need to add the A record into the DNS zone such that the hostname resolves.
  5. The directory /etc/virtual/<hostname> must be available in the server without any files under that.
  6. We need to add the details of the domain, which is used by the mail system in both the /etc/virtual/domains file and the /etc/virtual/domainowners file. Furthermore, the system must have /etc/virtual/<domain> file, /etc/virtual/<domain>/passwd and /etc/virtual/<domain>/aliases files.
  7. File permission of the virtual pop inboxes should be set as below (excluding Dovecot/Maildir):

/var/spool/virtual/<domain> 770 username:mail

/var/spool/virtual/<domain>/* 660 username:mail 

8. Ensure that the hostname is not having any uppercase letters.

9. Ensure that the main server IP has set reverse lookup on it.

HOW TO REBUILD /ETC/VIRTUAL/DOMAINOWNERS FILE, IF IT IS EMPTY

Create a script under /etc/virtual folder with the name fix_domainowners.sh.

cd /etc/virtuals

vi fix_domainowners.sh

Press “i” to go into insert mode and update the below code into it.

#!/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

 { 

echo “$d: $u” for p in `cat /usr/local/directadmin/data/users/$u/domains/$d.pointers | cut -d= -f1 2>/dev/null`; do { echo “$p: $u” 

}

 done; 

} done; 

} done;

Exit insert mode (ctrl+c), then save and exit (click shift+Z twice) the file. Then run the below code in the command prompt:


chmod 755 fix_domainowners.sh

 ./fix_domainowners.sh > domainowners

 chmod 644 domainowners 

chown mail:mail domainowners

SET EXTERNAL/REMOTE MAIL SERVER IN DIRECTADMIN


Instead of the local mail server, if a client wants to use an external/remote server as their mail server, then they can follow the below steps.

Log in to the “DirectAdmin” panel and navigate to the “E-mail Manager” section.

Click on the “MX Records” option under the E-mail Manager.




To disable the local Mail server, please uncheck the option “Use this server to handle my e-mails. If not, change the MX records and uncheck this option.” and click the “Save” button.

To point to the external mail server, delete the existing MX record first and then add “other.domain.com” (remote server) as the new MX record under the “Add another MX record” tab.

Note: If you do not have the MX Records menu in your DirectAdmin User Level login, then ask your hosting provider to enable the DNS Control option for your account.

DISABLE LOCAL MAIL SERVER BY DEFAULT FOR NEW DOMAINS

If all the newly created domains have their mail server in remote, then we can disable the local mail server by default with the help of domain_create_post.sh script.

Create 

/usr/local/directadmin/scripts/custom/domain_create_post.sh script by adding the below code into it.


#!/bin/sh FILE=/etc/virtual/domains cp -f $

FILE $FILE.backup 

grep -v -e "^$domain\$" $FILE > $FILE.tmp

 mv -f $FILE.tmp $FILE 

chmod 644 $FILE 

chown mail:mail $FILE

 exit 0;

Save and exit the code and change the chmod of the script to 755.

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

Note: Any newly created domains after this point should not be in the /etc/virtual/domains. Also, we need to copy /usr/local/directadmin/data/templates/dns_mx.conf to a custom folder in the same directory and then edit the custom/dns_mx.conf for the correct default values.

CREATE AN E-MAIL ACCOUNT THAT DELETES INCOMING MAIL


If a client wants to create an e-mail account that deletes all the incoming e-mails, then they can create a forwarder and then send it to:

:blackhole:

Or

:fail:

Note:-

:blackhole: will accept the e-mail, but will not save it.

:fail: will send a fail message to the sender

The above has the same functionality as that of a catch-all e-mail account. A catch-all e-mail account is an address that receives all messages which addressed to an incorrect or non-existing e-mail address for that domain.

If you need any further help, please do reach our support department.

-----‐--------------‐------------------‐-------------‐----------‐--------

  WordPress Hosting @ Rs.99
GOOLHOST.COM




No comments