remove the copy button, use CNAME for DKIM
This commit is contained in:
parent
625def2367
commit
6a42673229
|
@ -28,19 +28,21 @@
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="mb-2">Add the following MX DNS record to your domain. <br>
|
<div class="mb-2">Add the following MX DNS record to your domain. <br>
|
||||||
Please note that there's a point (<em>.</em>) at the end target addresses. <br>
|
Please note that there's a point (<em>.</em>) at the end target addresses.
|
||||||
|
This is to make sure the <i>absolute</i> address is used.
|
||||||
|
<br>
|
||||||
Also some domain registrars (Namecheap, CloudFlare, etc) might use <em>@</em> for the root domain.
|
Also some domain registrars (Namecheap, CloudFlare, etc) might use <em>@</em> for the root domain.
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{% for priority, email_server in EMAIL_SERVERS_WITH_PRIORITY %}
|
{% for priority, email_server in EMAIL_SERVERS_WITH_PRIORITY %}
|
||||||
<div class="mb-3 p-3" style="background-color: #eee">
|
<div class="mb-3 p-3" style="background-color: #eee">
|
||||||
Domain: <em>{{ custom_domain.domain }}</em> or <em>@</em> <br>
|
Record: MX <br>
|
||||||
|
Domain: {{ custom_domain.domain }} or @ <br>
|
||||||
Priority: {{ priority }} <br>
|
Priority: {{ priority }} <br>
|
||||||
Target: <em>{{ email_server }}</em>
|
Target: <em data-toggle="tooltip"
|
||||||
<button class="ml-4 clipboard btn btn-sm btn-outline-success" data-clipboard-action="copy"
|
title="Click to copy"
|
||||||
data-clipboard-text="{{ email_server }}">
|
class="clipboard"
|
||||||
Copy <i class="fe fe-clipboard"></i>
|
data-clipboard-text="{{ email_server }}">{{ email_server }}</em>
|
||||||
</button>
|
|
||||||
</div>
|
</div>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
|
||||||
|
@ -93,18 +95,18 @@
|
||||||
Setting up SPF is highly recommended to reduce the chance your emails ending up in the recipient's Spam folder.
|
Setting up SPF is highly recommended to reduce the chance your emails ending up in the recipient's Spam folder.
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="mb-2">Add the following TXT DNS record to your domain</div>
|
<div class="mb-2">Add the following TXT DNS record to your domain.</div>
|
||||||
|
|
||||||
<div class="mb-2 p-3" style="background-color: #eee">
|
<div class="mb-2 p-3" style="background-color: #eee">
|
||||||
Domain: <em>{{ custom_domain.domain }}</em> or <em>@</em> <br>
|
Record: TXT <br>
|
||||||
|
Domain: {{ custom_domain.domain }} or @ <br>
|
||||||
Value:
|
Value:
|
||||||
<em>
|
<em data-toggle="tooltip"
|
||||||
|
title="Click to copy"
|
||||||
|
class="clipboard"
|
||||||
|
data-clipboard-text="{{ spf_record }}">
|
||||||
{{ spf_record }}
|
{{ spf_record }}
|
||||||
</em>
|
</em>
|
||||||
<button class="ml-4 clipboard btn btn-sm btn-outline-success" data-clipboard-action="copy"
|
|
||||||
data-clipboard-text="{{ spf_record }}">
|
|
||||||
Copy <i class="fe fe-clipboard"></i>
|
|
||||||
</button>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<form method="post" action="#spf-form">
|
<form method="post" action="#spf-form">
|
||||||
|
@ -158,18 +160,21 @@
|
||||||
Setting up DKIM is highly recommended to reduce the chance your emails ending up in the recipient's Spam folder.
|
Setting up DKIM is highly recommended to reduce the chance your emails ending up in the recipient's Spam folder.
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="mb-2">Add the following TXT DNS record to your domain</div>
|
<div class="mb-2">Add the following CNAME DNS record to your domain.</div>
|
||||||
|
|
||||||
<div class="mb-2 p-3" style="background-color: #eee">
|
<div class="mb-2 p-3" style="background-color: #eee">
|
||||||
Domain: <em>dkim._domainkey.{{ custom_domain.domain }}</em> <br>
|
Record: CNAME <br>
|
||||||
|
Domain: <em data-toggle="tooltip"
|
||||||
|
title="Click to copy"
|
||||||
|
class="clipboard"
|
||||||
|
data-clipboard-text="dkim._domainkey.">dkim._domainkey.</em>{{ custom_domain.domain }} <br>
|
||||||
Value:
|
Value:
|
||||||
<em style="overflow-wrap: break-word">
|
<em data-toggle="tooltip"
|
||||||
{{ dkim_record }}
|
title="Click to copy"
|
||||||
|
class="clipboard"
|
||||||
|
data-clipboard-text="{{ dkim_cname }}" style="overflow-wrap: break-word">
|
||||||
|
{{ dkim_cname }}
|
||||||
</em>
|
</em>
|
||||||
<button class="ml-4 clipboard btn btn-sm btn-outline-success" data-clipboard-action="copy"
|
|
||||||
data-clipboard-text="{{ dkim_record }}">
|
|
||||||
Copy <i class="fe fe-clipboard"></i>
|
|
||||||
</button>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<form method="post" action="#dkim-form">
|
<form method="post" action="#dkim-form">
|
||||||
|
@ -189,7 +194,7 @@
|
||||||
<div class="text-danger mt-4">
|
<div class="text-danger mt-4">
|
||||||
Your DNS is not correctly set.
|
Your DNS is not correctly set.
|
||||||
{% if dkim_errors %}
|
{% if dkim_errors %}
|
||||||
The TXT record we obtain for
|
The CNAME record we obtain for
|
||||||
<em>dkim._domainkey.{{ custom_domain.domain }}</em> is:
|
<em>dkim._domainkey.{{ custom_domain.domain }}</em> is:
|
||||||
|
|
||||||
<div class="mb-3 p-3" style="background-color: #eee">
|
<div class="mb-3 p-3" style="background-color: #eee">
|
||||||
|
|
|
@ -8,6 +8,7 @@ from app.dns_utils import (
|
||||||
get_spf_domain,
|
get_spf_domain,
|
||||||
get_dkim_record,
|
get_dkim_record,
|
||||||
get_txt_record,
|
get_txt_record,
|
||||||
|
get_cname_record,
|
||||||
)
|
)
|
||||||
from app.extensions import db
|
from app.extensions import db
|
||||||
from app.models import CustomDomain, Alias
|
from app.models import CustomDomain, Alias
|
||||||
|
@ -21,6 +22,11 @@ def domain_detail_dns(custom_domain_id):
|
||||||
flash("You cannot see this page", "warning")
|
flash("You cannot see this page", "warning")
|
||||||
return redirect(url_for("dashboard.index"))
|
return redirect(url_for("dashboard.index"))
|
||||||
|
|
||||||
|
spf_record = f"v=spf1 include:{EMAIL_DOMAIN} -all"
|
||||||
|
|
||||||
|
# hardcode the DKIM selector here
|
||||||
|
dkim_cname = f"dkim._domainkey.{EMAIL_DOMAIN}"
|
||||||
|
|
||||||
mx_ok = spf_ok = dkim_ok = True
|
mx_ok = spf_ok = dkim_ok = True
|
||||||
mx_errors = spf_errors = dkim_errors = []
|
mx_errors = spf_errors = dkim_errors = []
|
||||||
|
|
||||||
|
@ -67,9 +73,8 @@ def domain_detail_dns(custom_domain_id):
|
||||||
spf_errors = get_txt_record(custom_domain.domain)
|
spf_errors = get_txt_record(custom_domain.domain)
|
||||||
|
|
||||||
elif request.form.get("form-name") == "check-dkim":
|
elif request.form.get("form-name") == "check-dkim":
|
||||||
dkim_record = get_dkim_record(custom_domain.domain)
|
dkim_record = get_cname_record(custom_domain.domain)
|
||||||
correct_dkim_record = f"v=DKIM1; k=rsa; p={DKIM_DNS_VALUE}"
|
if dkim_record == dkim_cname:
|
||||||
if dkim_record == correct_dkim_record:
|
|
||||||
flash("The DKIM is setup correctly.", "success")
|
flash("The DKIM is setup correctly.", "success")
|
||||||
custom_domain.dkim_verified = True
|
custom_domain.dkim_verified = True
|
||||||
db.session.commit()
|
db.session.commit()
|
||||||
|
@ -80,13 +85,9 @@ def domain_detail_dns(custom_domain_id):
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
flash("DKIM: the TXT record is not correctly set", "warning")
|
flash("DKIM: the CNAME record is not correctly set", "warning")
|
||||||
dkim_ok = False
|
dkim_ok = False
|
||||||
dkim_errors = get_txt_record(f"dkim._domainkey.{custom_domain.domain}")
|
dkim_errors = [dkim_record or "[Empty]"]
|
||||||
|
|
||||||
spf_record = f"v=spf1 include:{EMAIL_DOMAIN} -all"
|
|
||||||
|
|
||||||
dkim_record = f"v=DKIM1; k=rsa; p={DKIM_DNS_VALUE}"
|
|
||||||
|
|
||||||
return render_template(
|
return render_template(
|
||||||
"dashboard/domain_detail/dns.html",
|
"dashboard/domain_detail/dns.html",
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
from typing import Optional
|
||||||
|
|
||||||
import dns.resolver
|
import dns.resolver
|
||||||
|
|
||||||
|
|
||||||
|
@ -10,6 +12,19 @@ def _get_dns_resolver():
|
||||||
return my_resolver
|
return my_resolver
|
||||||
|
|
||||||
|
|
||||||
|
def get_cname_record(hostname) -> Optional[str]:
|
||||||
|
"""Return the CNAME record if exists for a domain"""
|
||||||
|
try:
|
||||||
|
answers = _get_dns_resolver().query(hostname, "CNAME")
|
||||||
|
except Exception:
|
||||||
|
return None
|
||||||
|
|
||||||
|
for a in answers:
|
||||||
|
return a
|
||||||
|
|
||||||
|
return None
|
||||||
|
|
||||||
|
|
||||||
def get_mx_domains(hostname) -> [(int, str)]:
|
def get_mx_domains(hostname) -> [(int, str)]:
|
||||||
"""return list of (priority, domain name).
|
"""return list of (priority, domain name).
|
||||||
domain name ends with a "." at the end.
|
domain name ends with a "." at the end.
|
||||||
|
|
Loading…
Reference in a new issue