Skip to content

Instantly share code, notes, and snippets.

@dapi
Last active December 10, 2019 08:05
Show Gist options
  • Save dapi/cf4a50cee52f361656f3decf3ac36c0f to your computer and use it in GitHub Desktop.
Save dapi/cf4a50cee52f361656f3decf3ac36c0f to your computer and use it in GitHub Desktop.
class SpfChecker
Response = Struct.new(:correct, :spf_value, :message)
def initialize(value)
@value
end
def check(domain)
result = Net::DNS::Resolver.start(domain, Net::DNS::TXT)
values = result.each_mx.map(&:txt)
Response.new( correct: values&.include?(VALID_VALUE), spf_value: values, message: message).freeze
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment