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



131
132
133
# File 'lib/mailblastr/emails.rb', line 131

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" })



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

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



87
88
89
# File 'lib/mailblastr/emails.rb', line 87

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



104
105
106
107
108
109
110
# File 'lib/mailblastr/emails.rb', line 104

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



114
115
116
# File 'lib/mailblastr/emails.rb', line 114

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



75
76
77
78
# File 'lib/mailblastr/emails.rb', line 75

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



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

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



94
95
96
97
98
99
100
# File 'lib/mailblastr/emails.rb', line 94

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



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

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