Class: Mailgun::Mailbox

Inherits:
Object show all
Defined in:
lib/mailgun/mailbox.rb

Instance Method Summary collapse

Constructor Details

#initialize(mailgun, domain) ⇒ Mailbox

Used internally, called from Mailgun::Base



5
6
7
8
# File 'lib/mailgun/mailbox.rb', line 5

def initialize(mailgun, domain)
  @mailgun = mailgun
  @domain  = domain
end

Instance Method Details

#create(mailbox_name, password) ⇒ Object

Creates a mailbox on the Mailgun server with the given password



18
19
20
21
22
23
24
25
26
27
28
# File 'lib/mailgun/mailbox.rb', line 18

def create(mailbox_name, password)
  address = "#{mailbox_name}@#{@domain}"
  Mailgun.submit(
    :post,
    mailbox_url,
    {
      :mailbox => address,
      :password => password
    }
  )
end

#destroy(mailbox_name) ⇒ Object

Destroys the mailbox



38
39
40
# File 'lib/mailgun/mailbox.rb', line 38

def destroy(mailbox_name)
  Mailgun.submit :delete, mailbox_url(mailbox_name)
end

#list(options = {}) ⇒ Object

List all mailboxes for a given domain

  • domain the domain for which all mailboxes will listed



12
13
14
# File 'lib/mailgun/mailbox.rb', line 12

def list(options={})
  Mailgun.submit(:get, mailbox_url, options)["items"]
end

#update_password(mailbox_name, password) ⇒ Object

Sets the password for a mailbox



32
33
34
# File 'lib/mailgun/mailbox.rb', line 32

def update_password(mailbox_name, password)
  Mailgun.submit :put, mailbox_url(mailbox_name), :password => password
end