mailgun-ruby 1.1.0 → 1.2.5

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.
Files changed (57) hide show
  1. checksums.yaml +5 -5
  2. data/.gitignore +1 -0
  3. data/.ruby-env.yml.example +1 -1
  4. data/.travis.yml +23 -7
  5. data/Gemfile +2 -0
  6. data/README.md +79 -18
  7. data/{Domains.md → docs/Domains.md} +18 -0
  8. data/{Events.md → docs/Events.md} +0 -0
  9. data/{MessageBuilder.md → docs/MessageBuilder.md} +32 -13
  10. data/{Messages.md → docs/Messages.md} +3 -3
  11. data/{OptInHandler.md → docs/OptInHandler.md} +0 -0
  12. data/{Snippets.md → docs/Snippets.md} +21 -2
  13. data/docs/Suppressions.md +82 -0
  14. data/{Webhooks.md → docs/Webhooks.md} +1 -1
  15. data/docs/railgun/Overview.md +11 -0
  16. data/docs/railgun/Parameters.md +83 -0
  17. data/lib/mailgun/address.rb +48 -0
  18. data/lib/mailgun/client.rb +85 -8
  19. data/lib/mailgun/events/events.rb +40 -12
  20. data/lib/mailgun/exceptions/exceptions.rb +21 -7
  21. data/lib/mailgun/lists/opt_in_handler.rb +0 -1
  22. data/lib/mailgun/messages/batch_message.rb +3 -2
  23. data/lib/mailgun/messages/message_builder.rb +139 -30
  24. data/lib/mailgun/response.rb +7 -0
  25. data/lib/mailgun/suppressions.rb +273 -0
  26. data/lib/mailgun/version.rb +1 -1
  27. data/lib/mailgun/webhooks/webhooks.rb +1 -1
  28. data/lib/mailgun-ruby.rb +2 -0
  29. data/lib/mailgun.rb +1 -0
  30. data/lib/railgun/attachment.rb +56 -0
  31. data/lib/railgun/errors.rb +27 -0
  32. data/lib/railgun/mailer.rb +253 -0
  33. data/lib/railgun/message.rb +18 -0
  34. data/lib/railgun/railtie.rb +10 -0
  35. data/lib/railgun.rb +8 -0
  36. data/mailgun.gemspec +12 -13
  37. data/spec/integration/email_validation_spec.rb +57 -15
  38. data/spec/integration/events_spec.rb +9 -1
  39. data/spec/integration/mailer_spec.rb +67 -0
  40. data/spec/integration/mailgun_spec.rb +51 -1
  41. data/spec/integration/suppressions_spec.rb +142 -0
  42. data/spec/spec_helper.rb +3 -1
  43. data/spec/unit/connection/test_client.rb +16 -0
  44. data/spec/unit/events/events_spec.rb +36 -2
  45. data/spec/unit/mailgun_spec.rb +32 -10
  46. data/spec/unit/messages/batch_message_spec.rb +56 -40
  47. data/spec/unit/messages/message_builder_spec.rb +267 -81
  48. data/spec/unit/messages/sample_data/unknown.type +0 -0
  49. data/spec/unit/railgun/content_type_spec.rb +71 -0
  50. data/spec/unit/railgun/mailer_spec.rb +388 -0
  51. data/vcr_cassettes/email_validation.yml +136 -25
  52. data/vcr_cassettes/events.yml +48 -1
  53. data/vcr_cassettes/exceptions.yml +45 -0
  54. data/vcr_cassettes/mailer_invalid_domain.yml +109 -0
  55. data/vcr_cassettes/message_deliver.yml +149 -0
  56. data/vcr_cassettes/suppressions.yml +727 -0
  57. metadata +65 -40
@@ -58,4 +58,51 @@ http_interactions:
58
58
  \ }\n}"
59
59
  http_version:
60
60
  recorded_at: Thu, 07 Jan 2016 22:08:06 GMT
61
- recorded_with: VCR 3.0.1
61
+ - request:
62
+ method: get
63
+ uri: https://api:<APIKEY>@api.mailgun.net/v3/DOMAIN.TEST/events
64
+ body:
65
+ encoding: US-ASCII
66
+ string: ''
67
+ headers:
68
+ Accept:
69
+ - "*/*"
70
+ Accept-Encoding:
71
+ - gzip, deflate
72
+ User-Agent:
73
+ - rest-client/2.0.1 (linux-gnu x86_64) ruby/2.3.3p222
74
+ Host:
75
+ - api.mailgun.net
76
+ response:
77
+ status:
78
+ code: 200
79
+ message: OK
80
+ headers:
81
+ Access-Control-Allow-Headers:
82
+ - Content-Type, x-requested-with
83
+ Access-Control-Allow-Methods:
84
+ - GET, POST, PUT, DELETE, OPTIONS
85
+ Access-Control-Allow-Origin:
86
+ - "*"
87
+ Access-Control-Max-Age:
88
+ - '600'
89
+ Content-Type:
90
+ - application/json
91
+ Date:
92
+ - Wed, 10 May 2017 20:06:54 GMT
93
+ Server:
94
+ - nginx
95
+ Content-Length:
96
+ - '2060'
97
+ Connection:
98
+ - keep-alive
99
+ body:
100
+ encoding: UTF-8
101
+ string: "{\n \"items\": [], \n \"paging\": {\n \"next\": \"https://api.mailgun.net/v3/DOMAIN.TEST/events/W3siYiI6ICIyMDE3LTA1LTEwVDIwOjA2OjU0LjU3NiswMDowMCIsICJlIjogIjIwMTctMDUtMDhUMjA6MDY6NTQuNTc3KzAwOjAwIn0sIHsiYiI6ICIyMDE3LTA1LTEwVDIwOjA2OjU0LjU3NiswMDowMCIsICJlIjogIjIwMTctMDUtMDhUMjA6MDY6NTQuNTc3KzAwOjAwIn0sIFsiZiJdLCBudWxsLCBbWyJhY2NvdW50LmlkIiwgIjU4MDUyMTg2NzhmYTE2MTNjNzkwYjUwZiJdLCBbImRvbWFpbi5uYW1lIiwgInNhbmRib3gyOTcwMTUyYWYzZDM0NTU5YmZjN2U3MTcwM2E2Y2YyNC5tYWlsZ3VuLm9yZyJdXSwgMTAwLCBudWxsXQ==\",
102
+ \n \"last\": \"https://api.mailgun.net/v3/DOMAIN.TEST/events/W3siYiI6ICIyMDE3LTA1LTEwVDIwOjA2OjU0LjU3NiswMDowMCIsICJlIjogIjIwMTctMDUtMDhUMjA6MDY6NTQuNTc3KzAwOjAwIn0sIHsiYiI6ICIyMDE3LTA1LTA4VDIwOjA2OjU0LjU3NyswMDowMCIsICJlIjogIjIwMTctMDUtMTBUMjA6MDY6NTQuNTc2KzAwOjAwIn0sIFsicCIsICJmIl0sIG51bGwsIFtbImFjY291bnQuaWQiLCAiNTgwNTIxODY3OGZhMTYxM2M3OTBiNTBmIl0sIFsiZG9tYWluLm5hbWUiLCAic2FuZGJveDI5NzAxNTJhZjNkMzQ1NTliZmM3ZTcxNzAzYTZjZjI0Lm1haWxndW4ub3JnIl1dLCAxMDAsIG51bGxd\",
103
+ \n \"first\": \"https://api.mailgun.net/v3/DOMAIN.TEST/events/W3siYiI6ICIyMDE3LTA1LTEwVDIwOjA2OjU0LjU3NiswMDowMCIsICJlIjogIjIwMTctMDUtMDhUMjA6MDY6NTQuNTc3KzAwOjAwIn0sIHsiYiI6ICIyMDE3LTA1LTEwVDIwOjA2OjU0LjU3NiswMDowMCIsICJlIjogIjIwMTctMDUtMDhUMjA6MDY6NTQuNTc3KzAwOjAwIn0sIFsiZiJdLCBudWxsLCBbWyJhY2NvdW50LmlkIiwgIjU4MDUyMTg2NzhmYTE2MTNjNzkwYjUwZiJdLCBbImRvbWFpbi5uYW1lIiwgInNhbmRib3gyOTcwMTUyYWYzZDM0NTU5YmZjN2U3MTcwM2E2Y2YyNC5tYWlsZ3VuLm9yZyJdXSwgMTAwLCBudWxsXQ==\",
104
+ \n \"previous\": \"https://api.mailgun.net/v3/DOMAIN.TEST/events/W3siYiI6ICIyMDE3LTA1LTEwVDIwOjA2OjU0LjU3NiswMDowMCIsICJlIjogIjIwMTctMDUtMDhUMjA6MDY6NTQuNTc3KzAwOjAwIn0sIHsiYiI6ICIyMDE3LTA1LTEwVDIwOjA2OjU0LjU3NiswMDowMCIsICJlIjogIjIwMTctMDUtMTBUMjA6MDY6NTQuNTc3KzAwOjAwIn0sIFsicCIsICJmIl0sIG51bGwsIFtbImFjY291bnQuaWQiLCAiNTgwNTIxODY3OGZhMTYxM2M3OTBiNTBmIl0sIFsiZG9tYWluLm5hbWUiLCAic2FuZGJveDI5NzAxNTJhZjNkMzQ1NTliZmM3ZTcxNzAzYTZjZjI0Lm1haWxndW4ub3JnIl1dLCAxMDAsIG51bGxd\"\n
105
+ \ }\n}"
106
+ http_version:
107
+ recorded_at: Wed, 10 May 2017 20:06:54 GMT
108
+ recorded_with: VCR 3.0.3
@@ -0,0 +1,45 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: post
5
+ uri: https://api:<APIKEY>@api.mailgun.net/v3/not-our-doma.in/messages
6
+ body:
7
+ encoding: UTF-8
8
+ string: from=sally%40not-our-doma.in&to=bob%40DOMAIN.TEST&subject=Exception+Integration+Test&text=INTEGRATION+TESTING
9
+ headers:
10
+ Accept:
11
+ - "*/*"
12
+ Accept-Encoding:
13
+ - gzip, deflate
14
+ User-Agent:
15
+ - rest-client/2.0.0 (linux-gnu x86_64) ruby/2.3.1p112
16
+ Content-Length:
17
+ - '149'
18
+ Content-Type:
19
+ - application/x-www-form-urlencoded
20
+ Host:
21
+ - api.mailgun.net
22
+ response:
23
+ status:
24
+ code: 404
25
+ message: NOT FOUND
26
+ headers:
27
+ Server:
28
+ - nginx
29
+ Date:
30
+ - Wed, 02 Nov 2016 19:42:44 GMT
31
+ Content-Type:
32
+ - application/json
33
+ Content-Length:
34
+ - '52'
35
+ Connection:
36
+ - keep-alive
37
+ body:
38
+ encoding: UTF-8
39
+ string: |-
40
+ {
41
+ "message": "Domain not found: not-our-doma.in"
42
+ }
43
+ http_version:
44
+ recorded_at: Wed, 02 Nov 2016 19:43:40 GMT
45
+ recorded_with: VCR 3.0.3
@@ -0,0 +1,109 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: post
5
+ uri: https://api.mailgun.net/v3/not-our-doma.in/messages
6
+ body:
7
+ encoding: US-ASCII
8
+ string: from[]=sally%40not-our-doma.in&subject[]=subject&html[]=%3Cp%3ETest%21%3C%2Fp%3E&text[]=Test%21&to[]=bob%40DOMAIN.TEST&h%3Acontent-type=multipart%2Falternative%3B+boundary%3D%22--%3D%3D_mimepart_6098fb5a12edf_78633ff4e00521889696a%22%3B+charset%3DUTF-8
9
+ headers:
10
+ Accept:
11
+ - "*/*"
12
+ User-Agent:
13
+ - rest-client/2.1.0 (darwin18.7.0 x86_64) ruby/2.2.2p95
14
+ Content-Length:
15
+ - '262'
16
+ Content-Type:
17
+ - application/x-www-form-urlencoded
18
+ Accept-Encoding:
19
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
20
+ Host:
21
+ - api.mailgun.net
22
+ Authorization:
23
+ - Basic YXBpOmQ5MTViNWNkYjlhNTgzNjg1ZDhmM2ZiMWJlYzBmMjBmLTA3YmM3YjA1LWZhNDgxNmEx
24
+ response:
25
+ status:
26
+ code: 401
27
+ message: UNAUTHORIZED
28
+ headers:
29
+ Access-Control-Allow-Headers:
30
+ - Content-Type, x-requested-with, Authorization
31
+ Access-Control-Allow-Methods:
32
+ - GET, POST, PUT, DELETE, OPTIONS
33
+ Access-Control-Allow-Origin:
34
+ - "*"
35
+ Access-Control-Max-Age:
36
+ - '600'
37
+ Cache-Control:
38
+ - no-store
39
+ Content-Type:
40
+ - text/html; charset=utf-8
41
+ Date:
42
+ - Mon, 10 May 2021 09:22:34 GMT
43
+ Server:
44
+ - nginx
45
+ Www-Authenticate:
46
+ - Basic realm="MG API"
47
+ Content-Length:
48
+ - '9'
49
+ Connection:
50
+ - keep-alive
51
+ body:
52
+ encoding: UTF-8
53
+ string: Forbidden
54
+ http_version:
55
+ recorded_at: Mon, 10 May 2021 09:22:34 GMT
56
+ - request:
57
+ method: post
58
+ uri: https://api.mailgun.net/v3/not-our-doma.in/messages
59
+ body:
60
+ encoding: US-ASCII
61
+ string: from[]=sally%40not-our-doma.in&subject[]=subject&html[]=%3Cp%3ETest%21%3C%2Fp%3E&text[]=Test%21&to[]=bob%40DOMAIN.TEST&h%3Acontent-type=multipart%2Falternative%3B+boundary%3D%22--%3D%3D_mimepart_6098fb5a12edf_78633ff4e00521889696a%22%3B+charset%3DUTF-8
62
+ headers:
63
+ Accept:
64
+ - "*/*"
65
+ User-Agent:
66
+ - rest-client/2.1.0 (darwin18.7.0 x86_64) ruby/2.2.2p95
67
+ Content-Length:
68
+ - '262'
69
+ Content-Type:
70
+ - application/x-www-form-urlencoded
71
+ Accept-Encoding:
72
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
73
+ Host:
74
+ - api.mailgun.net
75
+ Authorization:
76
+ - Basic YXBpOmQ5MTViNWNkYjlhNTgzNjg1ZDhmM2ZiMWJlYzBmMjBmLTA3YmM3YjA1LWZhNDgxNmEx
77
+ response:
78
+ status:
79
+ code: 401
80
+ message: UNAUTHORIZED
81
+ headers:
82
+ Access-Control-Allow-Headers:
83
+ - Content-Type, x-requested-with, Authorization
84
+ Access-Control-Allow-Methods:
85
+ - GET, POST, PUT, DELETE, OPTIONS
86
+ Access-Control-Allow-Origin:
87
+ - "*"
88
+ Access-Control-Max-Age:
89
+ - '600'
90
+ Cache-Control:
91
+ - no-store
92
+ Content-Type:
93
+ - text/html; charset=utf-8
94
+ Date:
95
+ - Mon, 10 May 2021 09:22:40 GMT
96
+ Server:
97
+ - nginx
98
+ Www-Authenticate:
99
+ - Basic realm="MG API"
100
+ Content-Length:
101
+ - '9'
102
+ Connection:
103
+ - keep-alive
104
+ body:
105
+ encoding: UTF-8
106
+ string: Forbidden
107
+ http_version:
108
+ recorded_at: Mon, 10 May 2021 09:22:40 GMT
109
+ recorded_with: VCR 3.0.3
@@ -0,0 +1,149 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: post
5
+ uri: https://api.mailgun.net/v3/DOMAIN.TEST/messages
6
+ body:
7
+ encoding: US-ASCII
8
+ string: from[]=bob%40DOMAIN.TEST&subject[]=subject&html[]=%3Cp%3ETest%21%3C%2Fp%3E&text[]=Test%21&to[]=bob%40DOMAIN.TEST&h%3Acontent-type=multipart%2Falternative%3B+boundary%3D%22--%3D%3D_mimepart_6098f913d64ca_62833fd4d74521802775%22%3B+charset%3DUTF-8
9
+ headers:
10
+ Accept:
11
+ - "*/*"
12
+ User-Agent:
13
+ - rest-client/2.1.0 (darwin18.7.0 x86_64) ruby/2.2.2p95
14
+ Content-Length:
15
+ - '261'
16
+ Content-Type:
17
+ - application/x-www-form-urlencoded
18
+ Accept-Encoding:
19
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
20
+ Host:
21
+ - api.mailgun.net
22
+ Authorization:
23
+ - Basic YXBpOmQ5MTViNWNkYjlhNTgzNjg1ZDhmM2ZiMWJlYzBmMjBmLTA3YmM3YjA1LWZhNDgxNmEx
24
+ response:
25
+ status:
26
+ code: 200
27
+ message: OK
28
+ headers:
29
+ Access-Control-Allow-Credentials:
30
+ - 'true'
31
+ Access-Control-Allow-Headers:
32
+ - Content-Type, x-requested-with, Authorization
33
+ Access-Control-Allow-Methods:
34
+ - GET, POST, PUT, DELETE, OPTIONS
35
+ Access-Control-Allow-Origin:
36
+ - "*"
37
+ Access-Control-Max-Age:
38
+ - '600'
39
+ Cache-Control:
40
+ - no-store
41
+ Content-Disposition:
42
+ - inline
43
+ Content-Type:
44
+ - application/json
45
+ Date:
46
+ - Mon, 10 May 2021 09:12:52 GMT
47
+ Server:
48
+ - nginx
49
+ Strict-Transport-Security:
50
+ - max-age=63072000; includeSubDomains
51
+ X-Ratelimit-Limit:
52
+ - '2000000'
53
+ X-Ratelimit-Remaining:
54
+ - '1999999'
55
+ X-Ratelimit-Reset:
56
+ - '1620637982656'
57
+ X-Recipient-Limit:
58
+ - '1000000'
59
+ X-Recipient-Remaining:
60
+ - '999999'
61
+ X-Recipient-Reset:
62
+ - '1620637982657'
63
+ Content-Length:
64
+ - '136'
65
+ Connection:
66
+ - keep-alive
67
+ body:
68
+ encoding: UTF-8
69
+ string: |-
70
+ {
71
+ "id": "<20210510091252.1.D6347B73DA43962E@DOMAIN.TEST>",
72
+ "message": "Queued. Thank you."
73
+ }
74
+ http_version:
75
+ recorded_at: Mon, 10 May 2021 09:12:52 GMT
76
+ - request:
77
+ method: post
78
+ uri: https://api.mailgun.net/v3/DOMAIN.TEST/messages
79
+ body:
80
+ encoding: US-ASCII
81
+ string: from[]=bob%40DOMAIN.TEST&subject[]=subject&html[]=%3Cp%3ETest%21%3C%2Fp%3E&text[]=Test%21&to[]=bob%40DOMAIN.TEST&h%3Amessage-id=%3C20210510091252.1.D6347B73DA43962E%40DOMAIN.TEST%3E&h%3Acontent-type=multipart%2Falternative%3B+boundary%3D%22--%3D%3D_mimepart_6098f913d64ca_62833fd4d74521802775%22%3B+charset%3DUTF-8
82
+ headers:
83
+ Accept:
84
+ - "*/*"
85
+ User-Agent:
86
+ - rest-client/2.1.0 (darwin18.7.0 x86_64) ruby/2.2.2p95
87
+ Content-Length:
88
+ - '370'
89
+ Content-Type:
90
+ - application/x-www-form-urlencoded
91
+ Accept-Encoding:
92
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
93
+ Host:
94
+ - api.mailgun.net
95
+ Authorization:
96
+ - Basic YXBpOmQ5MTViNWNkYjlhNTgzNjg1ZDhmM2ZiMWJlYzBmMjBmLTA3YmM3YjA1LWZhNDgxNmEx
97
+ response:
98
+ status:
99
+ code: 200
100
+ message: OK
101
+ headers:
102
+ Access-Control-Allow-Credentials:
103
+ - 'true'
104
+ Access-Control-Allow-Headers:
105
+ - Content-Type, x-requested-with, Authorization
106
+ Access-Control-Allow-Methods:
107
+ - GET, POST, PUT, DELETE, OPTIONS
108
+ Access-Control-Allow-Origin:
109
+ - "*"
110
+ Access-Control-Max-Age:
111
+ - '600'
112
+ Cache-Control:
113
+ - no-store
114
+ Content-Disposition:
115
+ - inline
116
+ Content-Type:
117
+ - application/json
118
+ Date:
119
+ - Mon, 10 May 2021 09:12:56 GMT
120
+ Server:
121
+ - nginx
122
+ Strict-Transport-Security:
123
+ - max-age=63072000; includeSubDomains
124
+ X-Ratelimit-Limit:
125
+ - '2000000'
126
+ X-Ratelimit-Remaining:
127
+ - '1999998'
128
+ X-Ratelimit-Reset:
129
+ - '1620637982656'
130
+ X-Recipient-Limit:
131
+ - '1000000'
132
+ X-Recipient-Remaining:
133
+ - '999998'
134
+ X-Recipient-Reset:
135
+ - '1620637982657'
136
+ Content-Length:
137
+ - '136'
138
+ Connection:
139
+ - keep-alive
140
+ body:
141
+ encoding: UTF-8
142
+ string: |-
143
+ {
144
+ "id": "<20210510091252.1.D6347B73DA43962E@DOMAIN.TEST>",
145
+ "message": "Queued. Thank you."
146
+ }
147
+ http_version:
148
+ recorded_at: Mon, 10 May 2021 09:12:56 GMT
149
+ recorded_with: VCR 3.0.3