wakio 0.1.3 → 0.1.4

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: 41b4696d5b5dcea8872174fce7d104adeb163eb775555de498214e2ba1c49711
4
- data.tar.gz: 1b7eaa7f2b2e4540b4f60a4beb979718262b54a35e64c34a52fc931aa1a748d0
3
+ metadata.gz: 38874499f377ba462c3e6b6309132fc3e755f83d53ba173c3f45c6f3c7a71b22
4
+ data.tar.gz: dd55b75c7b3d5ba2dd490c6d24c18bf284b4c389385e14627e840b5d73e56ea7
5
5
  SHA512:
6
- metadata.gz: ec7af6244e5c01a97da9b8455b23475dbf4d26a86df036e0cc97ec341020b19dc7b9b851307185f5d4d2a8052a3e53cb4db37a28f350c39acd23ea6762baae07
7
- data.tar.gz: 99b951382c14c5ee5732411f3ce2f4fc75c3128c9283d495d48763881fae5d1593630886970c55a82f89148a519a881f2e7ddc41b8968d2e252726381ffaf97b
6
+ metadata.gz: 96d287db49a082bdd79f41500482a7141e0aedae7ed1f7508ae070321a4ab10ac133496f6ba3214b328b780b13042a61e7d2f600e86a397337dfe0773047f6fe
7
+ data.tar.gz: 92402e1b1906380ede53db33c50f1ba806d746d8d63f9b3b8760105427e7a3349093dbfc46b1172ca1bdca07a73b4c671e6f7f48feea85930ea8f57053b97d5a
data/README.md CHANGED
@@ -18,7 +18,7 @@ config.action_mailer.wakio_settings = {
18
18
 
19
19
  `host` must be `https`. An `http` host other than `localhost` raises `Wakio::Misconfigured` before anything is sent, so the API key never travels in cleartext.
20
20
 
21
- Every existing mailer keeps working unchanged. Its rendered subject, its HTML and text parts, and its `from` go to Wakio as they are, with no server-side template involved. A text-only mailer sends a text-only email.
21
+ Every existing mailer keeps working unchanged. Its rendered subject, its HTML and text parts, and its `from` go to Wakio as they are, with no server-side template involved. A text-only mailer sends a text-only email. Recipients keep their display names (`to`, `cc`, `bcc`); `reply_to` is sent as bare addresses.
22
22
 
23
23
  The `from` domain must be one of your account's sendable sending domains, matched exactly: `hello@acme.com` needs `acme.com` itself verified, and a verified `mail.acme.com` does not cover it. A mismatch is refused with `422 no_verified_sending_domain`. A mailer with no `from` goes out as `no-reply@` your first sendable domain. `GET /v1/sending-identities` reports which domains are currently sendable.
24
24
 
@@ -26,7 +26,7 @@ The `from` domain must be one of your account's sendable sending domains, matche
26
26
 
27
27
  **A suppressed address raises.** Wakio suppresses addresses that have hard-bounced or complained, and accepts a send to one rather than refusing it. The response names each recipient's status, and `deliver!` raises `Wakio::Suppressed` (a `Wakio::DeliveryError`) when every recipient was suppressed, so a one-recipient mailer to a suppressed address fails loudly instead of reporting success. Retrying cannot help, so handle it rather than letting a job backend retry it: `rescue_from Wakio::Suppressed` in your mailer also catches it under `deliver_later`. A send where only some recipients were suppressed returns normally; check the returned response's `deliveries` for which ones.
28
28
 
29
- **Refusals split by whether a retry can ever send the message.** A refusal from Wakio is a `Wakio::DeliveryError` carrying `status`, `code` (the response's `error`, such as `"invalid_request"`) and the parsed `body`.
29
+ **Refusals split by whether a retry can ever send the message.** A refusal from Wakio is a `Wakio::DeliveryError` carrying `status`, `code` (the response's `error`, such as `"invalid_request"`) and the parsed `body`. `code` is nil when the response is not JSON or names no `error`, so fall back to `status` when you log it.
30
30
 
31
31
  - `Wakio::Rejected`: retrying this message cannot help. `400`, `413`, `422 invalid_request` (usually a mailer bug; `detail` names the field) and `422 idempotency_key_reused` (an earlier request with that key already went out). Report it and drop it.
32
32
  - `Wakio::Misconfigured`: the account or its configuration is wrong, and the same message sends once that is fixed. `401 invalid_api_key`, `402 not_entitled`, `403 account_suspended`, `404`, `422 no_verified_sending_domain`, `422 unknown_template`, a redirect, an `http` host, and any 4xx this gem does not know. Retry it.
@@ -43,6 +43,8 @@ end
43
43
  config.action_mailer.delivery_job = "WakioDeliveryJob"
44
44
  ```
45
45
 
46
+ On Sidekiq, skip that job. Sidekiq already retries every failed job, about 25 times over three weeks, so the risk runs the other way: a message that can never send is retried for weeks. What you need there is the `rescue_from` below, which stops `Suppressed` and `Rejected` from reaching Sidekiq at all.
47
+
46
48
  The mailer's `rescue_from` below catches `Suppressed` and `Rejected` before the job sees them.
47
49
 
48
50
  ```ruby
@@ -73,9 +73,9 @@ module Wakio
73
73
  def payload_for(mail)
74
74
  html, text = bodies_for(mail)
75
75
  {
76
- to: Array(mail.to),
77
- cc: Array(mail.cc),
78
- bcc: Array(mail.bcc),
76
+ to: named(mail, :to),
77
+ cc: named(mail, :cc),
78
+ bcc: named(mail, :bcc),
79
79
  reply_to: Array(mail.reply_to),
80
80
  from: mail[:from]&.value,
81
81
  subject: mail.subject.to_s.gsub(/[[:space:]]+/, " ").strip,
@@ -84,6 +84,17 @@ module Wakio
84
84
  }.compact
85
85
  end
86
86
 
87
+ # `formatted` keeps each recipient's display name, which Wakio shows in the To line and ignores
88
+ # for matching. reply_to stays bare above: Wakio takes no name there.
89
+ # A header Mail cannot parse is an UnstructuredField with no #formatted; sent as written, Wakio
90
+ # refuses it and the host sees Wakio::Rejected rather than a NoMethodError.
91
+ def named(mail, field)
92
+ header = mail[field]
93
+ return [] if header.nil?
94
+
95
+ header.respond_to?(:formatted) ? Array(header.formatted) : [ header.value.to_s ]
96
+ end
97
+
87
98
  # Parts, not `mail.body.decoded`: on a multipart message that is `""`, and multipart is
88
99
  # what every Rails mailer with both an .html.erb and a .text.erb view produces.
89
100
  def bodies_for(mail)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: wakio
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - WorkersLab LLC