← All packages

@lacspace/mail-dns

v1.0.0Mail Kit0 deps

Generate and verify a domain's email DNS records: MX, SPF, DKIM, DMARC, MTA-STS, TLS-RPT and BIMI. generateRecords() gives the exact records to add; checkDomain() looks them up, scores the domain 0-100 and explains every failure in plain English. Recursive SPF lookup counting (10-lookup limit, void lookups, cycles), SPF evaluation for an IP, DKIM key size, DMARC report authorization, MTA-STS policy fetch and MX coverage, provider presets (Hostinger, Google Workspace, Microsoft 365, Zoho, GoDaddy, Amazon SES, SendGrid, Mailgun, Brevo). Injectable resolver, DNS-over-HTTPS for edge runtimes, zero dependencies.

npm i @lacspace/mail-dns

Usage

mail-dns.ts
import { generateRecords, checkDomain, explain } from "@lacspace/mail-dns";

const setup = {
  domain: "acme.com",
  mailHost: "mx1.mail.lacspace.com",
  spfInclude: ["_spf.mail.lacspace.com"],
  dkim: { selector: "lac1", publicKey: "MIIBIjANBgkq..." },   // base64, PEM, or a full v=DKIM1 value
  dmarc: { policy: "none", rua: ["dmarc@acme.com"] },
  mtaSts: { mode: "testing", policyHost: "mta-sts.mail.lacspace.com" },
  tlsRpt: { rua: ["tls@acme.com"] },
};

const { records, mtaStsPolicyFile, notes } = generateRecords(setup);
// [{ type: "MX",  name: "@", fqdn: "acme.com", value: "mx1.mail.lacspace.com", priority: 10, ttl: 3600, required: true, purpose: "Delivers email for acme.com to ..." },
//  { type: "TXT", name: "@", value: "v=spf1 include:_spf.mail.lacspace.com ~all", ... },
//  { type: "TXT", name: "lac1._domainkey", value: "v=DKIM1; k=rsa; p=MIIB...", chunks: [/* ≤255-char strings */] },
//  { type: "TXT", name: "_dmarc", value: "v=DMARC1; p=none; rua=mailto:dmarc@acme.com" },
//  { type: "TXT", name: "_mta-sts", value: "v=STSv1; id=1f3a9c..." }, { type: "CNAME", name: "mta-sts", ... },
//  { type: "TXT", name: "_smtp._tls", value: "v=TLSRPTv1; rua=mailto:tls@acme.com" }]

const report = await checkDomain("acme.com", { expect: setup });
report.ok;      // true when MX, SPF, DKIM and DMARC all work
report.score;   // 0–100
report.fixes;   // ["Add an MX record at @ pointing to mx1.mail.lacspace.com with priority 10.", ...]
explain(report.checks.spf);
// Allowed senders (SPF): Broken: this needs fixing.
// - Your SPF record has 12 DNS lookups; the limit is 10, so receivers will treat it as broken. ...

Exports 50

CHECK_LABELSCOMMON_DKIM_SELECTORSPROVIDERSSCORE_WEIGHTSSTATUS_CREDITSTATUS_TEXTbase64ToBytesbuildDkimbuildDmarcbuildMtaStsPolicybuildSpfbuildTlsRptcheckDomaincidrMatchcountSpfLookupsdetectProvidersdohResolverevaluateSpfexpectedMxHostsexplainexplainReportexternalReportDomainsfindSpfRecordsgenerateRecordsipFamilyisDmarcRecordisNullMxmxMatchesPatternnodeResolvernormalizeDkimPublicKeyparseBimiparseDkimKeyparseDmarcparseDohAnswerparseIp4parseIp6parseMtaStsPolicyparseMtaStsTxtparseSpfparseTlsRptparseTxtDatapickResolverprimaryDkimproviderDkimSelectorsproviderMxrsaModulusBitsscoreCheckssplitTxttoZoneFileuncoveredMx

Keywords

emaildnsspfdkimdmarcmta-sts

More in Mail Kit

@lacspace/email-templates

Compose bulletproof, responsive, dark-mode HTML emails from simple blocks, plus 13 ready-made transactional templates (OTP, verify, password-reset, magic-link, receipt, order, shipping, invitation, digest, announcement). Ships plaintext generation, preheaders and {{var}} i18n interpolation. Zero-dependency, isomorphic.

@lacspace/email-validate

Smart, network-free email validation — RFC-5322 syntax (incl. quoted local parts & IP-literal domains), disposable/temp-mail & role-account detection, free-provider flags, Gmail normalization and 'did you mean?' typo suggestions. Zero-dependency, isomorphic.

@lacspace/email-verify

Best-effort email deliverability for Node — syntax + disposable/role, MX lookup with priority ranking, an optional SMTP RCPT probe (no mail sent), catch-all detection, a 0-100 confidence score, and de-duped batch verification. All DNS/SMTP injectable; zero npm dependencies.

@lacspace/mailer

A tiny zero-dependency SMTP client for Node — send email over raw net/tls with STARTTLS & AUTH, plus a fluent MIME builder (inline images, attachments, alternatives), RFC 5322 address + RFC 2047 helpers, batch send with retry, and no-network test transports. Provider presets (Hostinger, Gmail, Outlook, Zoho…) make setup one line.

@lacspace/imap

Zero-dependency IMAP4rev1 client for Node (RFC 3501 + IDLE, MOVE, UIDPLUS, CONDSTORE, SPECIAL-USE, LIST-EXTENDED, LITERAL+, SASL-IR, QUOTA, ID). Implicit TLS and STARTTLS with verification on, LOGIN / PLAIN / XOAUTH2 / OAUTHBEARER, streaming byte-accurate parser, async-iterable FETCH, envelopes with RFC 2047 decoding, BODYSTRUCTURE trees shared with @lacspace/mime, modified UTF-7 mailbox names, special-use detection (incl. Gmail XLIST and localised names), IDLE with NOOP fallback. Works with Hostinger (Dovecot), Gmail, Outlook/Exchange, GoDaddy.

@lacspace/mime

Isomorphic RFC 5322 / RFC 2045-2049 MIME parser and builder for webmail. parseMime() turns raw mail (string or bytes) into from/to/cc/subject/date/text/html/attachments/inline cid images/priority/List-Unsubscribe one-click and the part tree; handles nested multipart (mixed, alternative, related, report, signed), message/rfc822 forwards, base64 and quoted-printable (tolerant), RFC 2047 encoded words (split multibyte, adjacent whitespace), RFC 2231 parameters, 30+ charsets and malformed input without ever throwing. parseBodyStructure() parses IMAP BODYSTRUCTURE (literals, extension data) into the same tree with IMAP partIds, plus findTextParts / listAttachments / decodePart for lazy fetching. buildMime() writes CRLF messages with encoded-word headers, QP/base64 bodies, mixed/alternative/related nesting, Message-ID generation and header-injection guards; replyHeaders() / forwardSubject() for threading. Pairs with @lacspace/imap and @lacspace/mailer. Zero dependencies; Node 18+, edge runtimes and browsers.