Did you add the subdomain as the main domain in its own DirectAdmin account, or is it added as a subdomain beneath an existing DirectAdmin account?
If you added it as the main domain of its own DirectAdmin account, then you should be able to treat it like main domain in that it will have its own DNS zone file. For example, I created a new DA user account for
user@box:~$ dig mx +short test.domain.tld
10 mail.test.domain.tld
user@box:~$ dig a +short mail.test.domain.tld.
108.XX.XX.XXX
user@box:~$
So, in this case, using the API command, you should theoretically be able to use this:
Code:
domain=subdomain.domain1.com
Note that the domain= portion determines the name of the DNS zone file, so in this instance, it would have its own and be looking for /var/named/subdomain.domain1.com.db.
If you added it as a subdomain beneath an existing account as that main domain's subdomain, then it will typically use the main domain's MX records. It won't have its own zone file. You may be able to edit the main domain's zone file to add a MX record for the subdomain if you want it to use a different mail server than the main domain. If you want the subdomain to use a local mailserver while the main domain uses a remote mailserver, you may need to adjust the MX records accordingly, and check that /etc/virtual/domains contains an entry for the subdomain (since this file is responsible to routing mail locally in addition to the MX record itself.
In this case, using the API command, you should be able to format your POST string like this:
Post string:
Code:
domain=domain1.com&type=MX&name=subdomain.domain1.com.&value=20&mx_value=target.domain2.com&ttl=14400&affect_pointers=yes&json=yes&action=add
You can determine your own POST strings by running a trial run of the action you need to perform in DirectAdmin while it's running in debug mode:
https://help.directadmin.com/item.php?id=293
Also, I prefer to test my API commands via curl:
https://help.directadmin.com/item.php?id=580
You may want to test thoroughly following setup.