awahqn 0 Newbie Poster

Hi,

I dont know if this is the right place to ask but I hope I find and answer to my question. I have two vps servers. One with the main domain name (example.com) and the other is serving mail.example.com. The example.com is serving the web server while the mail.example.com is serving the mail server and the mail client (roundcube). Now what I need help with is setting up the right DNS records to forward all the emails coming to example.com to mail.example.com droplet. So like the mail server is kinda working now and it can send emails. these are the current dns reccords of my example.com:

$TTL    1800
@       IN  SOA NS1.DIGITALOCEAN.COM.   hostmaster.goodwindows.org. (
            1402913331 ; last update: 2014-06-16 10:08:51 UTC
            3600 ; refresh
            900 ; retry
            1209600 ; expire
            1800 ; ttl
            )
             IN      NS      NS1.DIGITALOCEAN.COM.
                     NS      NS2.DIGITALOCEAN.COM.
                     NS      NS3.DIGITALOCEAN.COM.
            MX 0    mail.goodwindows.org.
            MX 10   @
@   IN A    107.170.142.45
www CNAME   @
mail    IN A    107.170.232.141
*   CNAME   @

and this is the dns records for mail.example.com

$TTL    1800
@       IN  SOA NS1.DIGITALOCEAN.COM.   hostmaster.mail.goodwindows.org. (
            1402885887 ; last update: 2014-06-16 02:31:27 UTC
            3600 ; refresh
            900 ; retry
            1209600 ; expire
            1800 ; ttl
            )
             IN      NS      NS1.DIGITALOCEAN.COM.
                     NS      NS2.DIGITALOCEAN.COM.
                     NS      NS3.DIGITALOCEAN.COM.
@   IN A    107.170.232.141

So what should I do? any help will be more than appreciated!

Dani AI

Generated

Short answer for : point all example.com mail to your mail host (mail.example.com) by making the domain’s MX record(s) reference that subdomain only, and remove the MX that points back to the web server. That ensures incoming SMTP delivery lands on the mail droplet. Keep a single authoritative A record for mail.example.com (usually in the main example.com zone unless you intentionally delegated the subdomain).

On the mail server, make sure the MTA is configured to accept and deliver mail for example.com (add the domain to your local/virtual domains list). Set the server hostname to the mail host (used in HELO/EHLO) and ensure the droplet’s reverse DNS (PTR) points to that same hostname. Open/allow SMTP ports (25 and submission 587) in the firewall and verify your provider isn’t blocking port 25.

Publish standard mail-auth records to improve deliverability: an SPF TXT that authorizes your mail host or IP, a DKIM public key (selector._domainkey), and a DMARC policy for reporting. Example SPF template (replace with your real IP/hosts):

example.com. TXT "v=spf1 a mx ip4:YOUR.MAIL.IP -all"

Quick checks and troubleshooting:

dig MX example.com
dig A mail.example.com
dig -x <mail-IP>
telnet mail.example.com 25
openssl s_client -starttls smtp -crlf -connect mail.example.com:587

If mail still bounces, check mail logs for rejection reasons, confirm your MTA is listed to handle example.com (mydestination/virtual in Postfix or equivalent), and inspect message headers to see which host answered. Remove or be cautious with wildcard CNAMEs (they can complicate lookups for unspecified subdomains) and avoid keeping a fallback MX that points to the web server unless that host actually accepts mail for the domain.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.