How to know mail server domain linux command line

To find the mail server domain from the Linux command line, you can use the following commands:

  1. dig command:

    dig mx example.com

    Replace example.com with the domain name you want to check. This command will show you the mail exchange (MX) records for the domain, which will include the mail server domain.

  2. host command:

    host -t mx example.com

    This command is similar to the dig command, but it's a bit more concise.

  3. nslookup command:

    nslookup -type=mx example.com

    This command is another way to query the DNS server for the MX records of a domain.

  4. getent command:

    getent astream example.com

    This command will show you the MX records for the domain, including the mail server domain.

  5. postconf command:

    postconf -n mydestination

    This command will show you the value of the mydestination parameter, which is the mail server domain.

Note: The postconf command is specific to Postfix, a popular mail server software. If you're using a different mail server software, you may need to use a different command.

These commands will help you find the mail server domain for a given domain name.