google-http-actionmailer 0.1.0 → 0.2.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 +36 -6
- data/lib/google_http_actionmailer/version.rb +1 -1
- data/lib/google_http_actionmailer.rb +17 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5681fb59448881c9fd4872b3e63c5d0b23ab8f5c8f329c0558fd5860881456ec
|
4
|
+
data.tar.gz: 94601ff306b9a1af4610b71c0566c1365a2061ed6c494674940c7d2dd0e16566
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 791f3bb2d5cd9e10b8d21b67618fdce58e7f11373cf33aa838f122296c09afd932445e8763259ea29a1360a88e715ace1a763971961b0723fbd83772a8e06264
|
7
|
+
data.tar.gz: 76ed809027807736bacce6d0dd14c3e3bfe370123c5b48e45df9d64a04ae63246feef6f731a83f905dbbe248bbc806956e0bc598413db296beb88793aa49a9a0
|
data/README.md
CHANGED
@@ -1,15 +1,13 @@
|
|
1
1
|
# GoogleHttpActionmailer
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
TODO: Delete this and the text above, and describe your gem
|
3
|
+
An ActionMailer adapter to send email using Google's HTTPS Web API (instead of SMTP).
|
6
4
|
|
7
5
|
## Installation
|
8
6
|
|
9
7
|
Add this line to your application's Gemfile:
|
10
8
|
|
11
9
|
```ruby
|
12
|
-
gem '
|
10
|
+
gem 'google-http-actionmailer'
|
13
11
|
```
|
14
12
|
|
15
13
|
And then execute:
|
@@ -18,11 +16,43 @@ And then execute:
|
|
18
16
|
|
19
17
|
Or install it yourself as:
|
20
18
|
|
21
|
-
$ gem install
|
19
|
+
$ gem install google-http-actionmailer
|
22
20
|
|
23
21
|
## Usage
|
24
22
|
|
25
|
-
|
23
|
+
Set up your `authorization` as described in the [Google API Client](https://github.com/google/google-api-ruby-client/#authorization) (the easiest method is to pass a valid access token), edit `config/application.rb` or `config/environments/$ENVIRONMENT.rb` and add/change the following to the ActionMailer configuration:
|
24
|
+
|
25
|
+
```ruby
|
26
|
+
config.action_mailer.delivery_method = :google_http_actionmailer
|
27
|
+
config.action_mailer.google_http_actionmailer_settings = {
|
28
|
+
authorization: ...,
|
29
|
+
client_options: {
|
30
|
+
application_name: ...,
|
31
|
+
application_version: ...,
|
32
|
+
},
|
33
|
+
request_options: {
|
34
|
+
retries: ...,
|
35
|
+
header: ...,
|
36
|
+
},
|
37
|
+
message_options: {
|
38
|
+
fields: ...,
|
39
|
+
content_type: ...,
|
40
|
+
}
|
41
|
+
}
|
42
|
+
```
|
43
|
+
|
44
|
+
For client and request options, you can look [here](https://github.com/google/google-api-ruby-client/blob/master/lib/google/apis/options.rb). And for message options, you can look at the `send_user_message` method [here](https://github.com/google/google-api-ruby-client/blob/master/generated/google/apis/gmail_v1/service.rb#L1150).
|
45
|
+
|
46
|
+
For dynamic setting of delivery method (this may be required given the access tokens usually expire):
|
47
|
+
|
48
|
+
```ruby
|
49
|
+
mail.delivery_method(
|
50
|
+
GoogleHttpActionmailer::DeliveryMethod, {
|
51
|
+
authorization: ...
|
52
|
+
})
|
53
|
+
```
|
54
|
+
|
55
|
+
Normal ActionMailer usage will now transparently be sent using Google's HTTPS API.
|
26
56
|
|
27
57
|
## Development
|
28
58
|
|
@@ -9,6 +9,7 @@ module GoogleHttpActionmailer
|
|
9
9
|
class DeliveryMethod
|
10
10
|
attr_reader :service
|
11
11
|
attr_reader :message_options
|
12
|
+
attr_reader :delivery_options
|
12
13
|
|
13
14
|
def initialize(params)
|
14
15
|
@service = Google::Apis::GmailV1::GmailService.new
|
@@ -26,6 +27,7 @@ module GoogleHttpActionmailer
|
|
26
27
|
end
|
27
28
|
|
28
29
|
@message_options = params[:message_options] || {}
|
30
|
+
@delivery_options = params[:delivery_options] || {}
|
29
31
|
end
|
30
32
|
|
31
33
|
def deliver!(mail)
|
@@ -35,7 +37,21 @@ module GoogleHttpActionmailer
|
|
35
37
|
thread_id: mail['Thread-ID']
|
36
38
|
)
|
37
39
|
|
38
|
-
|
40
|
+
before_send = delivery_options[:before_send]
|
41
|
+
if before_send && before_send.respond_to?(:call)
|
42
|
+
before_send.call(mail, message)
|
43
|
+
end
|
44
|
+
|
45
|
+
message = service.send_user_message(
|
46
|
+
user_id,
|
47
|
+
message,
|
48
|
+
message_options
|
49
|
+
)
|
50
|
+
|
51
|
+
after_send = delivery_options[:after_send]
|
52
|
+
if after_send && after_send.respond_to?(:call)
|
53
|
+
after_send.call(mail, message)
|
54
|
+
end
|
39
55
|
end
|
40
56
|
end
|
41
57
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: google-http-actionmailer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kartik Luke Singh
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-10-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: mail
|