mail-x_smtpapi 1.0.0.alpha2 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +40 -6
- data/lib/mail_x_smtpapi/accessors.rb +6 -0
- data/lib/mail_x_smtpapi/field.rb +3 -2
- data/lib/mail_x_smtpapi/version.rb +1 -1
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ff36feee769b1735b03c6334a653e02eba9b0866
|
4
|
+
data.tar.gz: 5e54b8c395024ca89d1df5f4930118905a7f6aee
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f6e9b53cec3cba4b2af9574f850eb1eda94064c3e5fcc0e73a58dd51270171639948987cd7b81c3f156cff4c676d06bbc557562e1f322f175fa10b99720bd41d
|
7
|
+
data.tar.gz: efb9fdc5fc2c6bb3f61f70ec6d4bf64cfc1bfe49c776099bd53198c78ab49a59315cafd304c0d35dfa5ab2985ccbc6785793cac120fc2da8b4376cf57e810004
|
data/README.md
CHANGED
@@ -1,6 +1,8 @@
|
|
1
1
|
# Mail::X::Smtpapi
|
2
2
|
|
3
|
-
Integrates
|
3
|
+
Integrates support for SendGrid's X-SMTPAPI field into the [Mail](https://github.com/mikel/mail) gem.
|
4
|
+
|
5
|
+
Please refer to [SendGrid docs](https://sendgrid.com/docs/API_Reference/SMTP_API/index.html) for ideas of what you can do with the X-SMTPAPI header!
|
4
6
|
|
5
7
|
## Installation
|
6
8
|
|
@@ -20,19 +22,51 @@ Or install it yourself as:
|
|
20
22
|
|
21
23
|
## Usage
|
22
24
|
|
23
|
-
Write into the SMTPAPI header from anywhere with access to the `mail` object.
|
25
|
+
Write into the X-SMTPAPI header from anywhere with access to the `mail` object.
|
24
26
|
|
25
27
|
### Example: Rails Mailer
|
26
28
|
|
27
|
-
(
|
29
|
+
Adapting the [Rails Guide example](http://guides.rubyonrails.org/v4.0.8/action_mailer_basics.html#edit-the-mailer):
|
28
30
|
|
29
|
-
|
31
|
+
```ruby
|
32
|
+
class UserMailer < ActionMailer::Base
|
33
|
+
|
34
|
+
def welcome(user)
|
35
|
+
@user = user
|
30
36
|
|
31
|
-
|
37
|
+
mail.smtpapi.category = 'welcome'
|
38
|
+
mail.smtpapi.unique_args['user_id'] = @user.id
|
39
|
+
|
40
|
+
mail(to: @user.email, subject: 'Welcome to My Awesome Site')
|
41
|
+
end
|
42
|
+
|
43
|
+
end
|
44
|
+
```
|
32
45
|
|
33
46
|
### Example: Mail Interceptor
|
34
47
|
|
35
|
-
(
|
48
|
+
Adapting the [Rails Guide example](http://guides.rubyonrails.org/v4.0.8/action_mailer_basics.html#intercepting-emails):
|
49
|
+
|
50
|
+
```ruby
|
51
|
+
class SandboxEmailInterceptor
|
52
|
+
def self.delivering_email(message)
|
53
|
+
message.smtpapi.unique_args['original'] = message.to
|
54
|
+
message.to = ['sandbox@example.com']
|
55
|
+
end
|
56
|
+
end
|
57
|
+
```
|
58
|
+
|
59
|
+
### Example: Template Helper
|
60
|
+
|
61
|
+
```ruby
|
62
|
+
module MailerABHelper
|
63
|
+
def show_variant?(name)
|
64
|
+
variant = rand(2) == 0 ? 'main' : 'alternate'
|
65
|
+
mail.smtpapi.unique_args["#{name}_variant"] = variant
|
66
|
+
return variant == 'alternate'
|
67
|
+
end
|
68
|
+
end
|
69
|
+
```
|
36
70
|
|
37
71
|
## Contributing
|
38
72
|
|
data/lib/mail_x_smtpapi/field.rb
CHANGED
@@ -12,6 +12,7 @@ module MailXSMTPAPI
|
|
12
12
|
include UniqueArguments
|
13
13
|
include Category
|
14
14
|
include Filters
|
15
|
+
include Sections
|
15
16
|
|
16
17
|
def initialize(value = nil, charset = 'utf-8')
|
17
18
|
self.charset = charset
|
@@ -27,8 +28,8 @@ module MailXSMTPAPI
|
|
27
28
|
end
|
28
29
|
end
|
29
30
|
|
30
|
-
# to take advantage of folding, decoded must return a string
|
31
|
-
#
|
31
|
+
# to take advantage of folding, decoded must return a string of
|
32
|
+
# JSON with extra spaces inserted for line wrapping.
|
32
33
|
def decoded
|
33
34
|
JSON.generate(value).gsub(/(["\]}])([,:])(["\[{])/, '\\1\\2 \\3')
|
34
35
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mail-x_smtpapi
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.0
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Lance Ivy
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2015-01-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -88,9 +88,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
88
88
|
version: '0'
|
89
89
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
90
90
|
requirements:
|
91
|
-
- - "
|
91
|
+
- - ">="
|
92
92
|
- !ruby/object:Gem::Version
|
93
|
-
version:
|
93
|
+
version: '0'
|
94
94
|
requirements: []
|
95
95
|
rubyforge_project:
|
96
96
|
rubygems_version: 2.2.2
|