rails_mailersend 0.5.0 → 0.6.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 +4 -4
- data/README.md +34 -0
- data/lib/mailersend_rails/delivery_method.rb +41 -1
- data/lib/mailersend_rails/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: f3615a45b8f5ec8f462c1a590064cd923ff3e5ede15dcfa3470aeb83077a7858
|
|
4
|
+
data.tar.gz: 8f67af0e86500603cc5216f2504d06a4b3f7ba6b4903e270b3e3df59076be672
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: d443297aedd5a29abb72ad9ef7bb74cd021bdb208e1998fde63c2e3553bb8951f4249a80cf723a2b3008cc2185960937361c6a7d83a90afca94ff8835bdcebfb
|
|
7
|
+
data.tar.gz: b40dc56a2d2322607c25d51df1a2eb18af3b0cafeff698944a863631c43dbc548d278a00c7e31e5273bc17416c9a3f68aca99c32a0f0ea7c5e2ab9b63f915625
|
data/README.md
CHANGED
|
@@ -80,6 +80,40 @@ fields rather than a MIME message, and these are the two worth translating. Both
|
|
|
80
80
|
are paid-plan only at MailerSend, which answers a free account carrying them with
|
|
81
81
|
a 422 — loudly, rather than with an unthreaded reply nobody can account for.
|
|
82
82
|
|
|
83
|
+
## Link and open tracking
|
|
84
|
+
|
|
85
|
+
MailerSend can rewrite every link in a message to a redirector on its own domain. For
|
|
86
|
+
marketing mail that is the point. For a message carrying a credential it is two problems at
|
|
87
|
+
once: the token is handed to a third party and kept in their click reporting, and the
|
|
88
|
+
rewritten URL is no longer yours — so an iOS Universal Link stops matching your
|
|
89
|
+
`apple-app-site-association` and opens a browser instead of your app. For a single-use
|
|
90
|
+
sign-in link that means it is spent somewhere the app cannot see it.
|
|
91
|
+
|
|
92
|
+
Set the switches per message, on the mailer that needs them:
|
|
93
|
+
|
|
94
|
+
```ruby
|
|
95
|
+
class SessionMailer < ApplicationMailer
|
|
96
|
+
def sign_in(user)
|
|
97
|
+
headers["X-MailerSend-Track-Clicks"] = "false"
|
|
98
|
+
mail to: user.email, subject: "Your sign-in link"
|
|
99
|
+
end
|
|
100
|
+
end
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
| Header | MailerSend field |
|
|
104
|
+
|---|---|
|
|
105
|
+
| `X-MailerSend-Track-Clicks` | `settings.track_clicks` |
|
|
106
|
+
| `X-MailerSend-Track-Opens` | `settings.track_opens` |
|
|
107
|
+
| `X-MailerSend-Track-Content` | `settings.track_content` |
|
|
108
|
+
|
|
109
|
+
Each takes `"true"` or `"false"`, case-insensitively. A message that sets none says nothing
|
|
110
|
+
about tracking, and MailerSend falls back to the domain's own setting — so this changes
|
|
111
|
+
nothing for the mail you already send.
|
|
112
|
+
|
|
113
|
+
A value that is neither raises, rather than being quietly dropped. The caller asking for
|
|
114
|
+
tracking off is usually sending a credential, and the failure mode of guessing is a token
|
|
115
|
+
routed through a redirector without anybody noticing.
|
|
116
|
+
|
|
83
117
|
## Inbound mail
|
|
84
118
|
|
|
85
119
|
Optional, and only loads when the app has Action Mailbox. MailerSend posts the
|
|
@@ -29,6 +29,24 @@ module MailersendRails
|
|
|
29
29
|
OPEN_TIMEOUT = 15
|
|
30
30
|
READ_TIMEOUT = 30
|
|
31
31
|
|
|
32
|
+
# MailerSend's per-message tracking switches, and the header each is set from.
|
|
33
|
+
#
|
|
34
|
+
# Tracking rewrites every link in the message to a redirector on MailerSend's
|
|
35
|
+
# domain. For marketing mail that is the point. For a message carrying a
|
|
36
|
+
# credential it is two problems: the token is handed to a third party and
|
|
37
|
+
# logged in their click reporting, and the rewritten URL is no longer yours --
|
|
38
|
+
# so an iOS Universal Link stops matching your apple-app-site-association and
|
|
39
|
+
# opens a browser instead of your app, which for a single-use sign-in link
|
|
40
|
+
# means it is spent somewhere the app cannot see.
|
|
41
|
+
#
|
|
42
|
+
# Absent means absent: MailerSend falls back to the domain's own setting, so a
|
|
43
|
+
# message that says nothing keeps whatever the account is configured for.
|
|
44
|
+
TRACKING = {
|
|
45
|
+
"track_clicks" => "X-MailerSend-Track-Clicks",
|
|
46
|
+
"track_opens" => "X-MailerSend-Track-Opens",
|
|
47
|
+
"track_content" => "X-MailerSend-Track-Content"
|
|
48
|
+
}.freeze
|
|
49
|
+
|
|
32
50
|
attr_reader :settings
|
|
33
51
|
|
|
34
52
|
def initialize(settings = {})
|
|
@@ -57,10 +75,32 @@ module MailersendRails
|
|
|
57
75
|
"text" => mail.text_part&.body&.decoded,
|
|
58
76
|
"html" => html_for(mail),
|
|
59
77
|
"in_reply_to" => message_ids_in(mail[:in_reply_to]).first,
|
|
60
|
-
"references" => message_ids_in(mail[:references])
|
|
78
|
+
"references" => message_ids_in(mail[:references]),
|
|
79
|
+
"settings" => tracking_in(mail)
|
|
61
80
|
}.reject { |_, value| omit?(value) }
|
|
62
81
|
end
|
|
63
82
|
|
|
83
|
+
# The tracking switches this message sets, if any. See TRACKING.
|
|
84
|
+
#
|
|
85
|
+
# A value that is neither "true" nor "false" raises rather than being
|
|
86
|
+
# dropped, for the same reason a failed delivery raises: the caller that
|
|
87
|
+
# asked for tracking off is usually sending a credential, and the failure
|
|
88
|
+
# mode of guessing is a token quietly routed through a redirector. A typo
|
|
89
|
+
# here is a mistake in the sender's own code and shows up the first time
|
|
90
|
+
# that mailer is exercised.
|
|
91
|
+
def tracking_in(mail)
|
|
92
|
+
TRACKING.each_with_object({}) do |(field, header), settings|
|
|
93
|
+
raw = mail[header]&.to_s&.strip
|
|
94
|
+
next if raw.nil? || raw.empty?
|
|
95
|
+
|
|
96
|
+
case raw.downcase
|
|
97
|
+
when "true" then settings[field] = true
|
|
98
|
+
when "false" then settings[field] = false
|
|
99
|
+
else raise DeliveryError, "#{header} must be \"true\" or \"false\", got #{raw.inspect}"
|
|
100
|
+
end
|
|
101
|
+
end
|
|
102
|
+
end
|
|
103
|
+
|
|
64
104
|
# In-Reply-To and References, in the form MailerSend asks for them.
|
|
65
105
|
#
|
|
66
106
|
# Threading is what puts a reply under the message it answers rather than
|