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 SPF 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
# => [#<URI::MailTo:0x000000034a1cc8 URL:mailto:[email protected]>]

record.ruf
# => [#<URI::MailTo:0x000000034a02b0 URL:mailto:[email protected]>]

record.sp
# => :reject

Query the SPF record for a domain:

record = DMARC::Record.query('twitter.com')
# => #<DMARC::Record:0x0000000313bd90 @adkim=:r, @aspf=:r, @fo=["1"@79], @p=:reject, @pct=100, @rf=:afrf, @ri=86400, @rua=[#<URI::MailTo:0x00000003124e38 URL:mailto:[email protected]>], @ruf=[#<URI::MailTo:0x00000003132678 URL:mailto:[email protected]>], @sp=:reject, @v=:DMARC1>

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.