incoming 0.1.6 → 0.1.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +38 -16
- data/lib/incoming.rb +2 -1
- data/lib/incoming/strategies/mandrill.rb +22 -0
- data/lib/incoming/strategies/sendgrid.rb +11 -4
- metadata +19 -18
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 669e826d514d7f60c2f0b573d05e06b5c787bd58
|
4
|
+
data.tar.gz: 69297a42708e49dcc34dfbb8c9e7564c98fca255
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fffdd521a873011ce3a2c63086b9a90428a366b6eb0e902692d1c58c10d15a200f6b1329bcb5c270dc0d7ad8fb93f30e2fa30c4298c2faf218a892b16ed12b56
|
7
|
+
data.tar.gz: b74dd6dd56b1a0dacc49807b38da6fbe5747045d7ea28703574eee4ea0f827e8275154141ff724520501a06aa6eb94a781c9968ec69de29543b4202d930ca18c
|
data/README.md
CHANGED
@@ -7,11 +7,12 @@ Incoming! receives a `Rack::Request` and hands you a [`Mail::Message`](https://g
|
|
7
7
|
like `ActionMailer::Base.receive` does with a raw email. We currently
|
8
8
|
support the following services:
|
9
9
|
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
10
|
+
* SendGrid
|
11
|
+
* Mailgun
|
12
|
+
* Postmark
|
13
|
+
* CloudMailin
|
14
|
+
* Mandrill
|
15
|
+
* Any mail server capable of routing messages to a system command
|
15
16
|
|
16
17
|
Brought to you by :zap: **Honeybadger.io**, painless [Rails exception tracking](https://www.honeybadger.io/).
|
17
18
|
|
@@ -31,12 +32,12 @@ Brought to you by :zap: **Honeybadger.io**, painless [Rails exception tracking](
|
|
31
32
|
3. Implement an HTTP endpoint to receive HTTP post hooks, and pass the
|
32
33
|
request to your receiver. (see examples below)
|
33
34
|
|
34
|
-
## SendGrid example
|
35
|
+
## SendGrid example
|
35
36
|
|
36
37
|
```ruby
|
37
38
|
class EmailReceiver < Incoming::Strategies::SendGrid
|
38
39
|
def receive(mail)
|
39
|
-
|
40
|
+
%(Got message from #{mail.to.first} with subject "#{mail.subject}")
|
40
41
|
end
|
41
42
|
end
|
42
43
|
|
@@ -46,14 +47,14 @@ result = EmailReceiver.receive(req) # => Got message from whoever@wherever.com w
|
|
46
47
|
|
47
48
|
[Sendgrid API reference](http://sendgrid.com/docs/API_Reference/Webhooks/parse.html)
|
48
49
|
|
49
|
-
## Mailgun example
|
50
|
+
## Mailgun example
|
50
51
|
|
51
52
|
```ruby
|
52
53
|
class EmailReceiver < Incoming::Strategies::Mailgun
|
53
54
|
setup :api_key => 'asdf'
|
54
55
|
|
55
56
|
def receive(mail)
|
56
|
-
|
57
|
+
%(Got message from #{mail.to.first} with subject "#{mail.subject}")
|
57
58
|
end
|
58
59
|
end
|
59
60
|
|
@@ -63,12 +64,12 @@ result = EmailReceiver.receive(req) # => Got message from whoever@wherever.com w
|
|
63
64
|
|
64
65
|
[Mailgun API reference](http://documentation.mailgun.net/user_manual.html#receiving-messages)
|
65
66
|
|
66
|
-
## Postmark example
|
67
|
+
## Postmark example
|
67
68
|
|
68
69
|
```ruby
|
69
70
|
class EmailReceiver < Incoming::Strategies::Postmark
|
70
71
|
def receive(mail)
|
71
|
-
|
72
|
+
%(Got message from #{mail.to.first} with subject "#{mail.subject}")
|
72
73
|
end
|
73
74
|
end
|
74
75
|
|
@@ -78,14 +79,14 @@ result = EmailReceiver.receive(req) # => Got message from whoever@wherever.com w
|
|
78
79
|
|
79
80
|
[Postmark API reference](http://developer.postmarkapp.com/developer-inbound.html)
|
80
81
|
|
81
|
-
## CloudMailin example
|
82
|
+
## CloudMailin example
|
82
83
|
|
83
84
|
Use the Raw Format when setting up your address target.
|
84
85
|
|
85
86
|
```ruby
|
86
87
|
class EmailReceiver < Incoming::Strategies::CloudMailin
|
87
88
|
def receive(mail)
|
88
|
-
|
89
|
+
%(Got message from #{mail.to.first} with subject "#{mail.subject}")
|
89
90
|
end
|
90
91
|
end
|
91
92
|
|
@@ -95,14 +96,35 @@ result = EmailReceiver.receive(req) # => Got message from whoever@wherever.com w
|
|
95
96
|
|
96
97
|
[CloudMailin API reference](http://docs.cloudmailin.com/http_post_formats/)
|
97
98
|
|
98
|
-
##
|
99
|
+
## Mandrill example
|
100
|
+
|
101
|
+
Mandrill is capable of sending multiple events in a single webhook, so
|
102
|
+
the Mandrill strategy works a bit differently than the others. Namely,
|
103
|
+
the `.receive` method returns an Array of return values from your
|
104
|
+
`#receive` method for each inbound event in the payload. Otherwise, the
|
105
|
+
implementation is the same:
|
106
|
+
|
107
|
+
```ruby
|
108
|
+
class EmailReceiver < Incoming::Strategies::Mandrill
|
109
|
+
def receive(mail)
|
110
|
+
%(Got message from #{mail.to.first} with subject "#{mail.subject}")
|
111
|
+
end
|
112
|
+
end
|
113
|
+
|
114
|
+
req = Rack::Request.new(env)
|
115
|
+
result = EmailReceiver.receive(req) # => ['Got message from whoever@wherever.com with subject "hello world"', '...']
|
116
|
+
```
|
117
|
+
|
118
|
+
[Mandrill API reference](http://help.mandrill.com/entries/22092308-What-is-the-format-of-inbound-email-webhooks-)
|
119
|
+
|
120
|
+
## Postfix example
|
99
121
|
|
100
122
|
```ruby
|
101
123
|
class EmailReceiver < Incoming::Strategies::HTTPPost
|
102
124
|
setup :secret => '6d7e5337a0cd69f52c3fcf9f5af438b1'
|
103
125
|
|
104
126
|
def receive(mail)
|
105
|
-
|
127
|
+
%(Got message from #{mail.to.first} with subject "#{mail.subject}")
|
106
128
|
end
|
107
129
|
end
|
108
130
|
|
@@ -124,7 +146,7 @@ class EmailReceiver < Incoming::Strategies::HTTPPost
|
|
124
146
|
setup :secret => '6d7e5337a0cd69f52c3fcf9f5af438b1'
|
125
147
|
|
126
148
|
def receive(mail)
|
127
|
-
|
149
|
+
%(Got message from #{mail.to.first} with subject "#{mail.subject}")
|
128
150
|
end
|
129
151
|
end
|
130
152
|
|
data/lib/incoming.rb
CHANGED
@@ -2,9 +2,10 @@ require 'mail'
|
|
2
2
|
require 'incoming/strategy'
|
3
3
|
|
4
4
|
module Incoming
|
5
|
-
VERSION = '0.1.
|
5
|
+
VERSION = '0.1.7'
|
6
6
|
|
7
7
|
module Strategies
|
8
|
+
autoload :Mandrill, 'incoming/strategies/mandrill'
|
8
9
|
autoload :SendGrid, 'incoming/strategies/sendgrid'
|
9
10
|
autoload :Mailgun, 'incoming/strategies/mailgun'
|
10
11
|
autoload :Postmark, 'incoming/strategies/postmark'
|
@@ -0,0 +1,22 @@
|
|
1
|
+
require 'json'
|
2
|
+
|
3
|
+
module Incoming
|
4
|
+
module Strategies
|
5
|
+
class Mandrill
|
6
|
+
include Incoming::Strategy
|
7
|
+
|
8
|
+
def self.receive(request)
|
9
|
+
JSON.parse(request.params['mandrill_events']).map do |event|
|
10
|
+
next unless event['event'] == 'inbound'
|
11
|
+
result = super(event['msg'])
|
12
|
+
yield(result) if block_given?
|
13
|
+
result
|
14
|
+
end.compact
|
15
|
+
end
|
16
|
+
|
17
|
+
def initialize(msg)
|
18
|
+
@message = Mail.new(msg['raw_msg'])
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -9,7 +9,7 @@ module Incoming
|
|
9
9
|
params = request.params.dup
|
10
10
|
|
11
11
|
# TODO: Properly handle encodings
|
12
|
-
|
12
|
+
encodings = JSON.parse(params['charsets'])
|
13
13
|
|
14
14
|
attachments = 1.upto(params['attachments'].to_i).map do |num|
|
15
15
|
attachment_from_params(params["attachment#{num}"])
|
@@ -17,12 +17,19 @@ module Incoming
|
|
17
17
|
|
18
18
|
@message = Mail.new do
|
19
19
|
header params['headers']
|
20
|
-
|
21
|
-
|
20
|
+
if encodings['text'].blank?
|
21
|
+
body params['text']
|
22
|
+
else
|
23
|
+
body params['text'].force_encoding(encodings['text']).encode('UTF-8')
|
24
|
+
end
|
22
25
|
|
23
26
|
html_part do
|
24
27
|
content_type 'text/html; charset=UTF-8'
|
25
|
-
|
28
|
+
if encodings['html'].blank?
|
29
|
+
body params['html']
|
30
|
+
else
|
31
|
+
body params['html'].force_encoding(encodings['html']).encode('UTF-8')
|
32
|
+
end
|
26
33
|
end if params['html']
|
27
34
|
|
28
35
|
attachments.each do |attachment|
|
metadata
CHANGED
@@ -1,69 +1,69 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: incoming
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Joshua Wood
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2014-04-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rack
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- -
|
17
|
+
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '0'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- -
|
24
|
+
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: mail
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- - ~>
|
31
|
+
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: '2.4'
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- - ~>
|
38
|
+
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '2.4'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: rake
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- -
|
45
|
+
- - ">="
|
46
46
|
- !ruby/object:Gem::Version
|
47
47
|
version: '0'
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- -
|
52
|
+
- - ">="
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '0'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: rspec
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
|
-
- -
|
59
|
+
- - ">="
|
60
60
|
- !ruby/object:Gem::Version
|
61
61
|
version: '0'
|
62
62
|
type: :development
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
|
-
- -
|
66
|
+
- - ">="
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '0'
|
69
69
|
description: Incoming! standardizes various mail parse apis, making it a snap to receive
|
@@ -75,17 +75,18 @@ executables:
|
|
75
75
|
extensions: []
|
76
76
|
extra_rdoc_files: []
|
77
77
|
files:
|
78
|
+
- MIT-LICENSE
|
79
|
+
- README.md
|
80
|
+
- Rakefile
|
81
|
+
- bin/http_post
|
82
|
+
- lib/incoming.rb
|
78
83
|
- lib/incoming/strategies/cloudmailin.rb
|
79
84
|
- lib/incoming/strategies/http_post.rb
|
80
85
|
- lib/incoming/strategies/mailgun.rb
|
86
|
+
- lib/incoming/strategies/mandrill.rb
|
81
87
|
- lib/incoming/strategies/postmark.rb
|
82
88
|
- lib/incoming/strategies/sendgrid.rb
|
83
89
|
- lib/incoming/strategy.rb
|
84
|
-
- lib/incoming.rb
|
85
|
-
- MIT-LICENSE
|
86
|
-
- Rakefile
|
87
|
-
- README.md
|
88
|
-
- bin/http_post
|
89
90
|
homepage: https://github.com/honeybadger-io/incoming
|
90
91
|
licenses: []
|
91
92
|
metadata: {}
|
@@ -95,17 +96,17 @@ require_paths:
|
|
95
96
|
- lib
|
96
97
|
required_ruby_version: !ruby/object:Gem::Requirement
|
97
98
|
requirements:
|
98
|
-
- -
|
99
|
+
- - ">="
|
99
100
|
- !ruby/object:Gem::Version
|
100
101
|
version: '0'
|
101
102
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
102
103
|
requirements:
|
103
|
-
- -
|
104
|
+
- - ">="
|
104
105
|
- !ruby/object:Gem::Version
|
105
106
|
version: '0'
|
106
107
|
requirements: []
|
107
108
|
rubyforge_project:
|
108
|
-
rubygems_version: 2.
|
109
|
+
rubygems_version: 2.2.0
|
109
110
|
signing_key:
|
110
111
|
specification_version: 4
|
111
112
|
summary: Incoming! helps you receive email in your Rack apps.
|