sendgrid-actionmailer 0.2.1 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 279c424c1fb91a3d43959b079eb62ff18cc49f4b
4
- data.tar.gz: 612acbbe466f59ef1cfe8fb43d3e50b905b480c7
3
+ metadata.gz: 20a38e557a4c77001c637d5d94407d99113b9661
4
+ data.tar.gz: 2dc48c9d94c830a664cb0105e8ad8d068eca449a
5
5
  SHA512:
6
- metadata.gz: efa913396a27fca27aaa83f3aa4ee00f9c59a8e5706d881d097e43e7a2d246fb06283f6c58a41ebe468fd997a6b2b7e56fe43b444597c31fe465bfaca2ff007e
7
- data.tar.gz: 22c1f0dc2f693e4788cd508ccb2a4a7997e4437423ceea8c6eeaf5372dd2905c52447660dd0590f548f1f17dc2faa07410f3efebe1732af47a587502b88702fc
6
+ metadata.gz: 059add8c5b4fe2d4232ec038c2686b79ec93c8dbeed984bd806b3f61d71e3afeb961ea05181f603b7105ba50eb34709ddb108c3cfc5997d5b66a66d5083c499a
7
+ data.tar.gz: c60cf2c4baeeb7468c03cdd6631eeb5b7516a287c88750a2ad7afcc882ae6c81ec59f0c501a811bff046d07c7e7f5b5ca915db223c2431ea9fe992eb06e3b3ae
data/.travis.yml CHANGED
@@ -1,11 +1,13 @@
1
1
  sudo: false
2
2
  language: ruby
3
3
  rvm:
4
- - 2.2.1
5
- - 2.0.0
6
- - 1.9.3
7
- before_script:
8
- - bundle install
4
+ - 2.5.1
5
+ - 2.4.4
6
+ - 2.3.4
7
+ - 2.3.7
8
+ - 2.2.10
9
+ before_install:
10
+ - gem install bundler
9
11
  gemfile:
10
12
  - gemfiles/mail_2.5.gemfile
11
13
  - gemfiles/mail_2.6.gemfile
data/Appraisals CHANGED
@@ -5,3 +5,7 @@ end
5
5
  appraise "mail-2.6" do
6
6
  gem "mail", "2.6.4"
7
7
  end
8
+
9
+ appraise "mail-2.7" do
10
+ gem "mail", "2.7.0"
11
+ end
data/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # Change Log
2
2
 
3
+ ## 2.0.0 - 2018-08-15
4
+
5
+ ### Changed
6
+
7
+ - Compatibility with `sendgrid-ruby` v5.0.
8
+
3
9
  ## 0.2.1 - 2016-04-26
4
10
 
5
11
  ### Fixed
data/Gemfile CHANGED
@@ -2,3 +2,8 @@ source 'https://rubygems.org'
2
2
 
3
3
  # Specify your gem's dependencies in sendgrid-actionmailer.gemspec
4
4
  gemspec
5
+
6
+ if RUBY_VERSION < '2'
7
+ gem 'public_suffix', '~> 1.4.6'
8
+ gem 'mime-types', '~> 2.99'
9
+ end
data/README.md CHANGED
@@ -1,23 +1,12 @@
1
1
  # SendGrid ActionMailer
2
2
 
3
- An ActionMailer adapter to send email using SendGrid's HTTPS Web API (instead of SMTP).
4
-
5
- [![BuildStatus](https://travis-ci.org/eddiezane/sendgrid-actionmailer.svg?branch=master)](https://travis-ci.org/eddiezane/sendgrid-actionmailer)
3
+ An ActionMailer adapter to send email using SendGrid's HTTPS Web API (instead of SMTP). Compatible with Rails 5 and Sendgrid API v3.
6
4
 
7
5
  ## Installation
8
6
 
9
7
  Add this line to your application's Gemfile:
10
8
 
11
- gem 'sendgrid-actionmailer'
12
-
13
- And then execute:
14
-
15
- $ bundle
16
-
17
- Or install it yourself as:
18
-
19
- $ gem install sendgrid-actionmailer
20
-
9
+ gem 'sendgrid-actionmailer', github: 'eddiezane/sendgrid-actionmailer'
21
10
 
22
11
  ## Usage
23
12
 
@@ -26,74 +15,196 @@ Create a [SendGrid API Key](https://app.sendgrid.com/settings/api_keys) for your
26
15
  ```ruby
27
16
  config.action_mailer.delivery_method = :sendgrid_actionmailer
28
17
  config.action_mailer.sendgrid_actionmailer_settings = {
29
- api_key: ENV['SENDGRID_API_KEY']
18
+ api_key: ENV['SENDGRID_API_KEY'],
19
+ raise_delivery_errors: true
30
20
  }
31
21
  ```
32
22
 
33
23
  Normal ActionMailer usage will now transparently be sent using SendGrid's Web API.
34
24
 
35
- ### X-SMTPAPI
25
+ ```mail(to: 'example@email.com', subject: 'email subject', body: 'email body')```
36
26
 
37
- You may optionally set SendGrid's [X-SMTPAPI](https://sendgrid.com/docs/API_Reference/SMTP_API/index.html) header on messages to control SendGrid specific functionality. This header must be set to a JSON string.
27
+ ## SendGrid Mail Extensions
38
28
 
39
- ```ruby
40
- class UserMailer < ApplicationMailer
41
- def welcome_email(user)
42
- headers['X-SMTPAPI'] = {
43
- category: ['newuser']
44
- }.to_json
45
-
46
- mail(to: user.email, subject: 'Welcome to My Awesome Site')
47
- end
48
- end
49
- ```
29
+ The Mail functionality is extended to include additional attributes provided by the Sendgrid API.
50
30
 
51
- The following `X-SMTPAPI` options are supported:
31
+ [Sendgrid v3 API Documentation](https://sendgrid.com/docs/API_Reference/api_v3.html)
52
32
 
53
- - `filters`
54
- - `category`
55
- - `send_at`
56
- - `send_each_at`
57
- - `section`
58
- - `sub`
59
- - `asm_group_id`
60
- - `unique_args`
61
- - `ip_pool`
33
+ ### template_id (string)
34
+ The id of a template that you would like to use. If you use a template that contains a subject and content (either text or html), you do not need to specify those at the personalizations nor message level.
62
35
 
63
- #### X-SMTPAPI Defaults
36
+ ```mail(to: 'example@email.com', subject: 'email subject', body: 'email body', template_id: 'template_1')```
64
37
 
65
- Default values for the `X-SMTPAPI` header may be set at different levels using ActionMailer's normal options for setting default headers. However, since `X-SMTPAPI` is treated as a single string value, it's important to note that default values at different levels will not get merged together. So if you override the `X-SMTPAPI` header at any level, you may need to repeat any default values at more specific levels.
38
+ ### sections (object)
39
+ An object of key/value pairs that define block sections of code to be used as substitutions.
66
40
 
67
- Global defaults can be set inside `config/application.rb`:
41
+ ```mail(to: 'example@email.com', subject: 'email subject', body: 'email body', sections: {'%header%' => "<h1>Header</h1>"})```
68
42
 
69
- ```ruby
70
- config.action_mailer.default_options = {
71
- 'X-SMTPAPI' => {
72
- ip_pool: 'marketing_ip_pool'
73
- }.to_json
74
- }
75
- ```
43
+ ### headers (object)
44
+ An object containing key/value pairs of header names and the value to substitute for them. You must ensure these are properly encoded if they contain unicode characters. Must not be one of the reserved headers.
76
45
 
77
- Per-mailer defaults can be set inside an ActionMailer class:
46
+ ```mail(to: 'example@email.com', subject: 'email subject', body: 'email body', headers: {'X-CUSTOM-HEADER' => "foo"})```
78
47
 
79
- ```ruby
80
- class NewsletterMailer < ApplicationMailer
81
- default('X-SMTPAPI' => {
82
- category: ['newsletter'],
83
-
84
- # Assuming the above "config.action_mailer.default_options" global default
85
- # example, the default "ip_pool" value must be repeated here if you want
86
- # that default value to also apply to this specific mailer that's
87
- # specifying it's own default X-SMTPAPI value.
88
- ip_pool: 'marketing_ip_pool'
89
- }.to_json)
90
- end
91
- ```
48
+ ### categories (array)
49
+ An array of category names for this message. Each category name may not exceed 255 characters.
50
+
51
+ ```mail(to: 'example@email.com', subject: 'email subject', body: 'email body', categories: ['marketing', 'sales'])```
52
+
53
+ ### custom_args (object)
54
+ Values that are specific to the entire send that will be carried along with the email and its activity data. Substitutions will not be made on custom arguments, so any string that is entered into this parameter will be assumed to be the custom argument that you would like to be used. This parameter is overridden by personalizations[x].custom_args if that parameter has been defined. Total custom args size may not exceed 10,000 bytes.
55
+
56
+ ```mail(to: 'example@email.com', subject: 'email subject', body: 'email body', custom_args: {campaign: 'welcome'})```
57
+
58
+ ### send_at (integer)
59
+ A unix timestamp allowing you to specify when you want your email to be delivered. This may be overridden by the personalizations[x].send_at parameter. You can't schedule more than 72 hours in advance. If you have the flexibility, it's better to schedule mail for off-peak times. Most emails are scheduled and sent at the top of the hour or half hour. Scheduling email to avoid those times (for example, scheduling at 10:53) can result in lower deferral rates because it won't be going through our servers at the same times as everyone else's mail.
60
+
61
+ ### batch_id (string)
62
+ This ID represents a batch of emails to be sent at the same time. Including a batch_id in your request allows you include this email in that batch, and also enables you to cancel or pause the delivery of that batch. For more information, see [cancel_schedule_send](https://sendgrid.com/docs/API_Reference/Web_API_v3/cancel_schedule_send.html)
63
+
64
+ ```mail(to: 'example@email.com', subject: 'email subject', body: 'email body', send_at: 1443636842, batch_id: 'batch1')```
65
+
66
+ ### asm (object)
67
+ An object allowing you to specify how to handle unsubscribes.
68
+
69
+ #### group_id (integer) *required
70
+ The unsubscribe group to associate with this email.
71
+
72
+ #### groups_to_display (array[integer])
73
+ An array containing the unsubscribe groups that you would like to be displayed on the unsubscribe preferences page.
74
+
75
+ ```mail(to: 'example@email.com', subject: 'email subject', body: 'email body', asm: group_id: 99, groups_to_display: [4,5,6,7,8])```
76
+
77
+ ### ip_pool_name (string)
78
+ The IP Pool that you would like to send this email from.
79
+
80
+ ```mail(to: 'example@email.com', subject: 'email subject', body: 'email body', ip_pool_name: 'marketing_ips')```
81
+
82
+ ### mail_settings (object)
83
+ A collection of different mail settings that you can use to specify how you would like this email to be handled.
84
+
85
+ #### bcc (object)
86
+ This allows you to have a blind carbon copy automatically sent to the specified email address for every email that is sent.
87
+
88
+ ##### enable (boolean)
89
+ Indicates if this setting is enabled.
90
+
91
+ ##### email (string)
92
+ The email address that you would like to receive the BCC.
93
+
94
+ ```mail(to: 'example@email.com', subject: 'email subject', body: 'email body', mail_settings: {bcc: {enable: true, email: 'bcc@example.com}})```
95
+
96
+ #### bypass_list_management (object)
97
+ Allows you to bypass all unsubscribe groups and suppressions to ensure that the email is delivered to every single recipient. This should only be used in emergencies when it is absolutely necessary that every recipient receives your email.
98
+
99
+ ###### enable (boolean)
100
+ Indicates if this setting is enabled.
101
+
102
+ ```mail(to: 'example@email.com', subject: 'email subject', body: 'email body', mail_settings:{ bypass_list_management: { enable: true }})```
103
+
104
+ #### footer (object)
105
+ The default footer that you would like included on every email.
106
+
107
+ ##### enable (boolean)
108
+ Indicates if this setting is enabled.
109
+
110
+ ##### text (string)
111
+ The plain text content of your footer.
112
+
113
+ ##### html (string)
114
+ The HTML content of your footer.
115
+
116
+ ```mail(to: 'example@email.com', subject: 'email subject', body: 'email body', mail_settings:{ footer: { enable: true, text: 'FOOTER', html: '<h1>FOOTER</h1>' }})```
117
+
118
+ #### sandbox_mode (object)
119
+ This allows you to send a test email to ensure that your request body is valid and formatted correctly.
120
+
121
+ ##### enable (boolean)
122
+ Indicates if this setting is enabled.
123
+
124
+ ```mail(to: 'example@email.com', subject: 'email subject', body: 'email body', mail_settings:{ sandbox_mode: { enable: true }})```
125
+
126
+ #### spam_check (object)
127
+ This allows you to test the content of your email for spam.
128
+
129
+ ##### enable (boolean)
130
+ Indicates if this setting is enabled.
131
+
132
+ ##### threshold (integer)
133
+ The threshold used to determine if your content qualifies as spam on a scale from 1 to 10, with 10 being most strict, or most likely to be considered as spam.
134
+
135
+ ##### post_to_url (string)
136
+ An Inbound Parse URL that you would like a copy of your email along with the spam report to be sent to.
137
+
138
+ ```mail(to: 'example@email.com', subject: 'email subject', body: 'email body', mail_settings:{ spam_check: {enable: true, threshold: 1, post_to_url: 'https://spamcatcher.sendgrid.com'}})```
139
+ ### tracking_settings(json)
140
+ Settings to determine how you would like to track the metrics of how your recipients interact with your email.
141
+
142
+ #### click_tracking(object)
143
+ Allows you to track whether a recipient clicked a link in your email.
144
+
145
+ ##### enable (boolean)
146
+ Indicates if this setting is enabled.
147
+
148
+ ##### enable_text (boolean)
149
+ Indicates if this setting should be included in the text/plain portion of your email.
150
+
151
+ ```mail(to: 'example@email.com', subject: 'email subject', body: 'email body', tracking_settings:{ enable: false, enable_text: false }})```
152
+
153
+ #### open_tracking (object)
154
+ Allows you to track whether the email was opened or not, but including a single pixel image in the body of the content. When the pixel is loaded, we can log that the email was opened.
155
+
156
+ ##### enable (boolean)
157
+ Indicates if this setting is enabled.
158
+
159
+ ##### substitution_tag (string)
160
+ Allows you to specify a substitution tag that you can insert in the body of your email at a location that you desire. This tag will be replaced by the open tracking pixel.
161
+
162
+ ```mail(to: 'example@email.com', subject: 'email subject', body: 'email body', tracking_settings:{ enable: true, substitution_tag: 'Optional tag to replace with the open image in the body of the message' }})```
163
+
164
+ #### subscription_tracking (object)
165
+ Allows you to insert a subscription management link at the bottom of the text and html bodies of your email. If you would like to specify the location of the link within your email, you may use the substitution_tag.
166
+
167
+ ##### enable (boolean)
168
+ Indicates if this setting is enabled.
169
+
170
+ ##### text (string)
171
+ Text to be appended to the email, with the subscription tracking link. You may control where the link is by using the tag <% %>
172
+
173
+ ##### html (string)
174
+ HTML to be appended to the email, with the subscription tracking link. You may control where the link is by using the tag <% %>
175
+
176
+ ##### substitution_tag (string)
177
+ A tag that will be replaced with the unsubscribe URL. for example: [unsubscribe_url]. If this parameter is used, it will override both the text and html parameters. The URL of the link will be placed at the substitution tag’s location, with no additional formatting.
178
+
179
+ ```mail(to: 'example@email.com', subject: 'email subject', body: 'email body', tracking_settings:{ enable: true, text: 'text to insert into the text/plain portion of the message', html: 'html to insert into the text/html portion of the message', substitution_tag: 'Optional tag to replace with the open image in the body of the message' }})```
180
+
181
+ #### ganalytics (object)
182
+ Allows you to enable tracking provided by Google Analytics.
183
+
184
+ ##### enable (boolean)
185
+ Indicates if this setting is enabled.
186
+
187
+ ##### utm_source (string)
188
+ Name of the referrer source. (e.g. Google, SomeDomain.com, or Marketing Email)
189
+
190
+ ##### utm_medium (string)
191
+ Name of the marketing medium. (e.g. Email)
192
+
193
+ ##### utm_term (string)
194
+ Used to identify any paid keywords.
195
+
196
+ ##### utm_content (string)
197
+ Used to differentiate your campaign from advertisements.
198
+
199
+ ##### utm_campaign (string)
200
+ The name of the campaign.
201
+
202
+ ```mail(to: 'example@email.com', subject: 'email subject', body: 'email body', tracking_settings:{ enable: true, utm_source: 'some source', utm_medium: 'some medium', utm_term: 'some term', utm_content: 'some content', utm_campaign: 'some campaign' }})```
203
+
204
+ ### Unsubscribe Links
92
205
 
93
- ## Contributing
206
+ Sendgrid unfortunately uses <% %> for their default substitution syntax, which makes it incompatible with Rails templates. Their proposed solution is to use Personalization Substitutions with the v3 Mail Send Endpoint. This gem makes that modification to make the following Rails friendly unsubscribe urls.
94
207
 
95
- 1. Fork it ( https://github.com/[my-github-username]/sendgrid-actionmailer/fork )
96
- 2. Create your feature branch (`git checkout -b my-new-feature`)
97
- 3. Commit your changes (`git commit -am 'Add some feature'`)
98
- 4. Push to the branch (`git push origin my-new-feature`)
99
- 5. Create a new Pull Request
208
+ * `<a href="%asm_group_unsubscribe_raw_url%">Unsubscribe</a>`
209
+ * `<a href="%asm_global_unsubscribe_raw_url%">Unsubscribe from List</a>`
210
+ * `<a href="%asm_preferences_raw_url%">Manage Email Preferences</a>`
@@ -1,3 +1,3 @@
1
1
  module SendGridActionMailer
2
- VERSION = '0.2.1'
2
+ VERSION = '2.0.0'.freeze
3
3
  end