ohmysmtp-rails 0.1.2 → 0.1.7

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3c3000f4a22dc0707d3f3f9dcdecaf516fac706bdc516f548e8b2887e824ddc4
4
- data.tar.gz: 1ed67d355eec1c59b3b5726d390d853d382cc7f2295addd9aa6a51ae98034bf2
3
+ metadata.gz: d81c552bc6b41a27224f899c30770f06d4ec43fde051d597131fe88271d567f9
4
+ data.tar.gz: cebbc8aa094bd151f7ede8063c64ab95dcad6415b0e55da537c804ee8c275ff4
5
5
  SHA512:
6
- metadata.gz: d409fe132487a6f43e35e7217689890080ec6a4567c747eb390b29f31a63784842622ffddc88e2373a1dccafa97c7dc5cd0f14251f49b4d0cc1ca7ee7002239a
7
- data.tar.gz: c772331f9ff39a5fd7bab4e1f0a8c23d651b6db02fe53ca7bd5285b36e38c320c81619f31d8b53c6b496c3c2081a28bd0cca82965ee3d5c319d97fde35fce49f
6
+ metadata.gz: 83e7282255476746b6d1d02656bc4a38b707bf44970c8673781e692809c7418c31c80271b133462a685e94dc7c87b965c0fd730296c774fc9abb2af9d17a49de
7
+ data.tar.gz: df445b4af0d0cb736867b95cce2e41b82789d4002f05f7af303be517f1f0cff5329b1e780d15bed1ea9b188afa82f1feb6cf354870c070c0dd40aec966f1e111
data/README.md CHANGED
@@ -81,12 +81,41 @@ config.action_mailer.delivery_method = :ohmysmtp
81
81
  config.action_mailer.ohmysmtp_settings = { :api_token => Rails.application.secrets.ohmysmtp_api_token }
82
82
  ```
83
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
+
84
109
  ## Support
85
110
 
86
111
  For support please check the [OhMySMTP Documentation](https://docs.ohmysmtp.com) or contact us at support@ohmysmtp.com
87
112
 
88
113
  ## Contributing
89
114
 
115
+ Please ensure to add a test for any change you make. To run the tests:
116
+
117
+ `bin/test`
118
+
90
119
  Pull requests always welcome
91
120
 
92
121
  ## License
@@ -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.from.join(','),
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
- }.to_json,
30
+ replyto: mail.reply_to,
31
+ attachments: format_attachments(mail.attachments),
32
+ tags: mail.header['tags'].to_s
33
+ }.compact_blank.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
@@ -1,5 +1,5 @@
1
1
  module OhMySMTP
2
2
  module Rails
3
- VERSION = '0.1.2'
3
+ VERSION = '0.1.7'
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ohmysmtp-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - OhMySMTP
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-02-12 00:00:00.000000000 Z
11
+ date: 2021-04-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails