Module: Mailblastr::Emails
- Defined in:
- lib/mailblastr/emails.rb
Overview
Send and inspect emails. Inbound mail lives under Mailblastr::Emails::Receiving.
Defined Under Namespace
Modules: Receiving
Class Method Summary collapse
-
.batch(payloads, options = {}) ⇒ Object
Send up to 100 emails in one request.
-
.cancel(email_id) ⇒ Object
Cancel a scheduled email.
-
.get(email_id) ⇒ Object
Retrieve a sent email and its events.
-
.get_attachment(email_id, attachment_id) ⇒ Object
Retrieve one attachment's metadata.
-
.list(params = {}) ⇒ Object
List sent emails (trimmed list items) — cursor pagination plus optional server-side filters:
campaign_id,automation_id,source("individual" for all one-off sends with no campaign/automation origin, "api" for one-off sends made with an API key — which also covers mail sent before the send origin was recorded — or "dashboard" for one-off mail composed in the dashboard: the composer and inbox replies/forwards; honoured only when neithercampaign_idnorautomation_idis supplied),domain_id,status(matched case-insensitively against the row'slast_event),folder(one of "outbox", "sent", "scheduled" or "failed" — any other value is rejected with a 422) andsearch(recipients, subject and sender). -
.list_attachments(email_id) ⇒ Object
List a sent email's attachments.
-
.send(params, options = {}) ⇒ Object
Send a single email.
-
.sources ⇒ Object
Per-source send metrics, one row per origin.
-
.update(email_id, params) ⇒ Object
Reschedule a scheduled email.
Class Method Details
.batch(payloads, options = {}) ⇒ Object
Send up to 100 emails in one request. POST /emails/batch (alias of Batch.send).
Batch items reject attachments and scheduled_at — send those
individually via Emails.send.
24 25 26 |
# File 'lib/mailblastr/emails.rb', line 24 def batch(payloads, = {}) Client.request(:post, "/emails/batch", body: payloads, options: ) end |
.cancel(email_id) ⇒ Object
Cancel a scheduled email. POST /emails/:id/cancel
78 79 80 |
# File 'lib/mailblastr/emails.rb', line 78 def cancel(email_id) Client.request(:post, "/emails/#{Client.path_escape(email_id)}/cancel") end |
.get(email_id) ⇒ Object
Retrieve a sent email and its events. GET /emails/:id
57 58 59 |
# File 'lib/mailblastr/emails.rb', line 57 def get(email_id) Client.request(:get, "/emails/#{Client.path_escape(email_id)}") end |
.get_attachment(email_id, attachment_id) ⇒ Object
Retrieve one attachment's metadata. GET /emails/:id/attachments/:attachment_id
67 68 69 |
# File 'lib/mailblastr/emails.rb', line 67 def (email_id, ) Client.request(:get, "/emails/#{Client.path_escape(email_id)}/attachments/#{Client.path_escape()}") end |
.list(params = {}) ⇒ Object
List sent emails (trimmed list items) — cursor pagination plus optional
server-side filters: campaign_id, automation_id, source
("individual" for all one-off sends with no campaign/automation origin,
"api" for one-off sends made with an API key — which also covers mail
sent before the send origin was recorded — or "dashboard" for one-off
mail composed in the dashboard: the composer and inbox replies/forwards;
honoured only when neither campaign_id nor automation_id is
supplied), domain_id, status (matched case-insensitively
against the row's last_event), folder (one of "outbox", "sent",
"scheduled" or "failed" — any other value is rejected with a 422) and
search (recipients, subject and sender). q is the server's alias
for search, honoured only when search is absent. GET /emails
40 41 42 43 44 45 |
# File 'lib/mailblastr/emails.rb', line 40 def list(params = {}) query = Client.pagination(params).merge( Client.filters(params, :campaign_id, :automation_id, :source, :domain_id, :status, :search, :q, :folder) ) Client.request(:get, "/emails", query: query) end |
.list_attachments(email_id) ⇒ Object
List a sent email's attachments. GET /emails/:id/attachments
62 63 64 |
# File 'lib/mailblastr/emails.rb', line 62 def (email_id) Client.request(:get, "/emails/#{Client.path_escape(email_id)}/attachments") end |
.send(params, options = {}) ⇒ Object
Send a single email. POST /emails Mailblastr::Emails.send({ from: "...", to: ["..."], subject: "...", html: "..." })
Write ordinary links. Anchors, markdown links and bare URLs/domains in BOTH the :html and :text bodies are converted to tracked redirects at send time (when the sending domain has click tracking on), so a click is recorded whichever alternative the recipient's mail client renders. Opt-out links are never wrapped, and the content you send is stored and returned UNCHANGED — only the delivered copy carries the tracking URL. Pass { idempotency_key: "order-123" } as the second argument to retry safely.
17 18 19 |
# File 'lib/mailblastr/emails.rb', line 17 def send(params, = {}) Client.request(:post, "/emails", body: params, options: ) end |
.sources ⇒ Object
Per-source send metrics, one row per origin. kind is "campaign",
"automation", "api" (one-off API-key sends, including mail sent before
the send origin was recorded) or "individual" (dashboard-composed
one-offs); id, name, subject and status are null for both the
"api" and "individual" rows. Not paginated. GET /emails/sources
52 53 54 |
# File 'lib/mailblastr/emails.rb', line 52 def sources Client.request(:get, "/emails/sources") end |
.update(email_id, params) ⇒ Object
Reschedule a scheduled email. PATCH /emails/:id Mailblastr::Emails.update("email_id", { scheduled_at: "2026-08-01T09:00:00Z" })
73 74 75 |
# File 'lib/mailblastr/emails.rb', line 73 def update(email_id, params) Client.request(:patch, "/emails/#{Client.path_escape(email_id)}", body: params) end |