Class: Mailbox

Inherits:
MailgunResource show all
Defined in:
lib/howitzer/utils/email/mailgun.rb

Overview

All mail arriving to emails addresses that have mailboxes associated will be stored on the server and can be later accessed via IMAP or POP3 protocols.

Mailbox has several properties:

[email protected] ^ ^ | | user domain

Class Method Summary collapse

Methods inherited from MailgunResource

#upsert

Methods included from Mailgun::RequestBuilder

#prepare_request

Class Method Details

.remove(mailbox) ⇒ Object



154
155
156
157
158
# File 'lib/howitzer/utils/email/mailgun.rb', line 154

def self.remove(mailbox)
  res = RestClient.delete "https://api:#{MailgunResource.password}"\
  "@api.mailgun.net/v2/#{mailbox.domain}/mailboxes/#{mailbox.user}"
  Mailgun::handle_response(res)
end

.upsert_from_csv(mailboxes) ⇒ Object

Example of a CSV file:

[email protected], password [email protected], password2



147
148
149
150
151
152
# File 'lib/howitzer/utils/email/mailgun.rb', line 147

def self.upsert_from_csv(mailboxes)
  uri_str = "#{MailgunResource.site}mailboxes.txt?api_key=#{MailgunResource.password}"
  http, url = prepare_request(uri_str)
  res = http.post(url, mailboxes, {"Content-type" => "text/plain" })
  Mailgun::handle_response(res)
end