DMARC

Code Climate Build Status Gem Version YARD Docs Test Coverage

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:[email protected]; ruf=mailto:[email protected]; 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:[email protected]>, @size=nil, @unit=nil>]

record.ruf
# => [#<DMARC::Uri:0x0055ede606f138 @uri=#<URI::MailTo mailto:[email protected]>, @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:[email protected]>, @size=nil, @unit=nil>], @ruf=[#<DMARC::Uri:0x0055ede6b8b760 @uri=#<URI::MailTo mailto:[email protected]>, @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 LICENSE file.