GithubHelp home page GithubHelp logo

markvantilburg / businessmonitor.mailtools Goto Github PK

View Code? Open in Web Editor NEW
2.0 4.0 0.0 69 KB

A .NET library providing utilities for mail such as DKIM, SPF and DMARC.

License: Apache License 2.0

C# 100.00%
bimi dkim dmarc e-mail mx spf mail

businessmonitor.mailtools's Introduction

BusinessMonitor.MailTools

Test status Nuget

A .NET library providing utilities for mail such as DKIM, SPF and DMARC.

Usage

dotnet add package BusinessMonitor.MailTools

If you are using ASP.NET targeting .NET Framework you may need netstandard as reference in your web.config.

<assemblies>
    <add assembly="netstandard, Version=2.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51" />
</assemblies>

Resolver

To make this library independent of any DNS resolver implementation, we instead provide a IResolver interface. Each check class which needs to do lookups will require an instance of this interface, the user can then implement this interface with their own DNS library of choice.

public class DnsResolver : IResolver
{
    public string[] GetTextRecords(string domain)
    {
        // Your DNS resolve implementation goes here
    }
}

For an example implementation see BusinessMonitor.MailTools.Dns

Examples

Validate the DKIM record on a domain and return the public key:

var check = new DkimCheck(resolver);
var record = check.GetDkimRecord(domain, selector);

Console.WriteLine(record.PublicKey);

Parse a DMARC record:

var record = DmarcCheck.ParseDmarcRecord("v=DMARC1; p=reject; adkim=s; aspf=s");

Console.WriteLine(record.DkimMode);

Get a SPF record and return all includes:

var check = new SpfCheck(resolver);
var record = check.GetSpfRecord(domain);

foreach (var directive in record.Directives)
{
    if (directive.Mechanism == SpfMechanism.Include)
    {
        Console.WriteLine(directive.Include); // The include domain
        Console.WriteLine(directive.Included); // The included SPF record
    }
}

businessmonitor.mailtools's People

Contributors

markvantilburg avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

businessmonitor.mailtools's Issues

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.