mailhive 0.2.0 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: edcbe7300fa0125e510b97d0225cd3b04b134e3ffa31cb6b53c8964659600615
4
- data.tar.gz: e7de31bd34f7cc7d0b2339bcdc63fdee039d02304c4b8d3554885aa159743f50
3
+ metadata.gz: 9bb1ea422aebb86c3f13a4125f29af35ececc6e6cde468b4d40561272c85e52c
4
+ data.tar.gz: 718e5848772457d73744a7b238dce479e0685ee32bbc8fcc529872f319873016
5
5
  SHA512:
6
- metadata.gz: a971410f091c7727ba4e967457b781da96af928427ae27deed1e751ca58334d3c4dcd1d8fffdc412008d27be4378002fd5ff257c0eda1e40fbaafb5b1fe641c6
7
- data.tar.gz: ce3e746f965c8ca30dba2eb2b7858279d78bba7d47c7e6d2a4951d2bf5ab9b686c20bcaa50054fc5768a9e65b397e9dd9f106d5aa5684b2432142710c892c61d
6
+ metadata.gz: e167f84ea1047de96fafa0da90bc233335029c7b56beb1e525b3c9adcde4a4d53f98c04cdd701fa700b36d12cbf3e25524d2d5c56cfd3343eb4a5c1b40ce4367
7
+ data.tar.gz: 3ac49c2bec0c3a8e1f7a96a015cdf7c27d4a62bad41b70e6bd162ff717618639a1f1fb3b5ea215848373ffb83b3f8d2c38cfe21a2a49a8a56a3bc1ba8d9d7bf1
data/CHANGELOG.md CHANGED
@@ -1,5 +1,10 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.3.0 (2026-11-09)
4
+
5
+ - `rejected` on accepted and retrieved emails: the addresses dropped before sending because they can't work (a mistyped, non-existent or mail-less domain), mapped to the reason. They never reach the sending engine, so they can't bounce.
6
+ - `emails.validate` checks addresses on a form before sending: syntax, mistyped domains (with the address probably meant), domains that don't exist or have no mail server, and your suppression list. Nothing is sent or stored.
7
+
3
8
  ## 0.2.0 (2026-10-26)
4
9
 
5
10
  - Audiences and contacts, for API keys with Full access: `audiences.list`, `create` and `rename`; `contacts.list`, `add`, `upsert`, `upsert_batch`, `get`, `update`, `unsubscribe` and `delete`.
data/README.md CHANGED
@@ -46,6 +46,17 @@ client.emails.send_batch([email1, email2]) # up to 100; all accepted or none. Re
46
46
  client.emails.get(email_id) # {status: "delivered", …}
47
47
  ```
48
48
 
49
+ The accepted email's `rejected` maps any address dropped before sending because it can't work (a mistyped, non-existent or mail-less domain) to the reason; those addresses never bounce.
50
+
51
+ ### Check addresses before sending
52
+
53
+ Run the same checks on a form, while the person can still fix a typo. Nothing is sent or stored:
54
+
55
+ ```ruby
56
+ client.emails.validate(["ada@gmial.com"])
57
+ # => [{ email: "ada@gmial.com", normalized: "ada@gmial.com", valid: false, reason: "domain_typo", suggestion: "ada@gmail.com", message: "The domain looks mistyped." }]
58
+ ```
59
+
49
60
  `emails.send` sends an email: on that object, use `__send__` or `public_send` for Ruby's dynamic dispatch.
50
61
 
51
62
  ## Rails (ActionMailer)
@@ -8,7 +8,9 @@ module Mailhive
8
8
  @client = client
9
9
  end
10
10
 
11
- # Sends one email and returns the accepted email: {id:, status:, suppressed:, test:}.
11
+ # Sends one email and returns the accepted email: {id:, status:, suppressed:, rejected:, test:}.
12
+ # +rejected+ maps the addresses dropped before sending because they can't
13
+ # work (a mistyped, non-existent or mail-less domain) to the reason.
12
14
  #
13
15
  # Keys match the API reference exactly (symbols or strings): from, to,
14
16
  # cc, bcc, subject, html, text, template_id, variables, reply_to,
@@ -33,6 +35,18 @@ module Mailhive
33
35
  @client.request("GET", "/send/emails/#{self.class.escape(id)}")
34
36
  end
35
37
 
38
+ # The checks sending applies, for a form to run while the person can
39
+ # still fix a typo: syntax, mistyped and non-existent domains, domains
40
+ # with no mail server, and your suppression list. Nothing is sent or
41
+ # stored. Returns one hash per address, in order:
42
+ # { email:, normalized:, valid:, reason:, message:, suggestion: }.
43
+ #
44
+ # client.emails.validate(["ada@gmial.com"])
45
+ # # => [{ email: "ada@gmial.com", valid: false, reason: "domain_typo", suggestion: "ada@gmail.com", … }]
46
+ def validate(emails)
47
+ @client.request("POST", "/send/emails/validate", { emails: Array(emails).map(&:to_s) })[:data]
48
+ end
49
+
36
50
  def inspect
37
51
  "#<#{self.class.name}>"
38
52
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Mailhive
4
- VERSION = "0.2.0"
4
+ VERSION = "0.3.0"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mailhive
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Naszat