Class: Mandrill::Inbound

Inherits:
Object
  • Object
show all
Defined in:
lib/mandrill/api.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(master) ⇒ Inbound

Returns a new instance of Inbound.



491
492
493
# File 'lib/mandrill/api.rb', line 491

def initialize(master)
    @master = master
end

Instance Attribute Details

#masterObject

Returns the value of attribute master.



489
490
491
# File 'lib/mandrill/api.rb', line 489

def master
  @master
end

Instance Method Details

#add_domain(domain) ⇒ Hash

Add an inbound domain to your account

Parameters:

  • domain (String)

    a domain name

Returns:

  • (Hash)

    information about the domain

    • String

      domain the domain name that is accepting mail

    • String

      created_at the date and time that the inbound domain was added as a UTC string in YYYY-MM-DD HH:MM:SS format

    • Boolean

      valid_mx true if this inbound domain has successfully set up an MX record to deliver mail to the Mandrill servers



512
513
514
515
# File 'lib/mandrill/api.rb', line 512

def add_domain(domain)
    _params = {:domain => domain}
    return @master.call 'inbound/add-domain', _params
end

#add_route(domain, pattern, url) ⇒ Hash

Add a new mailbox route to an inbound domain

Parameters:

  • domain (String)

    an existing inbound domain

  • pattern (String)

    the search pattern that the mailbox name should match

  • url (String)

    the webhook URL where the inbound messages will be published

Returns:

  • (Hash)

    the added mailbox route information

    • String

      id the unique identifier of the route

    • String

      pattern the search pattern that the mailbox name should match

    • String

      url the webhook URL where inbound messages will be published



559
560
561
562
# File 'lib/mandrill/api.rb', line 559

def add_route(domain, pattern, url)
    _params = {:domain => domain, :pattern => pattern, :url => url}
    return @master.call 'inbound/add-route', _params
end

#check_domain(domain) ⇒ Hash

Check the MX settings for an inbound domain. The domain must have already been added with the add-domain call

Parameters:

  • domain (String)

    an existing inbound domain

Returns:

  • (Hash)

    information about the inbound domain

    • String

      domain the domain name that is accepting mail

    • String

      created_at the date and time that the inbound domain was added as a UTC string in YYYY-MM-DD HH:MM:SS format

    • Boolean

      valid_mx true if this inbound domain has successfully set up an MX record to deliver mail to the Mandrill servers



523
524
525
526
# File 'lib/mandrill/api.rb', line 523

def check_domain(domain)
    _params = {:domain => domain}
    return @master.call 'inbound/check-domain', _params
end

#delete_domain(domain) ⇒ Hash

Delete an inbound domain from the account. All mail will stop routing for this domain immediately.

Parameters:

  • domain (String)

    an existing inbound domain

Returns:

  • (Hash)

    information about the deleted domain

    • String

      domain the domain name that is accepting mail

    • String

      created_at the date and time that the inbound domain was added as a UTC string in YYYY-MM-DD HH:MM:SS format

    • Boolean

      valid_mx true if this inbound domain has successfully set up an MX record to deliver mail to the Mandrill servers



534
535
536
537
# File 'lib/mandrill/api.rb', line 534

def delete_domain(domain)
    _params = {:domain => domain}
    return @master.call 'inbound/delete-domain', _params
end

#delete_route(id) ⇒ Hash

Delete an existing inbound mailbox route

Parameters:

  • id (String)

    the unique identifier of an existing route

Returns:

  • (Hash)

    the deleted mailbox route information

    • String

      id the unique identifier of the route

    • String

      pattern the search pattern that the mailbox name should match

    • String

      url the webhook URL where inbound messages will be published



583
584
585
586
# File 'lib/mandrill/api.rb', line 583

def delete_route(id)
    _params = {:id => id}
    return @master.call 'inbound/delete-route', _params
end

#domainsArray

List the domains that have been configured for inbound delivery

Returns:

  • (Array)

    the inbound domains associated with the account

    • Hash

      return[] the individual domain info

      - [String] domain the domain name that is accepting mail
      - [String] created_at the date and time that the inbound domain was added as a UTC string in YYYY-MM-DD HH:MM:SS format
      - [Boolean] valid_mx true if this inbound domain has successfully set up an MX record to deliver mail to the Mandrill servers
      


501
502
503
504
# File 'lib/mandrill/api.rb', line 501

def domains()
    _params = {}
    return @master.call 'inbound/domains', _params
end

#routes(domain) ⇒ Array

List the mailbox routes defined for an inbound domain

Parameters:

  • domain (String)

    the domain to check

Returns:

  • (Array)

    the routes associated with the domain

    • Hash

      return[] the individual mailbox route

      - [String] id the unique identifier of the route
      - [String] pattern the search pattern that the mailbox name should match
      - [String] url the webhook URL where inbound messages will be published
      


546
547
548
549
# File 'lib/mandrill/api.rb', line 546

def routes(domain)
    _params = {:domain => domain}
    return @master.call 'inbound/routes', _params
end

#send_raw(raw_message, to = nil, mail_from = nil, helo = nil, client_address = nil) ⇒ Array

Take a raw MIME document destined for a domain with inbound domains set up, and send it to the inbound hook exactly as if it had been sent over SMTP

Parameters:

  • raw_message (String)

    the full MIME document of an email message

  • to (Array, nil) (defaults to: nil)

    optionally define the recipients to receive the message - otherwise we’ll use the To, Cc, and Bcc headers provided in the document

    • String

      to[] the email address of the recipient

  • mail_from (String) (defaults to: nil)

    the address specified in the MAIL FROM stage of the SMTP conversation. Required for the SPF check.

  • helo (String) (defaults to: nil)

    the identification provided by the client mta in the MTA state of the SMTP conversation. Required for the SPF check.

  • client_address (String) (defaults to: nil)

    the remote MTA’s ip address. Optional; required for the SPF check.

Returns:

  • (Array)

    an array of the information for each recipient in the message (usually one) that matched an inbound route

    • Hash

      return[] the individual recipient information

      - [String] email the email address of the matching recipient
      - [String] pattern the mailbox route pattern that the recipient matched
      - [String] url the webhook URL that the message was posted to
      


600
601
602
603
# File 'lib/mandrill/api.rb', line 600

def send_raw(raw_message, to=nil, mail_from=nil, helo=nil, client_address=nil)
    _params = {:raw_message => raw_message, :to => to, :mail_from => mail_from, :helo => helo, :client_address => client_address}
    return @master.call 'inbound/send-raw', _params
end

#update_route(id, pattern = nil, url = nil) ⇒ Hash

Update the pattern or webhook of an existing inbound mailbox route. If null is provided for any fields, the values will remain unchanged.

Parameters:

  • id (String)

    the unique identifier of an existing mailbox route

  • pattern (String) (defaults to: nil)

    the search pattern that the mailbox name should match

  • url (String) (defaults to: nil)

    the webhook URL where the inbound messages will be published

Returns:

  • (Hash)

    the updated mailbox route information

    • String

      id the unique identifier of the route

    • String

      pattern the search pattern that the mailbox name should match

    • String

      url the webhook URL where inbound messages will be published



572
573
574
575
# File 'lib/mandrill/api.rb', line 572

def update_route(id, pattern=nil, url=nil)
    _params = {:id => id, :pattern => pattern, :url => url}
    return @master.call 'inbound/update-route', _params
end