ohmysmtp-rails 0.1.0 → 0.1.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +5 -0
- data/lib/ohmysmtp-rails.rb +20 -5
- 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: cb55e14160a857b8a6fc2355551c8ad9121f1cd715afb741baa062793b1560b8
|
4
|
+
data.tar.gz: 32251e93c2b3c08f3d59f185e427df7d84bea295be08a90c90a57854111dc976
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f0b424316ae395667c4c833f38944f955eb508104facf16f601a973f00b8603149592fa3b6cf9ae210ab2e0047df5ff7dcc59130415523a39cf02ec19c0d2dcf
|
7
|
+
data.tar.gz: 17bcb1101f56de25245fcc319b693e7c8629a598a89dbeb971bebc28a00def77f86d100d8ef2e822cf57fc97b50b5aba1d5f9471e808660e5ceb3ae345d3d101
|
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.
|
@@ -86,6 +87,10 @@ For support please check the [OhMySMTP Documentation](https://docs.ohmysmtp.com)
|
|
86
87
|
|
87
88
|
## Contributing
|
88
89
|
|
90
|
+
Please ensure to add a test for any change you make. To run the tests:
|
91
|
+
|
92
|
+
`bin/test`
|
93
|
+
|
89
94
|
Pull requests always welcome
|
90
95
|
|
91
96
|
## License
|
data/lib/ohmysmtp-rails.rb
CHANGED
@@ -20,14 +20,16 @@ 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,
|
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
|
+
}.compact.to_json,
|
31
33
|
headers: {
|
32
34
|
'User-Agent' => "OhMySMTP Rails Gem v#{OhMySMTP::Rails::VERSION}",
|
33
35
|
'Accept' => 'application/json',
|
@@ -56,7 +58,20 @@ module OhMySMTP
|
|
56
58
|
def handle_response(result)
|
57
59
|
return unless result.code != 200
|
58
60
|
|
59
|
-
|
61
|
+
# TODO: Improved error handling
|
62
|
+
res = result.parsed_response
|
63
|
+
raise res['error']&.to_s || res['errors']&.to_s
|
64
|
+
end
|
65
|
+
|
66
|
+
def format_attachments(attachments)
|
67
|
+
attachments.map do |attachment|
|
68
|
+
{
|
69
|
+
name: attachment.filename,
|
70
|
+
content_type: attachment.mime_type,
|
71
|
+
content: Base64.encode64(attachment.body.encoded),
|
72
|
+
cid: attachment.content_id
|
73
|
+
}.compact
|
74
|
+
end
|
60
75
|
end
|
61
76
|
end
|
62
77
|
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.5
|
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-27 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
|