Git Product home page Git Product logo

mailpolicyexplainer's Introduction

MailPolicyExplainer

GitHub release (with filter) GitHub PowerShell Gallery

Unofficial logo: email with an info icon

A PowerShell module to fetch and analyze a domain's mail-related DNS records.

SHORT EXAMPLE

PS C:\>  Test-MailPolicy contoso.com

LONG DESCRIPTION

MailPolicyExplainer is just that: a PowerShell module that will retrieve all of a domain's email-related DNS records, and show them to the user. However, unlike a simple call to Resolve-DnsName, this module will actually analyze them and show you what they mean, rather than just what they are.

This module supports MX, SPF, DKIM ADSP, DMARC, DANE, MTA-STS, and SMTP TLS Reporting; as well as evaluating whether or not records are signed with DNSSEC. In addition, if you provide names of selectors, DKIM and BIMI selector records are also evaluated.

EXAMPLES

Most people using this module will want to use the Test-MailPolicy cmdlet, which runs every single test in order. Though it may not be obvious which DKIM and BIMI selector names exist (save for email services like Exchange Online who use well-known DKIM selector names -- selector1 and selector2), the -DkimSelectorsToCheck and -BimiSelectorsToCheck can be used to test known selectors.

In its simplest form, Test-MailPolicy will review almost every DNS record available.

PS C:\>  Test-MailPolicy contoso.com

Checking DKIM Selectors

Exchange Online always uses DKIM selectors "selector1" and "selector2". If a domain doesn't use any other email sending platforms (such as Constant Contact), you can test any Office 365 customer with this command:

PS C:\>  Test-MailPolicy fabrikam.com -DkimSelectorsToCheck "selector1","selector2"

MailPolicyExplainer's output when running:  Test-MailPolicy -DkimSelectorsToCheck 'selector1','selector2' microsoft.com

But what if they do use something like Constant Contact? Assuming the DKIM selector name is known:

PS C:\>  Test-MailPolicy woodgrovebank.com -DkimSelectorsToCheck "selector1","selector2","constantcontact"

Note that sometimes emails can come from subdomains, and those subdomains will have their own DNS records. You will need to run this cmdlet once per domain.

PS C:\>  Test-MailPolicy tailspintoys.com -DkimSelectorsToCheck "selector1","selector2"
PS C:\>  Test-MailPolicy shop.tailspintoys.com -DkimSelectorsToCheck "shopify"

Running Only Some Tests

Or, if you only want to test one aspect of email, you can test items individually. For example, if yu're working on MTA-STS, you can skip all the other checks.

PS C:\>  Test-MtaStsPolicy adatum.com

MailPolicyExplainer's output when running:  Test-MaStsPolicy colincogle.name

SPF DNS Lookup Counts

It can also count how many DNS lookups are in an SPF record.

PS C:\>  Test-MailPolicy northwindtraders.com -CountSpfDnsLookups  # or
PS C:\>  Test-SpfRecord  northwindtraders.com -CountDnsLookups     # or
PS C:\>  Test-SpfRecord  northwindtraders.com -Recurse

MailPolicyExplainer's output when running:  Test-SpfRecord -Recurse microsoft.com

Further Help

For more help, why not start with the conceptual help?

mailpolicyexplainer's People

Contributors

rhymeswithmogul avatar skyblaster avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

skyblaster

mailpolicyexplainer's Issues

Enhancement: Better handling of missing DKIM records

I'm not going to submit a PR for this one, as you may have other ideas on how to handle it.

The issue I'm having is that Microsoft (as one example) will issue a CNAME record for you to point your domain to your 365 tenant sub-domain (eg: example.onmicrosoft.com).

Once you create the CNAME record, they give you a nice green checkmark in the M365 admin center portal even when your DKIM is disabled in Microsoft Defender resulting in an empty TXT record.

Sample code:

+	If ($DnsLookup.PSObject.Properties.Name -Contains 'Answer' -and $DnsLookup.Status -eq 3)
+	{
+		Write-BadNews "DKIM selector${Name}: CNAME record exists, but resultant TXT record is empty."
+		Return
+	}

	If ($DnsLookup.PSObject.Properties.Name -NotContains 'Answer' -or $DnsLookup.Status -eq 3)
	{
		Write-BadNews "DKIM selector${Name}: This selector was not found."
		Return
	}

Example results:
image

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.