Skip to content

Instantly share code, notes, and snippets.

@timchambers
Last active October 11, 2022 23:33
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save timchambers/40fce1a2f1351e6e4c6a070e17367d54 to your computer and use it in GitHub Desktop.
Save timchambers/40fce1a2f1351e6e4c6a070e17367d54 to your computer and use it in GitHub Desktop.
Generate a DNS zone file with the necessary zones for email hosting with fastmail
// A script to generate a zone file with all the email-related zones required by Fastmail
// Reference: https://www.fastmail.com/help/receive/domains-advanced.html#dnslist
//
// Run this script with node and copy the output to your clipboard
// $ node fastmail-zone yourdomain.com | pbcopy
//
// Paste into AWS Route53 "Import zone file" field when creating a new zone, etc.
const render = (DOMAIN) => {
console.log(`;; Fastmail-hosted zones (email only)
;; https://www.fastmail.com/help/receive/domains-advanced.html#dnslist
;; WEBMAIL
mail.${DOMAIN}. 3600 IN A 66.111.4.147
mail.${DOMAIN}. 3600 IN A 66.111.4.148
;; MX
@ 3600 IN MX 10 in1-smtp.messagingengine.com.
@ 3600 IN MX 20 in2-smtp.messagingengine.com.
*.${DOMAIN}. 3600 IN MX 10 in1-smtp.messagingengine.com.
*.${DOMAIN}. 3600 IN MX 20 in2-smtp.messagingengine.com.
mail.${DOMAIN}. 3600 IN MX 10 in1-smtp.messagingengine.com.
mail.${DOMAIN}. 3600 IN MX 20 in2-smtp.messagingengine.com.
;; DKIM
fm1._domainkey.${DOMAIN}. 3600 IN CNAME fm1.${DOMAIN}.dkim.fmhosted.com.
fm2._domainkey.${DOMAIN}. 3600 IN CNAME fm2.${DOMAIN}.dkim.fmhosted.com.
fm3._domainkey.${DOMAIN}. 3600 IN CNAME fm3.${DOMAIN}.dkim.fmhosted.com.
;; SPF
@ 3600 IN TXT "v=spf1 include:spf.messagingengine.com ?all"
;; Auto-discovery
_submission._tcp.${DOMAIN}. 3600 IN SRV 0 1 587 smtp.fastmail.com.
_imap._tcp.${DOMAIN}. 3600 IN SRV 0 0 0 .
_imaps._tcp.${DOMAIN}. 3600 IN SRV 0 1 993 imap.fastmail.com.
_pop3._tcp.${DOMAIN}. 3600 IN SRV 0 0 0 .
_pop3s._tcp.${DOMAIN}. 3600 IN SRV 10 1 995 pop.fastmail.com.
_carddav._tcp.${DOMAIN}. 3600 IN SRV 0 0 0 .
_carddavs._tcp.${DOMAIN}. 3600 IN SRV 0 1 443 carddav-d423617.fastmail.com.
_caldav._tcp.${DOMAIN}. 3600 IN SRV 0 0 0 .
_caldavs._tcp.${DOMAIN}. 3600 IN SRV 0 1 443 caldav-d423617.fastmail.com.
`)
}
if (require.main === module) {
const [ p, s, ...args ] = process.argv
render(...args)
} else {
module.exports = render
}
@timchambers
Copy link
Author

A script to generate a zone file with all the email-related zones required by Fastmail
Reference: https://www.fastmail.com/help/receive/domains-advanced.html#dnslist

Run this script with node and copy the output to your clipboard:

$ node fastmail-zone yourdomain.com | pbcopy

Paste into AWS Route53 "Import Zone File" field when creating a new zone, etc.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment