Project

dmarc

0.03
Low commit activity in last 3 years
A long-lived project that still receives updates
DMARC Record Parser
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 2.0

Runtime

>= 1.0.0, < 3.0.0
 Project Readme

DMARC

CI Gem Version YARD Docs

DMARC is a technical specification intended to solve a couple of long-standing email authentication problems. DMARC policies are described in DMARC "records," which are stored as DNS TXT records on a subdomain. This library contains a parser for DMARC records.

Example

Parse a DMARC record:

require 'dmarc'

record = DMARC::Record.parse("v=DMARC1; p=reject; rua=mailto:d@rua.agari.com; ruf=mailto:d@ruf.agari.com; fo=1")

record.v
# => :DMARC1

record.adkim
# => :r

record.aspf
# => :r

record.fo
# => ["0"]

record.p
# => :reject

record.pct
# => 100

record.rf
# => :afrf

record.ri
# => 86400

record.rua
# => [#<DMARC::Uri:0x0055ede60711e0 @uri=#<URI::MailTo mailto:d@rua.agari.com>, @size=nil, @unit=nil>]

record.ruf
# => [#<DMARC::Uri:0x0055ede606f138 @uri=#<URI::MailTo mailto:d@ruf.agari.com>, @size=nil, @unit=nil>]

record.sp
# => :reject

Query the DMARC record for a domain:

record = DMARC::Record.query('twitter.com')
# => #<DMARC::Record:0x0055ede6b808b0 @v=:DMARC1, @adkim=nil, @aspf=nil, @fo=["1"@79], @p=:reject, @pct=nil, @rf=nil, @ri=nil, @rua=[#<DMARC::Uri:0x0055ede6ba1c40 @uri=#<URI::MailTo mailto:d@rua.agari.com>, @size=nil, @unit=nil>], @ruf=[#<DMARC::Uri:0x0055ede6b8b760 @uri=#<URI::MailTo mailto:d@ruf.agari.com>, @size=nil, @unit=nil>], @sp=nil>

Requirements

Install

$ gem install dmarc

Testing

To run the RSpec tests:

$ rake spec

To test the parser against the Alexa Top 500:

$ rake spec:gauntlet

License

See the {file:LICENSE.txt} file.