mailgun-ruby 1.4.5 → 1.4.6
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/CHANGELOG.md +17 -1
- data/README.md +3 -1
- data/lib/mailgun/api_keys/api_keys.rb +2 -2
- data/lib/mailgun/client.rb +1 -1
- data/lib/mailgun/domains/domain_keys.rb +5 -5
- data/lib/mailgun/domains/domains.rb +12 -9
- data/lib/mailgun/events/events.rb +1 -1
- data/lib/mailgun/helpers/api_version_checker.rb +23 -12
- data/lib/mailgun/helpers/deprecation.rb +32 -0
- data/lib/mailgun/lists/mailing_lists.rb +250 -0
- data/lib/mailgun/messages/message_builder.rb +17 -7
- data/lib/mailgun/response.rb +1 -1
- data/lib/mailgun/routes/routes.rb +98 -0
- data/lib/mailgun/tags/analytics_tags.rb +2 -2
- data/lib/mailgun/tags/tags.rb +16 -8
- data/lib/mailgun/version.rb +1 -1
- data/lib/mailgun/webhooks/account_webhooks.rb +2 -2
- data/lib/mailgun/webhooks/webhooks.rb +17 -9
- data/lib/mailgun.rb +1 -0
- metadata +6 -326
- data/.github/workflows/ci.yml +0 -49
- data/.github_changelog_generator +0 -1
- data/.gitignore +0 -24
- data/.rubocop.yml +0 -68
- data/.ruby-env.yml.example +0 -13
- data/Gemfile +0 -9
- data/Rakefile +0 -32
- data/docs/AccountWebhooks.md +0 -55
- data/docs/AnalyticsTags.md +0 -63
- data/docs/ApiKeys.md +0 -65
- data/docs/DomainKeys.md +0 -49
- data/docs/Domains.md +0 -82
- data/docs/EmailValidation.md +0 -34
- data/docs/Events.md +0 -48
- data/docs/Logs.md +0 -67
- data/docs/MessageBuilder.md +0 -120
- data/docs/Metrics.md +0 -108
- data/docs/OptInHandler.md +0 -103
- data/docs/Snippets.md +0 -519
- data/docs/Subaccounts.md +0 -68
- data/docs/Suppressions.md +0 -92
- data/docs/Templates.md +0 -92
- data/docs/Webhooks.md +0 -65
- data/docs/railgun/EmailValidation.md +0 -34
- data/docs/railgun/Overview.md +0 -11
- data/docs/railgun/Parameters.md +0 -83
- data/mailgun.gemspec +0 -47
- data/spec/integration/account_webhooks_spec.rb +0 -57
- data/spec/integration/analytics_tags_spec.rb +0 -54
- data/spec/integration/api_keys_spec.rb +0 -50
- data/spec/integration/bounces_spec.rb +0 -45
- data/spec/integration/campaign_spec.rb +0 -62
- data/spec/integration/complaints_spec.rb +0 -40
- data/spec/integration/domain_keys_spec.rb +0 -124
- data/spec/integration/domains_spec.rb +0 -201
- data/spec/integration/email_validation_spec.rb +0 -73
- data/spec/integration/events_spec.rb +0 -28
- data/spec/integration/list_members_spec.rb +0 -64
- data/spec/integration/list_spec.rb +0 -59
- data/spec/integration/logs_spec.rb +0 -105
- data/spec/integration/mailer_spec.rb +0 -65
- data/spec/integration/mailgun_spec.rb +0 -198
- data/spec/integration/messages/sample_data/mime.txt +0 -38
- data/spec/integration/metrics_spec.rb +0 -224
- data/spec/integration/routes_spec.rb +0 -91
- data/spec/integration/stats_spec.rb +0 -17
- data/spec/integration/subaccounts_spec.rb +0 -57
- data/spec/integration/suppressions_spec.rb +0 -320
- data/spec/integration/templates_spec.rb +0 -137
- data/spec/integration/unsubscribes_spec.rb +0 -44
- data/spec/integration/webhook_spec.rb +0 -79
- data/spec/spec_helper.rb +0 -53
- data/spec/unit/client_spec.rb +0 -448
- data/spec/unit/connection/test_client.rb +0 -169
- data/spec/unit/events/events_spec.rb +0 -88
- data/spec/unit/exceptions/exceptions_spec.rb +0 -31
- data/spec/unit/helpers/api_version_checker_spec.rb +0 -206
- data/spec/unit/lists/opt_in_handler_spec.rb +0 -28
- data/spec/unit/mailgun_spec.rb +0 -171
- data/spec/unit/messages/batch_message_spec.rb +0 -148
- data/spec/unit/messages/message_builder_spec.rb +0 -745
- data/spec/unit/messages/sample_data/mailgun_icon.png +0 -0
- data/spec/unit/messages/sample_data/mime.txt +0 -38
- data/spec/unit/messages/sample_data/rackspace_logo.jpg +0 -0
- data/spec/unit/messages/sample_data/unknown.type +0 -0
- data/spec/unit/railgun/content_type_spec.rb +0 -89
- data/spec/unit/railgun/mailer_spec.rb +0 -391
- data/spec/unit/response_spec.rb +0 -225
- data/spec/unit/webhooks_spec.rb +0 -121
- data/vcr_cassettes/For_the_suppressions_handling_class/creates_a_single_bounce.yml +0 -55
- data/vcr_cassettes/account_webhooks.yml +0 -269
- data/vcr_cassettes/analytics_tags.yml +0 -187
- data/vcr_cassettes/api_keys.yml +0 -212
- data/vcr_cassettes/bounces.yml +0 -136
- data/vcr_cassettes/complaints.yml +0 -315
- data/vcr_cassettes/domains.todo.yml +0 -42
- data/vcr_cassettes/domains.yml +0 -1243
- data/vcr_cassettes/email_validation.yml +0 -152
- data/vcr_cassettes/events.yml +0 -69
- data/vcr_cassettes/exceptions-invalid-api-key.yml +0 -52
- data/vcr_cassettes/exceptions-invalid-data.yml +0 -52
- data/vcr_cassettes/exceptions-not-allowed.yml +0 -54
- data/vcr_cassettes/exceptions.yml +0 -92
- data/vcr_cassettes/list_members.yml +0 -328
- data/vcr_cassettes/logs.yml +0 -53
- data/vcr_cassettes/mailer_invalid_domain.yml +0 -109
- data/vcr_cassettes/mailing_list.todo.yml +0 -43
- data/vcr_cassettes/mailing_list.yml +0 -682
- data/vcr_cassettes/message_deliver.yml +0 -149
- data/vcr_cassettes/metrics.yml +0 -116
- data/vcr_cassettes/routes.yml +0 -359
- data/vcr_cassettes/send_message.yml +0 -158
- data/vcr_cassettes/stats.yml +0 -48
- data/vcr_cassettes/subaccounts.yml +0 -270
- data/vcr_cassettes/suppressions.yml +0 -1392
- data/vcr_cassettes/templates.yml +0 -1065
- data/vcr_cassettes/unsubscribes.yml +0 -401
- data/vcr_cassettes/webhooks.yml +0 -246
- data/vcr_cassettes/webhooks_v4.yml +0 -275
data/docs/ApiKeys.md
DELETED
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
Mailgun - API Keys
|
|
2
|
-
====================
|
|
3
|
-
|
|
4
|
-
This is the Mailgun Ruby *API Keys* utilities.
|
|
5
|
-
|
|
6
|
-
The below assumes you've already installed the Mailgun Ruby SDK in to your
|
|
7
|
-
project. If not, go back to the master README for instructions.
|
|
8
|
-
|
|
9
|
-
Usage - API Keys
|
|
10
|
-
-----------------------
|
|
11
|
-
|
|
12
|
-
```ruby
|
|
13
|
-
# First, instantiate the Mailgun Client with your API key
|
|
14
|
-
mg_client = Mailgun::Client.new('your-api-key', 'api.mailgun.net', 'v1')
|
|
15
|
-
api_keys = Mailgun::ApiKeys.new(mg_client)
|
|
16
|
-
```
|
|
17
|
-
|
|
18
|
-
API Keys methods:
|
|
19
|
-
|
|
20
|
-
```ruby
|
|
21
|
-
# List API keys
|
|
22
|
-
api_keys.list
|
|
23
|
-
|
|
24
|
-
# List API keys filtered by kind and domain
|
|
25
|
-
api_keys.list(kind: 'domain', domain_name: 'my.perfect.domain')
|
|
26
|
-
|
|
27
|
-
# Create a user API key
|
|
28
|
-
api_keys.create(
|
|
29
|
-
kind: 'user',
|
|
30
|
-
role: 'admin',
|
|
31
|
-
description: 'desc'
|
|
32
|
-
)
|
|
33
|
-
|
|
34
|
-
# Create a sending key for a domain, expiring in 1 day
|
|
35
|
-
api_keys.create(
|
|
36
|
-
kind: 'domain',
|
|
37
|
-
domain_name: 'my.perfect.domain',
|
|
38
|
-
role: 'sending',
|
|
39
|
-
expiration: 86_400
|
|
40
|
-
)
|
|
41
|
-
|
|
42
|
-
# Delete an API key
|
|
43
|
-
api_keys.remove('key-id')
|
|
44
|
-
|
|
45
|
-
# Regenerate the public API key
|
|
46
|
-
api_keys.regenerate
|
|
47
|
-
```
|
|
48
|
-
|
|
49
|
-
Supported `create` options:
|
|
50
|
-
|
|
51
|
-
| Option | Description |
|
|
52
|
-
|---------------|-------------|
|
|
53
|
-
| `kind` | Type of API key: `domain`, `user` or `web`. Defaults to `user` |
|
|
54
|
-
| `role` | Key role: `admin`, `basic`, `sending` (for `domain` keys) or `developer` |
|
|
55
|
-
| `domain_name` | Domain to associate with the key, for `domain` keys |
|
|
56
|
-
| `description` | Key description |
|
|
57
|
-
| `expiration` | Key lifetime in seconds, must be greater than 0 if set |
|
|
58
|
-
| `user_id` | API key user's ID, should be provided for `web` keys |
|
|
59
|
-
| `user_name` | API key user's name |
|
|
60
|
-
| `email` | API key user's email address, should be provided for `web` keys |
|
|
61
|
-
|
|
62
|
-
More Documentation
|
|
63
|
-
------------------
|
|
64
|
-
See the official [Mailgun API Keys Docs](https://documentation.mailgun.com/docs/mailgun/api-reference/send/mailgun/keys)
|
|
65
|
-
for more information
|
data/docs/DomainKeys.md
DELETED
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
Mailgun - DomainKeys
|
|
2
|
-
====================
|
|
3
|
-
|
|
4
|
-
This is the Mailgun Ruby *DomainKeys* utilities.
|
|
5
|
-
|
|
6
|
-
The below assumes you've already installed the Mailgun Ruby SDK in to your
|
|
7
|
-
project. If not, go back to the master README for instructions. It currently supports
|
|
8
|
-
all calls except credentials.
|
|
9
|
-
|
|
10
|
-
Usage - DomainKeys
|
|
11
|
-
-----------------------
|
|
12
|
-
First, instantiate the Mailgun Client with your API key
|
|
13
|
-
```ruby
|
|
14
|
-
mg_client = Mailgun::Client.new('your-api-key')
|
|
15
|
-
domainer = Mailgun::DomainKeys.new(mg_client)
|
|
16
|
-
```
|
|
17
|
-
|
|
18
|
-
Domain Keys methods:
|
|
19
|
-
|
|
20
|
-
```ruby
|
|
21
|
-
# List keys for all domains
|
|
22
|
-
domainer.list_domain_keys { some: 'options' }
|
|
23
|
-
|
|
24
|
-
# Create a domain key
|
|
25
|
-
domainer.create_domain_key { some: 'options' }
|
|
26
|
-
|
|
27
|
-
# Delete a domain key
|
|
28
|
-
domainer.delete_domain_key { some: 'options' }
|
|
29
|
-
|
|
30
|
-
# Activate a domain key
|
|
31
|
-
domainer.activate_domain_key 'my.perfect.domain', 'selector'
|
|
32
|
-
|
|
33
|
-
# List domain keys
|
|
34
|
-
domainer.get_domain_keys 'my.perfect.domain'
|
|
35
|
-
|
|
36
|
-
# Deactivate a domain key
|
|
37
|
-
domainer.deactivate_domain_key 'my.perfect.domain', 'selector'
|
|
38
|
-
|
|
39
|
-
# Update DKIM authority
|
|
40
|
-
domainer.update_domain_dkim_authority 'my.perfect.domain', { some: 'options' }
|
|
41
|
-
|
|
42
|
-
# Update a DKIM selector
|
|
43
|
-
domainer.update_domain_dkim_selector 'my.perfect.domain', { some: 'options' }
|
|
44
|
-
```
|
|
45
|
-
|
|
46
|
-
More Documentation
|
|
47
|
-
------------------
|
|
48
|
-
See the official [Mailgun Domain Docs](https://documentation.mailgun.com/docs/mailgun/api-reference/send/mailgun/domain-keys)
|
|
49
|
-
for more information
|
data/docs/Domains.md
DELETED
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
Mailgun - Domains
|
|
2
|
-
====================
|
|
3
|
-
|
|
4
|
-
This is the Mailgun Ruby *Domain* utilities.
|
|
5
|
-
|
|
6
|
-
The below assumes you've already installed the Mailgun Ruby SDK in to your
|
|
7
|
-
project. If not, go back to the master README for instructions. It currently supports
|
|
8
|
-
all calls except credentials.
|
|
9
|
-
|
|
10
|
-
Usage - Domains
|
|
11
|
-
-----------------------
|
|
12
|
-
First, instantiate the Mailgun Client with your API key
|
|
13
|
-
```ruby
|
|
14
|
-
mg_client = Mailgun::Client.new('your-api-key')
|
|
15
|
-
domainer = Mailgun::Domains.new(mg_client)
|
|
16
|
-
```
|
|
17
|
-
|
|
18
|
-
Core Domain methods:
|
|
19
|
-
|
|
20
|
-
```ruby
|
|
21
|
-
# Get a list of current domains.
|
|
22
|
-
domainer.list
|
|
23
|
-
|
|
24
|
-
# Add a new domain
|
|
25
|
-
domainer.create 'my.new.moreness'
|
|
26
|
-
# or with options
|
|
27
|
-
domainer.create 'my.new.moreness', { some: 'options' }
|
|
28
|
-
|
|
29
|
-
# View details of a domain
|
|
30
|
-
domainer.get 'my.perfect.domain'
|
|
31
|
-
|
|
32
|
-
# Update a domain
|
|
33
|
-
domainer.update 'my.new.moreness', { some: 'options' }
|
|
34
|
-
|
|
35
|
-
# Verify a domain
|
|
36
|
-
domainer.verify 'my.perfect.domain'
|
|
37
|
-
|
|
38
|
-
# Remove a domain
|
|
39
|
-
domainer.remove 'this.one.is.not.needed.'
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
```
|
|
43
|
-
|
|
44
|
-
Domain Tracking methods:
|
|
45
|
-
|
|
46
|
-
```ruby
|
|
47
|
-
# Get tracking settings
|
|
48
|
-
domainer.get_domain_tracking_settings 'my.perfect.domain'
|
|
49
|
-
|
|
50
|
-
# Update click tracking settings
|
|
51
|
-
domainer.update_domain_tracking_click_settings 'my.perfect.domain', { some: 'options' }
|
|
52
|
-
|
|
53
|
-
# Update open tracking settings
|
|
54
|
-
domainer.update_domain_tracking_open_settings 'my.perfect.domain', { some: 'options' }
|
|
55
|
-
|
|
56
|
-
# Update unsubscribe tracking settings
|
|
57
|
-
domainer.update_domain_tracking_unsubscribe_settings 'my.perfect.domain', { some: 'options' }
|
|
58
|
-
|
|
59
|
-
# Tracking Certificate: Get certificate and status
|
|
60
|
-
domainer.get_domain_tracking_certificate 'my.perfect.domain'
|
|
61
|
-
|
|
62
|
-
# Tracking Certificate: Regenerate expired certificate
|
|
63
|
-
domainer.regenerate_domain_tracking_certificate 'my.perfect.domain', { some: 'options' }
|
|
64
|
-
|
|
65
|
-
# Tracking Certificate: Generate
|
|
66
|
-
domainer.generate_domain_tracking_certificate 'my.perfect.domain', { some: 'options' }
|
|
67
|
-
```
|
|
68
|
-
|
|
69
|
-
DKIM Security methods:
|
|
70
|
-
|
|
71
|
-
```ruby
|
|
72
|
-
# Update Automatic Sender Security DKIM key rotation for a domain
|
|
73
|
-
domainer.dkim_rotation 'my.perfect.domain', true, { some: 'options' }
|
|
74
|
-
|
|
75
|
-
# Rotate Automatic Sender Security DKIM key for a domain
|
|
76
|
-
domainer.dkim_rotate 'my.perfect.domain'
|
|
77
|
-
```
|
|
78
|
-
|
|
79
|
-
More Documentation
|
|
80
|
-
------------------
|
|
81
|
-
See the official [Mailgun Domain Docs](https://documentation.mailgun.com/docs/mailgun/api-reference/send/mailgun/domains)
|
|
82
|
-
for more information
|
data/docs/EmailValidation.md
DELETED
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
Mailgun - Email Validation
|
|
2
|
-
====================
|
|
3
|
-
|
|
4
|
-
This is the Mailgun Ruby *Email Validation* utilities.
|
|
5
|
-
|
|
6
|
-
The below assumes you've already installed the Mailgun Ruby SDK in to your
|
|
7
|
-
project. If not, go back to the master README for instructions.
|
|
8
|
-
|
|
9
|
-
Usage - Email Validation
|
|
10
|
-
-----------------------
|
|
11
|
-
|
|
12
|
-
```ruby
|
|
13
|
-
# First, instantiate the Mailgun Address. It pulls api key for Client from Mailgun.api_key variable.
|
|
14
|
-
email_validator = Mailgun::Address.new
|
|
15
|
-
|
|
16
|
-
# Given an arbitrary address, validates address based off defined checks.
|
|
17
|
-
# Response Example:
|
|
18
|
-
# {
|
|
19
|
-
# "address": "existingemail@realdomain.com",
|
|
20
|
-
# "is_disposable_address": false,
|
|
21
|
-
# "is_role_address": false,
|
|
22
|
-
# "reason": [],
|
|
23
|
-
# "result": "deliverable",
|
|
24
|
-
# "risk": "low"
|
|
25
|
-
# }
|
|
26
|
-
email_validator.validate('email@example.com')
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
```
|
|
30
|
-
|
|
31
|
-
More Documentation
|
|
32
|
-
------------------
|
|
33
|
-
See the official [Mailgun Email Validation Docs](https://documentation.mailgun.com/en/latest/api-email-validation.html)
|
|
34
|
-
for more information
|
data/docs/Events.md
DELETED
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
Mailgun - Events
|
|
2
|
-
====================
|
|
3
|
-
|
|
4
|
-
_WARNING: This API is deprecated in favor of our Logs API._
|
|
5
|
-
|
|
6
|
-
This is the Mailgun Ruby *Events* utility.
|
|
7
|
-
|
|
8
|
-
The below assumes you've already installed the Mailgun Ruby SDK in your project.
|
|
9
|
-
If not, go back to the master README for a few quick install steps.
|
|
10
|
-
|
|
11
|
-
Events: Provides methods for traversing the Mailgun Events API.
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
Usage - Events
|
|
15
|
-
-----------------------------------------------------
|
|
16
|
-
Here's how to use the Events Handler to pull events.
|
|
17
|
-
|
|
18
|
-
```ruby
|
|
19
|
-
# First, instantiate the SDK with your API credentials, domain, and required parameters for example.
|
|
20
|
-
mg_client = Mailgun::Client.new("your-api-key")
|
|
21
|
-
mg_events = Mailgun::Events.new(mg_client, "your-domain")
|
|
22
|
-
|
|
23
|
-
result = mg_events.get({'limit' => 25,
|
|
24
|
-
'recipient' => 'joe@example.com'})
|
|
25
|
-
|
|
26
|
-
result.to_h['items'].each do | item |
|
|
27
|
-
# outputs "Delivered - 20140509184016.12571.48844@example.com"
|
|
28
|
-
puts "#{item['event']} - #{item['message']['headers']['message-id']}"
|
|
29
|
-
end
|
|
30
|
-
|
|
31
|
-
# Want more results?
|
|
32
|
-
result = mg_events.next
|
|
33
|
-
|
|
34
|
-
# Go backwards?
|
|
35
|
-
result = mg_events.previous
|
|
36
|
-
```
|
|
37
|
-
|
|
38
|
-
A few notes:
|
|
39
|
-
1. Next will use the pagination links to advance the result set.
|
|
40
|
-
Retain the mg_events object to query forward, or reverse, at any time.
|
|
41
|
-
2. If the result set is less than your limit, do not worry. A
|
|
42
|
-
second query against "next" will return the next 25 results since the
|
|
43
|
-
last time you called "next".
|
|
44
|
-
|
|
45
|
-
More Documentation
|
|
46
|
-
------------------
|
|
47
|
-
See the official [Mailgun Docs](https://documentation.mailgun.com/en/latest/api-events.html)
|
|
48
|
-
for more information.
|
data/docs/Logs.md
DELETED
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
Mailgun - Logs
|
|
2
|
-
====================
|
|
3
|
-
|
|
4
|
-
This is the Mailgun Ruby *Logs* utilities.
|
|
5
|
-
|
|
6
|
-
The below assumes you've already installed the Mailgun Ruby SDK in to your
|
|
7
|
-
project. If not, go back to the master README for instructions. It currently supports
|
|
8
|
-
all calls except credentials.
|
|
9
|
-
|
|
10
|
-
---
|
|
11
|
-
|
|
12
|
-
Mailgun collects many different events and generates event logs which are available
|
|
13
|
-
in your Control Panel. This data is also available via our analytics logs API endpoint.
|
|
14
|
-
|
|
15
|
-
You can view additional samples in the [logs_spec.rb](/spec/integration/logs_spec.rb)
|
|
16
|
-
or the Logs client API in [logs.rb](/lib/logs/logs.rb).
|
|
17
|
-
|
|
18
|
-
Usage
|
|
19
|
-
-----
|
|
20
|
-
|
|
21
|
-
To get an instance of the Logs client:
|
|
22
|
-
|
|
23
|
-
```ruby
|
|
24
|
-
require 'mailgun'
|
|
25
|
-
|
|
26
|
-
mg_client = Mailgun::Client.new('your-api-key', 'mailgun-api-host', 'v1')
|
|
27
|
-
logs = Mailgun::Logs.new(mg_client)
|
|
28
|
-
````
|
|
29
|
-
---
|
|
30
|
-
Get filtered logs for an account:
|
|
31
|
-
```ruby
|
|
32
|
-
options = {
|
|
33
|
-
{
|
|
34
|
-
start: 'Mon, 08 Jul 2024 00:00:00 -0000',
|
|
35
|
-
end: 'Fri, 12 Jul 2024 00:00:00 -0000',
|
|
36
|
-
filter: {
|
|
37
|
-
AND: [
|
|
38
|
-
{
|
|
39
|
-
attribute: 'domain',
|
|
40
|
-
comparator: '=',
|
|
41
|
-
values: [
|
|
42
|
-
{
|
|
43
|
-
label: 'example.com',
|
|
44
|
-
value: 'example.com'
|
|
45
|
-
}
|
|
46
|
-
]
|
|
47
|
-
}
|
|
48
|
-
]
|
|
49
|
-
},
|
|
50
|
-
include_subaccounts: true,
|
|
51
|
-
pagination: {
|
|
52
|
-
sort: 'timestamp:asc',
|
|
53
|
-
token: 'cjsijbijewbu78t678tVTYUYU76754fyuiksin865g',
|
|
54
|
-
limit: 50
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
logs.account_logs(options)
|
|
60
|
-
```
|
|
61
|
-
|
|
62
|
-
---
|
|
63
|
-
|
|
64
|
-
More Documentation
|
|
65
|
-
------------------
|
|
66
|
-
See the official [Mailgun Domain Docs](https://documentation.mailgun.com/docs/mailgun/api-reference/openapi-final/tag/Logs/)
|
|
67
|
-
for more information
|
data/docs/MessageBuilder.md
DELETED
|
@@ -1,120 +0,0 @@
|
|
|
1
|
-
Mailgun - Messages
|
|
2
|
-
====================
|
|
3
|
-
|
|
4
|
-
This is the Mailgun Ruby *Message* utilities.
|
|
5
|
-
|
|
6
|
-
The below assumes you've already installed the Mailgun Gem. If not, go back to the master README for instructions.
|
|
7
|
-
|
|
8
|
-
There are two utilities included, Message Builder and Batch Message.
|
|
9
|
-
|
|
10
|
-
Message Builder: Allows you to build a message object by calling methods for
|
|
11
|
-
each attribute.
|
|
12
|
-
Batch Message: Inherits Message Builder and allows you to iterate through
|
|
13
|
-
recipients from a list. Messages will fire after the 1,000th recipient has been
|
|
14
|
-
added.
|
|
15
|
-
|
|
16
|
-
Usage - Message Builder
|
|
17
|
-
-----------------------
|
|
18
|
-
Here's how to use Message Builder to build your Message.
|
|
19
|
-
|
|
20
|
-
```ruby
|
|
21
|
-
# First, instantiate the Mailgun Client with your API key
|
|
22
|
-
mg_client = Mailgun::Client.new("your-api-key")
|
|
23
|
-
mb_obj = Mailgun::MessageBuilder.new()
|
|
24
|
-
|
|
25
|
-
# Define the from address.
|
|
26
|
-
mb_obj.from("me@example.com", {"first"=>"Ruby", "last" => "SDK"});
|
|
27
|
-
|
|
28
|
-
# Define a to recipient.
|
|
29
|
-
mb_obj.add_recipient(:to, "john.doe@example.com", {"first" => "John", "last" => "Doe"});
|
|
30
|
-
|
|
31
|
-
# Define a cc recipient.
|
|
32
|
-
mb_obj.add_recipient(:cc, "sally.doe@example.com", {"first" => "Sally", "last" => "Doe"});
|
|
33
|
-
|
|
34
|
-
# Define the reply-to address.
|
|
35
|
-
mb_obj.reply_to("bob.doe@example.com", {"first" => "Bob", "last" => "Doe"});
|
|
36
|
-
|
|
37
|
-
# Define the subject.
|
|
38
|
-
mb_obj.subject("A message from the Ruby SDK using Message Builder!");
|
|
39
|
-
|
|
40
|
-
# Define the body of the message.
|
|
41
|
-
mb_obj.body_text("This is the text body of the message!");
|
|
42
|
-
|
|
43
|
-
# Define the HTML text of the message
|
|
44
|
-
mb_obj.body_html("<html><body><p>This is the text body of the message</p></body></html>");
|
|
45
|
-
|
|
46
|
-
# Set the Message-Id header, provide a valid Message-Id.
|
|
47
|
-
mb_obj.message_id("<20141014000000.11111.11111@example.com>")
|
|
48
|
-
|
|
49
|
-
# Or clear the Message-Id header, provide nil or empty string.
|
|
50
|
-
mb_obj.message_id(nil)
|
|
51
|
-
mb_obj.message_id('')
|
|
52
|
-
|
|
53
|
-
# Set the Message-tags at most 10.
|
|
54
|
-
mb_obj.add_tag("You can track mails as tag-units!")
|
|
55
|
-
|
|
56
|
-
# Campaigns and headers.
|
|
57
|
-
mb_obj.add_campaign_id("My-Awesome-Campaign");
|
|
58
|
-
mb_obj.header("Customer-Id", "12345");
|
|
59
|
-
|
|
60
|
-
# Custom variables
|
|
61
|
-
mb_obj.variable("Customer-Data", { :first_name => "John", :last_name => "Smith" })
|
|
62
|
-
|
|
63
|
-
# Attach a file and rename it.
|
|
64
|
-
mb_obj.add_attachment "/path/to/file/receipt_123491820.pdf", "Receipt.pdf"
|
|
65
|
-
|
|
66
|
-
# Attach an image inline.
|
|
67
|
-
mb_obj.add_inline_image "/path/to/file/header.png"
|
|
68
|
-
|
|
69
|
-
# Schedule message in the future
|
|
70
|
-
mb_obj.deliver_at("tomorrow 8:00AM PST");
|
|
71
|
-
|
|
72
|
-
# Turn Click Tracking on
|
|
73
|
-
mb_obj.track_clicks(true)
|
|
74
|
-
|
|
75
|
-
# Turn Click Tracking off
|
|
76
|
-
mb_obj.track_clicks(false)
|
|
77
|
-
|
|
78
|
-
# Finally, send your message using the client
|
|
79
|
-
result = mg_client.send_message("sending_domain.com", mb_obj)
|
|
80
|
-
|
|
81
|
-
puts result.body.to_s
|
|
82
|
-
```
|
|
83
|
-
|
|
84
|
-
Usage - Batch Message
|
|
85
|
-
---------------------
|
|
86
|
-
Here's how to use Batch Message to easily handle batch sending jobs.
|
|
87
|
-
|
|
88
|
-
```ruby
|
|
89
|
-
# First, instantiate the Mailgun Client with your API key
|
|
90
|
-
mg_client = Mailgun::Client.new("your-api-key")
|
|
91
|
-
|
|
92
|
-
# Create a Batch Message object, pass in the client and your domain.
|
|
93
|
-
mb_obj = Mailgun::BatchMessage.new(mg_client, "example.com")
|
|
94
|
-
|
|
95
|
-
# Define the from address.
|
|
96
|
-
mb_obj.from("me@example.com", {"first" => "Ruby", "last" => "SDK"});
|
|
97
|
-
|
|
98
|
-
# Define the subject.
|
|
99
|
-
mb_obj.subject("A message from the Ruby SDK using Message Builder!");
|
|
100
|
-
|
|
101
|
-
# Define the body of the message.
|
|
102
|
-
mb_obj.body_text("This is the text body of the message!");
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
# Loop through all of your recipients
|
|
106
|
-
mb_obj.add_recipient(:to, "john.doe@example.com", {"first" => "John", "last" => "Doe"});
|
|
107
|
-
mb_obj.add_recipient(:to, "jane.doe@example.com", {"first" => "Jane", "last" => "Doe"});
|
|
108
|
-
mb_obj.add_recipient(:to, "bob.doe@example.com", {"first" => "Bob", "last" => "Doe"});
|
|
109
|
-
...
|
|
110
|
-
mb_obj.add_recipient(:to, "sally.doe@example.com", {"first" => "Sally", "last" => "Doe"});
|
|
111
|
-
|
|
112
|
-
# Call finalize to get a list of message ids and totals.
|
|
113
|
-
message_ids = mb_obj.finalize
|
|
114
|
-
# {'id1234@example.com' => 1000, 'id5678@example.com' => 15}
|
|
115
|
-
```
|
|
116
|
-
|
|
117
|
-
More Documentation
|
|
118
|
-
------------------
|
|
119
|
-
See the official [Mailgun Docs](https://documentation.mailgun.com/en/latest/api-sending.html)
|
|
120
|
-
for more information.
|
data/docs/Metrics.md
DELETED
|
@@ -1,108 +0,0 @@
|
|
|
1
|
-
Mailgun - Metrics
|
|
2
|
-
====================
|
|
3
|
-
|
|
4
|
-
This is the Mailgun Ruby *Metrics* utilities.
|
|
5
|
-
|
|
6
|
-
The below assumes you've already installed the Mailgun Ruby SDK in to your
|
|
7
|
-
project. If not, go back to the master README for instructions. It currently supports
|
|
8
|
-
all calls except credentials.
|
|
9
|
-
|
|
10
|
-
---
|
|
11
|
-
|
|
12
|
-
Mailgun collects many different events and generates event metrics which are available
|
|
13
|
-
in your Control Panel. This data is also available via our analytics metrics API endpoint.
|
|
14
|
-
|
|
15
|
-
You can view additional samples in the [metrics_spec.rb](/spec/integration/metrics_spec.rb)
|
|
16
|
-
or the Metrics client API in [metrics.rb](/lib/metrics/metrics.rb).
|
|
17
|
-
|
|
18
|
-
Usage
|
|
19
|
-
-----
|
|
20
|
-
|
|
21
|
-
To get an instance of the Metrics client:
|
|
22
|
-
|
|
23
|
-
```ruby
|
|
24
|
-
require 'mailgun'
|
|
25
|
-
|
|
26
|
-
mg_client = Mailgun::Client.new('your-api-key', 'mailgun-api-host', 'v1')
|
|
27
|
-
metrics = Mailgun::Metrics.new(mg_client)
|
|
28
|
-
````
|
|
29
|
-
---
|
|
30
|
-
Get filtered metrics for an account:
|
|
31
|
-
```ruby
|
|
32
|
-
options = {
|
|
33
|
-
{
|
|
34
|
-
resolution: 'hour',
|
|
35
|
-
metrics: [
|
|
36
|
-
'accepted_count',
|
|
37
|
-
'delivered_count',
|
|
38
|
-
'clicked_rate',
|
|
39
|
-
'opened_rate'
|
|
40
|
-
],
|
|
41
|
-
include_aggregates: true,
|
|
42
|
-
start: 'Tue, 26 Nov 2024 20:56:50 -0500',
|
|
43
|
-
duration: '1m',
|
|
44
|
-
filter: {
|
|
45
|
-
AND: [
|
|
46
|
-
{
|
|
47
|
-
attribute: 'domain',
|
|
48
|
-
comparator: '!=',
|
|
49
|
-
values: [
|
|
50
|
-
{
|
|
51
|
-
label: 'example.com',
|
|
52
|
-
value: 'example.com'
|
|
53
|
-
}
|
|
54
|
-
]
|
|
55
|
-
}
|
|
56
|
-
]
|
|
57
|
-
},
|
|
58
|
-
dimensions: ['time'],
|
|
59
|
-
end: 'Tue, 30 Nov 2024 20:56:50 -0500',
|
|
60
|
-
include_subaccounts: true
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
metrics.account_metrics(options)
|
|
65
|
-
```
|
|
66
|
-
---
|
|
67
|
-
|
|
68
|
-
Get filtered usage metrics for an account:
|
|
69
|
-
```ruby
|
|
70
|
-
options = {
|
|
71
|
-
resolution: 'hour',
|
|
72
|
-
metrics: [
|
|
73
|
-
'accepted_count',
|
|
74
|
-
'delivered_count',
|
|
75
|
-
'clicked_rate',
|
|
76
|
-
'opened_rate'
|
|
77
|
-
],
|
|
78
|
-
include_aggregates: true,
|
|
79
|
-
start: 'Tue, 26 Nov 2024 20:56:50 -0500',
|
|
80
|
-
duration: '1m',
|
|
81
|
-
filter: {
|
|
82
|
-
AND: [
|
|
83
|
-
{
|
|
84
|
-
attribute: 'domain',
|
|
85
|
-
comparator: '!=',
|
|
86
|
-
values: [
|
|
87
|
-
{
|
|
88
|
-
label: 'example.com',
|
|
89
|
-
value: 'example.com'
|
|
90
|
-
}
|
|
91
|
-
]
|
|
92
|
-
}
|
|
93
|
-
]
|
|
94
|
-
},
|
|
95
|
-
dimensions: ['time'],
|
|
96
|
-
end: 'Tue, 30 Nov 2024 20:56:50 -0500',
|
|
97
|
-
include_subaccounts: true
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
metrics.account_usage_metrics(options)
|
|
101
|
-
```
|
|
102
|
-
|
|
103
|
-
---
|
|
104
|
-
|
|
105
|
-
More Documentation
|
|
106
|
-
------------------
|
|
107
|
-
See the official [Mailgun Domain Docs](https://documentation.mailgun.com/docs/mailgun/api-reference/openapi-final/tag/Metrics/)
|
|
108
|
-
for more information
|
data/docs/OptInHandler.md
DELETED
|
@@ -1,103 +0,0 @@
|
|
|
1
|
-
Mailgun - Lists
|
|
2
|
-
====================
|
|
3
|
-
|
|
4
|
-
This is the Mailgun Ruby *Lists* utilities.
|
|
5
|
-
|
|
6
|
-
The below assumes you've already installed the Mailgun Ruby SDK in your project.
|
|
7
|
-
If not, go back to the master README for a few quick install steps.
|
|
8
|
-
|
|
9
|
-
OptInHandler: Provides methods for authenticating an Opt-In Request.
|
|
10
|
-
|
|
11
|
-
The typical flow for using this utility would be as follows:
|
|
12
|
-
**Recipient Requests Subscribe** -> [Validate Recipient Address] -> [Generate Opt-In Link] -> [Email Recipient Opt-In Link]
|
|
13
|
-
**Recipient Clicks Opt-In Link** -> [Validate Opt-In Link] -> [Subscribe User] -> [Send final confirmation]
|
|
14
|
-
|
|
15
|
-
The above flow is modeled below.
|
|
16
|
-
|
|
17
|
-
Usage - Opt-In Handler (Recipient Requests Subscribe)
|
|
18
|
-
-----------------------------------------------------
|
|
19
|
-
Here's how to use Opt-In Handler to validate Opt-In requests.
|
|
20
|
-
|
|
21
|
-
```ruby
|
|
22
|
-
# First, instantiate the SDK with your API credentials, domain, and required parameters for example.
|
|
23
|
-
mg_client = Mailgun::Client.new("your-api-key")
|
|
24
|
-
mg_validate = Mailgun::Client.new("your-pub-api-key")
|
|
25
|
-
|
|
26
|
-
domain = 'example.com';
|
|
27
|
-
|
|
28
|
-
mailing_list = 'youlist@example.com';
|
|
29
|
-
secret_app_id = 'a_secret_passphrase';
|
|
30
|
-
recipient_address = 'recipient@example.com';
|
|
31
|
-
|
|
32
|
-
# Let's validate the customer's email address, using Mailgun's validation endpoint.
|
|
33
|
-
result = mg_validate.get('address/validate', {:address => recipient_address});
|
|
34
|
-
body = JSON.parse(result.body)
|
|
35
|
-
|
|
36
|
-
if body['is_valid'] == true
|
|
37
|
-
# Next, generate a hash.
|
|
38
|
-
generated_hash = Mailgun::OptInHandler.generate_hash(mailing_list, secret_app_id, recipient_address);
|
|
39
|
-
|
|
40
|
-
# Now, let's send a confirmation to the recipient with our link.
|
|
41
|
-
mg_client.send_message(domain, {:from => 'bob@example.com',
|
|
42
|
-
:to => recipient_address,
|
|
43
|
-
:subject => 'Please Confirm!',
|
|
44
|
-
:html => "<html><body>Hello,<br><br>You have requested to be subscribed
|
|
45
|
-
to the mailing list #{mailing_list}. Please <a
|
|
46
|
-
href=\"http://yourdomain.com/subscribe.php?hash=#{generated_hash}\">
|
|
47
|
-
confirm</a> your subscription.<br><br>Thank you!</body></html>"});
|
|
48
|
-
|
|
49
|
-
# Finally, let's add the subscriber to a Mailing List, as unsubscribed, so we can track non-conversions.
|
|
50
|
-
mg_client.post("lists/#{mailing_list}/members", {:address => recipient_address,
|
|
51
|
-
:subscribed => 'no',
|
|
52
|
-
:upsert => 'yes'});
|
|
53
|
-
end
|
|
54
|
-
```
|
|
55
|
-
|
|
56
|
-
Usage - Opt-In Handler (Recipient Clicks Opt In Link)
|
|
57
|
-
-----------------------------------------------------
|
|
58
|
-
Here's how to use Opt-In Handler to validate an Opt-In Hash.
|
|
59
|
-
|
|
60
|
-
```ruby
|
|
61
|
-
# First, instantiate the SDK with your API credentials and domain.
|
|
62
|
-
mg_client = Mailgun::Client.new("your-api-key")
|
|
63
|
-
domain = 'example.com';
|
|
64
|
-
|
|
65
|
-
# Now, validate the captured hash.
|
|
66
|
-
hash_validation = Mailgun::OptInHandler.validate_hash(secret_app_id, inbound_hash);
|
|
67
|
-
|
|
68
|
-
# Lastly, check to see if we have results, parse, subscribe, and send confirmation.
|
|
69
|
-
if !hash_validation.nil?
|
|
70
|
-
validated_list = hash_validation['mailing_list'];
|
|
71
|
-
validated_recipient = hash_validation['recipient_address'];
|
|
72
|
-
|
|
73
|
-
mg_client.put("lists/#{validated_list}/members/#{validated_recipient}",
|
|
74
|
-
{:address => validated_recipient,
|
|
75
|
-
:subscribed => 'yes'})
|
|
76
|
-
|
|
77
|
-
mg_client.send_message(domain, {:from => 'bob@example.com',
|
|
78
|
-
:to => validated_recipient,
|
|
79
|
-
:subject => 'Confirmation Received!',
|
|
80
|
-
:html => "<html><body>Hello,<br><br>We've successfully subscribed you to the list, #{validated_list}!<br><br>Thank you!
|
|
81
|
-
</body></html>"});
|
|
82
|
-
end
|
|
83
|
-
```
|
|
84
|
-
|
|
85
|
-
A few notes:
|
|
86
|
-
1. 'secret_app_id' can be anything. It's used as the *key* in hashing,
|
|
87
|
-
since your email address will vary. It should be secured like a password.
|
|
88
|
-
2. validateHash will return an array containing the recipient address and list
|
|
89
|
-
address.
|
|
90
|
-
3. You should *always* send an email confirmation before and after the
|
|
91
|
-
subscription request. This is what double-opt in means.
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
Available Functions
|
|
95
|
-
-----------------------------------------------------
|
|
96
|
-
|
|
97
|
-
`string generate_hash(string mailing_list, string secret_app_id, string recipient_address)`
|
|
98
|
-
|
|
99
|
-
`array validate_hash(string secret_app_id, string unique_hash)`
|
|
100
|
-
|
|
101
|
-
More Documentation
|
|
102
|
-
------------------
|
|
103
|
-
See the official [Mailgun Docs](https://documentation.mailgun.com/) for more information.
|