1 # smbcloud-email (Ruby)
2
3 Ruby bindings for the **smbCloud transactional email API**, powered by the shared
4 Rust SDK ([`smbcloud-email-sdk`](../../../crates/smbcloud-email-sdk)) and a native
5 [Magnus](https://github.com/matsadler/magnus) extension.
6
7 ## Install
8
9 ```ruby
10 gem 'smbcloud-email'
11 ```
12
13 The gem ships a native extension; `bundle install` compiles it (Rust toolchain
14 required).
15
16 ## Usage
17
18 ```ruby
19 require 'email'
20
21 client = SmbCloud::Email.client(
22 environment: SmbCloud::Email::Environment::PRODUCTION,
23 api_key: 'smb_mail_your_key',
24 )
25
26 # Send
27 sent = client.send(
28 from: 'billing@example.com',
29 to: ['customer@acme.com'],
30 subject: 'Your receipt',
31 html: '<h1>Thanks!</h1>',
32 text: 'Thanks!',
33 idempotency_key: 'receipt-2026-0001',
34 )
35 sent[:id] # => "eml_…"
36 sent[:status] # => 1 (sent)
37
38 # Attachments, cc/bcc, headers, tags
39 client.send(
40 from: 'billing@example.com',
41 to: ['customer@acme.com'],
42 subject: 'Invoice',
43 html: '<p>See attached.</p>',
44 cc: ['accounts@acme.com'],
45 attachments: [{ filename: 'invoice.pdf', content_base64: 'JVBERi0xLjQ...' }],
46 headers: { 'X-Entity-Ref-ID' => 'inv_123' },
47 tags: { 'category' => 'invoice' },
48 )
49
50 # Delivery status (needs a read-scope key)
51 message = client.get_message('eml_…')
52 message[:status]
53 message[:events]
54
55 client.list_messages(status: 'bounced', limit: 20)
56 ```
57
58 Mint an API key for your Mail app in the smbCloud console. Sending is scoped to
59 that app's verified domain; reading messages needs a read-scope key.
60
61 ## Errors
62
63 Non-2xx API responses and transport failures raise `SmbCloud::Email::Error`, with
64 the parsed response body available on `#payload`.
65
66 ## License
67
68 MIT