Class: Mailgun::Address
- Inherits:
-
Object
- Object
- Mailgun::Address
- Defined in:
- lib/mailgun/address.rb
Overview
Mailgun::Address is a simple interface to the Email Validation API.
Instance Method Summary collapse
-
#initialize(api_key = "") ⇒ Address
constructor
A new instance of Address.
-
#parse(addresses, syntax_only = true) ⇒ Object
Parses a delimiter separated list of email addresses into two lists: parsed addresses and unparsable portions.
-
#validate(address, mailbox_verification = false) ⇒ Object
Given an arbitrary address, validates it based on defined checks.
Constructor Details
#initialize(api_key = "") ⇒ Address
Returns a new instance of Address.
9 10 11 12 13 14 15 16 |
# File 'lib/mailgun/address.rb', line 9 def initialize(api_key = "") if api_key == "" then fail ParameterError.new('Public API key is required for Mailgun::Address.initialize()', nil) end @api_key = api_key @client = Mailgun::Client.new(api_key = api_key) end |
Instance Method Details
#parse(addresses, syntax_only = true) ⇒ Object
Parses a delimiter separated list of email addresses into two lists: parsed addresses and unparsable portions. The parsed addresses are a list of addresses that are syntactically valid (and optionally have DNS and ESP specific grammar checks) the unparsable list is a list of characters sequences that the parser was not able to understand. These often align with invalid email addresses, but not always. Delimiter characters are comma (,) and semicolon (;).
39 40 41 42 43 44 45 |
# File 'lib/mailgun/address.rb', line 39 def parse(addresses, syntax_only = true) validate_addrs = addresses.join(";") res = @client.get "address/parse", {:addresses => validate_addrs, :syntax_only => syntax_only.to_s} return res.to_h! end |
#validate(address, mailbox_verification = false) ⇒ Object
Given an arbitrary address, validates it based on defined checks.
21 22 23 24 25 26 27 |
# File 'lib/mailgun/address.rb', line 21 def validate(address, mailbox_verification = false) params = {:address => address} params[:mailbox_verification] = true if mailbox_verification res = @client.get "address/validate", params return res.to_h! end |