Email Provider MXUsage

Usage

Usage

Classify a single MX host

import { classifyMx } from "@visulima/email-provider-mx";

classifyMx("aspmx.l.google.com");
// → { provider: "google", type: "mailbox", display: "Google Workspace" }

classifyMx("mx0a-00000000.pphosted.com");
// → { provider: "proofpoint", type: "seg", display: "Proofpoint" }

classifyMx("mail.example.com");
// → undefined (unknown host)

Matching is case-insensitive, ignores a trailing dot, and only matches on a dot boundary, so notgoogle.com does not match google.com. The most specific (longest) known suffix wins, so tenant.mail.protection.outlook.com resolves to Microsoft 365.

Classify a set of MX records

Feed it the records from a DNS lookup. They are sorted by ascending priority and the first recognized record wins — which is usually the primary MX. Secure Email Gateways are typically published as the lowest-priority (primary) MX, so this surfaces the gateway fronting the mailbox host.

import { resolveMx } from "node:dns/promises";

import { classifyMxRecords } from "@visulima/email-provider-mx";

const records = await resolveMx("example.com");
// e.g. [{ exchange: "mx0a-00000000.pphosted.com", priority: 10 }, …]

classifyMxRecords(records);
// → { provider: "proofpoint", type: "seg", display: "Proofpoint" }

Detect a Secure Email Gateway

import { isSecureEmailGateway } from "@visulima/email-provider-mx";

isSecureEmailGateway("eu-smtp-inbound-1.mimecast.com"); // → true
isSecureEmailGateway("aspmx.l.google.com"); // → false

A note on classification

Classification is by MX host, which cannot always separate a free consumer tier from a paid business tier on the same infrastructure. For example, consumer Gmail (gmail-smtp-in.l.google.com) and Google Workspace (aspmx.l.google.com) both resolve under google.com, so both classify as Google mailbox.

Support

Contribute to our work and keep us going

Community is the heart of open source. The success of our packages wouldn't be possible without the incredible contributions of users, testers, and developers who collaborate with us every day.Want to get involved? Here are some tips on how you can make a meaningful impact on our open source projects.

Ready to help us out?

Be sure to check out the package's contribution guidelines first. They'll walk you through the process on how to properly submit an issue or pull request to our repositories.

Submit a pull request

Found something to improve? Fork the repo, make your changes, and open a PR. We review every contribution and provide feedback to help you get merged.

Good first issues

Simple issues suited for people new to open source development, and often a good place to start working on a package.
View good first issues