1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
# https://www.fastmail.help/hc/en-us/articles/360060591153-Manual-DNS-configuration
# Standard Mail
resource "dnsimple_zone_record" "mx" {
for_each = {
mx1 = { value = "in1-smtp.messagingengine.com", priority = 10 }
mx2 = { value = "in2-smtp.messagingengine.com", priority = 20 }
}
zone_name = var.zone.name
name = ""
value = each.value.value
type = "MX"
priority = each.value.priority
}
# Webmail Login Portal
resource "dnsimple_zone_record" "webmail" {
zone_name = var.zone.name
name = "mail"
value = "mail.fastmail.com"
type = "CNAME"
}
# DKIM
resource "dnsimple_zone_record" "dkim" {
for_each = toset(["fm1", "fm2", "fm3"])
zone_name = var.zone.name
name = "${each.key}._domainkey"
value = "${each.key}.${var.zone.name}.dkim.fmhosted.com"
type = "CNAME"
}
# SPF
resource "dnsimple_zone_record" "spf" {
zone_name = var.zone.name
name = ""
value = "v=spf1 include:spf.messagingengine.com ?all"
type = "TXT"
}
# DMARC
resource "dnsimple_zone_record" "dmarc" {
zone_name = var.zone.name
name = "_dmarc"
value = "v=DMARC1; p=none;"
type = "TXT"
}
# Client email auto-discovery
resource "dnsimple_zone_record" "autodiscover" {
for_each = {
submission = { priority = 0, weight = 0, port = 0, target = "." }
submissions = { priority = 0, weight = 1, port = 465, target = "smtp.fastmail.com" }
imap = { priority = 0, weight = 0, port = 0, target = "." }
imaps = { priority = 0, weight = 1, port = 993, target = "imap.fastmail.com" }
pop3 = { priority = 0, weight = 0, port = 0, target = "." }
pop3s = { priority = 10, weight = 1, port = 995, target = "pop.fastmail.com" }
jmap = { priority = 0, weight = 1, port = 443, target = "api.fastmail.com" }
autodiscover = { priority = 0, weight = 1, port = 443, target = "autodiscover.fastmail.com" }
}
zone_name = var.zone.name
name = "_${each.key}._tcp"
value = "${each.value.weight} ${each.value.port} ${each.value.target}"
priority = each.value.priority
type = "SRV"
}