ohmysmtp-rails 0.1.1 → 0.1.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +30 -0
- data/lib/ohmysmtp-rails.rb +18 -4
- data/lib/ohmysmtp-rails/version.rb +1 -1
- metadata +5 -11
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 523762bd4817881c5212cc60c53c8296454d0ac29c29d0cf20dd2350beb47cb7
|
4
|
+
data.tar.gz: 85d60684a427afe9afd4320ba40fabcfc93324af60384f80b8b5bebd5c8df082
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cb9f127dc921ae6a0e2a9a9f6bc81e79f42bd59c792f05338c43e75b5ab37e711ddee2ab1d923fed37f6d103a3b2063aa706e606f1643384821ff43b226e2b1e
|
7
|
+
data.tar.gz: b4a59456d2706587ca69a15dfc5d22fbbba37c1ad6e8c73880eefce41e7a61d2e68ba3bc52594ca544cca33c91b7310cf063663dc228cdd5eb8b010ce9b130e4
|
data/README.md
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
# OhMySMTP::Rails
|
2
2
|
|
3
3
|
[![License: MIT](https://img.shields.io/badge/License-MIT-green.svg)](https://opensource.org/licenses/MIT)
|
4
|
+
[![Gem Version](https://badge.fury.io/rb/ohmysmtp-rails.svg)](https://badge.fury.io/rb/ohmysmtp-rails)
|
4
5
|
|
5
6
|
|
6
7
|
[OhMySMTP](https://ohmysmtp.com) lets you send transactional emails from your app over an easy to use API.
|
@@ -80,12 +81,41 @@ config.action_mailer.delivery_method = :ohmysmtp
|
|
80
81
|
config.action_mailer.ohmysmtp_settings = { :api_token => Rails.application.secrets.ohmysmtp_api_token }
|
81
82
|
```
|
82
83
|
|
84
|
+
## Tagging
|
85
|
+
|
86
|
+
You can tag messages and filter them later in the OhMySMTP UI. To do this, pass the tags as a header by adding a tag variable to your `mail` method call.
|
87
|
+
|
88
|
+
```ruby
|
89
|
+
class TestMailer < ApplicationMailer
|
90
|
+
default from: 'notifications@example.com',
|
91
|
+
to: 'fake@sdfasdfsdaf.com'
|
92
|
+
|
93
|
+
def single_tag
|
94
|
+
mail(
|
95
|
+
tags: 'test tag' # One tag
|
96
|
+
)
|
97
|
+
end
|
98
|
+
|
99
|
+
def multi_tag
|
100
|
+
mail(
|
101
|
+
tags: "['test tag', 'another-tag']" # Multiple tags
|
102
|
+
)
|
103
|
+
end
|
104
|
+
end
|
105
|
+
```
|
106
|
+
|
107
|
+
Note that this should always be a string, even if using an array of multiple tags.
|
108
|
+
|
83
109
|
## Support
|
84
110
|
|
85
111
|
For support please check the [OhMySMTP Documentation](https://docs.ohmysmtp.com) or contact us at support@ohmysmtp.com
|
86
112
|
|
87
113
|
## Contributing
|
88
114
|
|
115
|
+
Please ensure to add a test for any change you make. To run the tests:
|
116
|
+
|
117
|
+
`bin/test`
|
118
|
+
|
89
119
|
Pull requests always welcome
|
90
120
|
|
91
121
|
## License
|
data/lib/ohmysmtp-rails.rb
CHANGED
@@ -20,14 +20,17 @@ module OhMySMTP
|
|
20
20
|
result = HTTParty.post(
|
21
21
|
'https://app.ohmysmtp.com/api/v1/send',
|
22
22
|
body: {
|
23
|
-
from: mail.
|
23
|
+
from: mail.from_address.to_s,
|
24
24
|
to: mail.to.join(','),
|
25
25
|
subject: mail.subject,
|
26
|
-
htmlbody: mail.body.to_s,
|
26
|
+
htmlbody: mail.html_part ? mail.html_part.body.decoded : mail.body.to_s,
|
27
|
+
textbody: mail.multipart? ? (mail.text_part ? mail.text_part.body.decoded : nil) : nil,
|
27
28
|
cc: mail.cc&.join(','),
|
28
29
|
bcc: mail.bcc&.join(','),
|
29
|
-
replyto: mail.reply_to
|
30
|
-
|
30
|
+
replyto: mail.reply_to,
|
31
|
+
attachments: format_attachments(mail.attachments),
|
32
|
+
tags: mail.header['tags'].to_s
|
33
|
+
}.compact.to_json,
|
31
34
|
headers: {
|
32
35
|
'User-Agent' => "OhMySMTP Rails Gem v#{OhMySMTP::Rails::VERSION}",
|
33
36
|
'Accept' => 'application/json',
|
@@ -60,5 +63,16 @@ module OhMySMTP
|
|
60
63
|
res = result.parsed_response
|
61
64
|
raise res['error']&.to_s || res['errors']&.to_s
|
62
65
|
end
|
66
|
+
|
67
|
+
def format_attachments(attachments)
|
68
|
+
attachments.map do |attachment|
|
69
|
+
{
|
70
|
+
name: attachment.filename,
|
71
|
+
content_type: attachment.mime_type,
|
72
|
+
content: Base64.encode64(attachment.body.encoded),
|
73
|
+
cid: attachment.content_id
|
74
|
+
}.compact
|
75
|
+
end
|
76
|
+
end
|
63
77
|
end
|
64
78
|
end
|
metadata
CHANGED
@@ -1,35 +1,29 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ohmysmtp-rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- OhMySMTP
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-03-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - "~>"
|
18
|
-
- !ruby/object:Gem::Version
|
19
|
-
version: 6.0.2
|
20
17
|
- - ">="
|
21
18
|
- !ruby/object:Gem::Version
|
22
|
-
version:
|
23
|
-
type: :
|
19
|
+
version: '0'
|
20
|
+
type: :development
|
24
21
|
prerelease: false
|
25
22
|
version_requirements: !ruby/object:Gem::Requirement
|
26
23
|
requirements:
|
27
|
-
- - "~>"
|
28
|
-
- !ruby/object:Gem::Version
|
29
|
-
version: 6.0.2
|
30
24
|
- - ">="
|
31
25
|
- !ruby/object:Gem::Version
|
32
|
-
version:
|
26
|
+
version: '0'
|
33
27
|
- !ruby/object:Gem::Dependency
|
34
28
|
name: actionmailer
|
35
29
|
requirement: !ruby/object:Gem::Requirement
|