From 84638ab11e7e793b01bf1452c67a5dffe7daf6ea Mon Sep 17 00:00:00 2001 From: "Robert G. Jakabosky" Date: Sun, 20 Mar 2016 08:19:59 +0800 Subject: [PATCH] Fix creation of custom MX records. --- management/dns_update.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/management/dns_update.py b/management/dns_update.py index 6f4de318..957e8290 100755 --- a/management/dns_update.py +++ b/management/dns_update.py @@ -175,9 +175,6 @@ def build_zone(domain, all_domains, additional_records, www_redirect_domains, en for value in build_sshfp_records(): records.append((None, "SSHFP", value, "Optional. Provides an out-of-band method for verifying an SSH key before connecting. Use 'VerifyHostKeyDNS yes' (or 'VerifyHostKeyDNS ask') when connecting with ssh.")) - # The MX record says where email for the domain should be delivered: Here! - records.append((None, "MX", "10 %s." % env["PRIMARY_HOSTNAME"], "Required. Specifies the hostname (and priority) of the machine that handles @%s mail." % domain)) - # Add DNS records for any subdomains of this domain. We should not have a zone for # both a domain and one of its subdomains. subdomains = [d for d in all_domains if d.endswith("." + domain)] @@ -244,6 +241,10 @@ def build_zone(domain, all_domains, additional_records, www_redirect_domains, en # Don't pin the list of records that has_rec checks against anymore. has_rec_base = records + # The MX record says where email for the domain should be delivered: Here! + if not has_rec(None, "MX"): + records.append((None, "MX", "10 %s." % env["PRIMARY_HOSTNAME"], "Required. Specifies the hostname (and priority) of the machine that handles @%s mail." % domain)) + # SPF record: Permit the box ('mx', see above) to send mail on behalf of # the domain, and no one else. # Skip if the user has set a custom SPF record.