Module: Mailblastr::Emails::Receiving

Defined in:
lib/mailblastr/emails.rb

Overview

Inbound (received) email.

Class Method Summary collapse

Class Method Details

.delete(email_id) ⇒ Object

Delete a received email. DELETE /emails/receiving/:id



138
139
140
# File 'lib/mailblastr/emails.rb', line 138

def delete(email_id)
  Client.request(:delete, "/emails/receiving/#{Client.path_escape(email_id)}")
end

.forward(email_id, params) ⇒ Object

Forward a received email. POST /emails/receiving/:id/forward Receiving.forward(id, { from: "you@yourdomain.com", to: "team@you.com" })



127
128
129
# File 'lib/mailblastr/emails.rb', line 127

def forward(email_id, params)
  Client.request(:post, "/emails/receiving/#{Client.path_escape(email_id)}/forward", body: params)
end

.get(email_id) ⇒ Object

Retrieve a received email. GET /emails/receiving/:id



94
95
96
# File 'lib/mailblastr/emails.rb', line 94

def get(email_id)
  Client.request(:get, "/emails/receiving/#{Client.path_escape(email_id)}")
end

.get_attachment(email_id, attachment_id) ⇒ Object

Download one attachment as raw bytes (binary String). GET /emails/receiving/:id/attachments/:attachment_id



111
112
113
114
115
116
117
# File 'lib/mailblastr/emails.rb', line 111

def get_attachment(email_id, attachment_id)
  Client.request(
    :get,
    "/emails/receiving/#{Client.path_escape(email_id)}/attachments/#{Client.path_escape(attachment_id)}",
    raw: true
  )
end

.get_raw(email_id) ⇒ Object

Download the original RFC822/MIME message as raw bytes (binary String). GET /emails/receiving/:id/raw



121
122
123
# File 'lib/mailblastr/emails.rb', line 121

def get_raw(email_id)
  Client.request(:get, "/emails/receiving/#{Client.path_escape(email_id)}/raw", raw: true)
end

.list(params = {}) ⇒ Object

List received emails — cursor pagination plus an optional received_for filter (only messages received for that address). With no limit and no cursor the endpoint returns up to 1000 rows in one response; pass limit to get normal 1-100 pages. GET /emails/receiving



82
83
84
85
# File 'lib/mailblastr/emails.rb', line 82

def list(params = {})
  query = Client.pagination(params).merge(Client.filters(params, :received_for))
  Client.request(:get, "/emails/receiving", query: query)
end

.list_addressesObject

Per-address inbound stats (totals, replies, last received). Not paginated. GET /emails/receiving/addresses



89
90
91
# File 'lib/mailblastr/emails.rb', line 89

def list_addresses
  Client.request(:get, "/emails/receiving/addresses")
end

.list_attachments(email_id, params = {}) ⇒ Object

List a received email's attachments. With no limit and no after every attachment is returned; supplying either paginates normally. GET /emails/receiving/:id/attachments



101
102
103
104
105
106
107
# File 'lib/mailblastr/emails.rb', line 101

def list_attachments(email_id, params = {})
  Client.request(
    :get,
    "/emails/receiving/#{Client.path_escape(email_id)}/attachments",
    query: Client.pagination(params)
  )
end

.reply(email_id, params) ⇒ Object

Reply to a received email's sender, threaded into the conversation. POST /emails/receiving/:id/reply



133
134
135
# File 'lib/mailblastr/emails.rb', line 133

def reply(email_id, params)
  Client.request(:post, "/emails/receiving/#{Client.path_escape(email_id)}/reply", body: params)
end