mail_plugger 1.4.0 → 1.6.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +28 -0
- data/README.md +3 -3
- data/lib/fake_plugger/delivery_method.rb +15 -15
- data/lib/mail_plugger/delivery_method.rb +1 -1
- data/lib/mail_plugger/error.rb +9 -8
- data/lib/mail_plugger/mail_helper.rb +20 -20
- data/lib/mail_plugger/version.rb +1 -1
- data/lib/mail_plugger.rb +6 -6
- metadata +18 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9c14f1e3d3349963e366c96c190b4c5f4a5952acab1d3edea57c1362a2f2cbbe
|
4
|
+
data.tar.gz: d5c5c499539d4acfd55314cc740a6a59c5dc6a464f4203e09668e48d4e4b422f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: aaf64a78ca834024faf8c7c68e4b8170ae9f1b40a92828beebc8f4fa465bc9cd741ebd3aff470865512bb4103e2c5ba68c47d1d530dec85d096332edd4541ef8
|
7
|
+
data.tar.gz: ad58904037919d40948361eb9a6e3b39e5e6cbda1bee4c331bd6ad597f808457b6d9b05f7700799ff967b2378d4bccd8f3d58ff37d5a2e343123329d10cff4cf
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,33 @@
|
|
1
1
|
# Change log
|
2
2
|
|
3
|
+
## 1.6.1 (2022-05-27)
|
4
|
+
|
5
|
+
### Changes
|
6
|
+
|
7
|
+
* Update MailGrabber to version 1.2.1 because of security issues in the rack gem.
|
8
|
+
|
9
|
+
|
10
|
+
## 1.6.0 (2022-05-26)
|
11
|
+
|
12
|
+
### Changes
|
13
|
+
|
14
|
+
* Drop Ruby 2.6 support.
|
15
|
+
* Fix some grammar issues and typos.
|
16
|
+
* Update bundler and gems.
|
17
|
+
|
18
|
+
|
19
|
+
## 1.5.0 (2021-12-31)
|
20
|
+
|
21
|
+
### Changes
|
22
|
+
|
23
|
+
* Add Ruby 3.1 support.
|
24
|
+
* Drop Ruby 2.5 support.
|
25
|
+
* Require MFA on RubyGems.
|
26
|
+
* Update bundler and gems.
|
27
|
+
* Fix typo in the README.md.
|
28
|
+
* Replace Travis with GitHub Actions.
|
29
|
+
|
30
|
+
|
3
31
|
## 1.4.0 (2021-06-08)
|
4
32
|
|
5
33
|
### New features
|
data/README.md
CHANGED
@@ -3,11 +3,11 @@
|
|
3
3
|
[![Gem Version](https://badge.fury.io/rb/mail_plugger.svg)](https://badge.fury.io/rb/mail_plugger)
|
4
4
|
[![MIT license](https://img.shields.io/badge/license-MIT-brightgreen)](https://github.com/MailToolbox/mail_plugger/blob/main/LICENSE.txt)
|
5
5
|
[![Ruby Style Guide](https://img.shields.io/badge/code_style-rubocop-brightgreen.svg)](https://github.com/rubocop-hq/rubocop)
|
6
|
-
[![
|
6
|
+
[![MailPlugger CI](https://github.com/MailToolbox/mail_plugger/actions/workflows/mail_plugger_ci.yml/badge.svg)](https://github.com/MailToolbox/mail_plugger/actions/workflows/mail_plugger_ci.yml)
|
7
7
|
[![Maintainability](https://api.codeclimate.com/v1/badges/137881380fc475b4a836/maintainability)](https://codeclimate.com/github/MailToolbox/mail_plugger/maintainability)
|
8
8
|
[![Test Coverage](https://api.codeclimate.com/v1/badges/137881380fc475b4a836/test_coverage)](https://codeclimate.com/github/MailToolbox/mail_plugger/test_coverage)
|
9
9
|
|
10
|
-
**MailPlugger** helps you to use different mail providers' **SMTP** and **API**. You can use any SMTPs and APIs which one would like to use. It allows you to send different emails with different SMTPs and APIs. Also it can help to move between providers, load
|
10
|
+
**MailPlugger** helps you to use different mail providers' **SMTP** and **API**. You can use any SMTPs and APIs which one would like to use. It allows you to send different emails with different SMTPs and APIs. Also, it can help to move between providers, load balancing or cost management.
|
11
11
|
|
12
12
|
## Installation
|
13
13
|
|
@@ -46,7 +46,7 @@ Or install it yourself as:
|
|
46
46
|
|
47
47
|
# F<img src="https://raw.githubusercontent.com/MailToolbox/mail_plugger/main/images/fake_plugger800x500.png" height="22" />kePlugger
|
48
48
|
|
49
|
-
**FakePlugger** is a delivery method to mock **MailPlugger**. It is working similarly like **MailPlugger**, but it won't send any emails (but if we would like it is possible, just we should do manually). Also it can write out debug
|
49
|
+
**FakePlugger** is a delivery method to mock **MailPlugger**. It is working similarly like **MailPlugger**, but it won't send any emails (but if we would like it is possible, just we should do manually). Also, it can write out debug information, or we can manipulate the response with it. Another option that we can use **[MailGrabber](https://github.com/MailToolbox/mail_grabber)** web interface if the delivery method is `:fake_plugger`.
|
50
50
|
|
51
51
|
## Usage
|
52
52
|
|
@@ -23,10 +23,10 @@ module FakePlugger
|
|
23
23
|
# e.g. 'defined_api'
|
24
24
|
#
|
25
25
|
# @option options [Boolean] debug
|
26
|
-
# if true it will show debug
|
26
|
+
# if true, it will show debug information
|
27
27
|
#
|
28
28
|
# @option options [Boolean] raw_message
|
29
|
-
# if true it will show raw message
|
29
|
+
# if true, it will show raw message
|
30
30
|
#
|
31
31
|
# @option options [String/Symbol/Array/Hash] response
|
32
32
|
# the deliver! method will return with this value or if this value is nil
|
@@ -53,22 +53,22 @@ module FakePlugger
|
|
53
53
|
#
|
54
54
|
# Using API:
|
55
55
|
# Mock send message with the given client if the message parameter is a
|
56
|
-
# Mail::Message object. If 'response' parameter is nil then it will extract
|
57
|
-
#
|
56
|
+
# Mail::Message object. If 'response' parameter is nil, then it will extract
|
57
|
+
# this information from the Mail::Message object which was provided in the
|
58
58
|
# 'delivery_options'. After that it generates a hash with these data and
|
59
59
|
# returns with the provided client class which has a 'deliver' method, but
|
60
60
|
# it won't call the 'deliver' method.
|
61
61
|
# If the 'response' parameter is a hash with 'return_delivery_data: true'
|
62
|
-
# then it will
|
62
|
+
# then it will return with the extracted delivery data.
|
63
63
|
#
|
64
64
|
#
|
65
|
-
# If the 'response' parameter is not nil then
|
65
|
+
# If the 'response' parameter is not nil, then returns with that given data
|
66
66
|
# without call any other methods.
|
67
|
-
# Except if 'debug' is true. In this case it will call those methods which
|
68
|
-
#
|
69
|
-
# If 'debug' is true then it prints out some debug
|
70
|
-
# If 'raw_message' is true then it prints out raw message.
|
71
|
-
#
|
67
|
+
# Except if 'debug' is true. In this case, it will call those methods which
|
68
|
+
# are calling in normal operation as well.
|
69
|
+
# If 'debug' is true, then it prints out some debug information.
|
70
|
+
# If 'raw_message' is true, then it prints out raw message.
|
71
|
+
# If 'use_mail_grabber' is true, then it stores the message in a database.
|
72
72
|
#
|
73
73
|
# @param [Mail::Message] message what we would like to send
|
74
74
|
#
|
@@ -165,7 +165,7 @@ module FakePlugger
|
|
165
165
|
|
166
166
|
private
|
167
167
|
|
168
|
-
# Call extra options like show debug
|
168
|
+
# Call extra options like show debug information, show raw message,
|
169
169
|
# use mail grabber.
|
170
170
|
def call_extra_options
|
171
171
|
show_debug_info if @debug
|
@@ -176,7 +176,7 @@ module FakePlugger
|
|
176
176
|
MailGrabber::DeliveryMethod.new.deliver!(@message)
|
177
177
|
end
|
178
178
|
|
179
|
-
# Debug
|
179
|
+
# Debug information for API
|
180
180
|
def debug_info_for_api
|
181
181
|
puts <<~DEBUG_INFO
|
182
182
|
|
@@ -246,7 +246,7 @@ module FakePlugger
|
|
246
246
|
end
|
247
247
|
end
|
248
248
|
|
249
|
-
# Check that it should
|
249
|
+
# Check that it should return with the delivery data.
|
250
250
|
def return_delivery_data?
|
251
251
|
!send_via_smtp? &&
|
252
252
|
@response.is_a?(Hash) &&
|
@@ -262,7 +262,7 @@ module FakePlugger
|
|
262
262
|
@response
|
263
263
|
end
|
264
264
|
|
265
|
-
# Show debug
|
265
|
+
# Show debug information from variables and methods.
|
266
266
|
def show_debug_info
|
267
267
|
send_via_smtp? ? debug_info_for_smtp : debug_info_for_api
|
268
268
|
end
|
@@ -44,7 +44,7 @@ module MailPlugger
|
|
44
44
|
#
|
45
45
|
# Using API:
|
46
46
|
# Send message with the given client if the message parameter is a
|
47
|
-
# Mail::Message object. Before doing that extract
|
47
|
+
# Mail::Message object. Before doing that, extract this information from the
|
48
48
|
# Mail::Message object which was provided in the 'delivery_options'. After
|
49
49
|
# that it generates a hash with these data and sends the message with the
|
50
50
|
# provided client class which has a 'deliver' method.
|
data/lib/mail_plugger/error.rb
CHANGED
@@ -2,24 +2,25 @@
|
|
2
2
|
|
3
3
|
module MailPlugger
|
4
4
|
class Error < StandardError
|
5
|
-
# Specific error class for errors if client is not given or has a wrong
|
5
|
+
# Specific error class for errors if client is not given or has a wrong
|
6
|
+
# type.
|
6
7
|
class WrongApiClient < Error; end
|
7
8
|
|
8
|
-
# Specific error class for errors if delivery options
|
9
|
-
# has a wrong type
|
9
|
+
# Specific error class for errors if delivery options are not given or
|
10
|
+
# has a wrong type.
|
10
11
|
class WrongDeliveryOptions < Error; end
|
11
12
|
|
12
|
-
# Specific error class for errors if delivery settings has a wrong type
|
13
|
+
# Specific error class for errors if delivery settings has a wrong type.
|
13
14
|
class WrongDeliverySettings < Error; end
|
14
15
|
|
15
|
-
# Specific error class for errors if delivery system is not given
|
16
|
+
# Specific error class for errors if delivery system is not given.
|
16
17
|
class WrongDeliverySystem < Error; end
|
17
18
|
|
18
|
-
# Specific error class for errors if parameter is not given
|
19
|
+
# Specific error class for errors if parameter is not given.
|
19
20
|
class WrongParameter < Error; end
|
20
21
|
|
21
|
-
# Specific error class for errors if tries to add
|
22
|
-
# in plug_in block
|
22
|
+
# Specific error class for errors if tries to add undeclared option
|
23
|
+
# in plug_in block.
|
23
24
|
class WrongPlugInOption < Error; end
|
24
25
|
end
|
25
26
|
end
|
@@ -27,9 +27,9 @@ module MailPlugger
|
|
27
27
|
requirement.satisfied_by?(current_version)
|
28
28
|
end
|
29
29
|
|
30
|
-
# Extract 'client'. If it's a hash then it'll return the right
|
31
|
-
# client belongs to the delivery system. If it's not a hash it'll return
|
32
|
-
# the given value. But if the value doesn't a class it'll raise an error.
|
30
|
+
# Extract 'client'. If it's a hash, then it'll return the right
|
31
|
+
# client belongs to the delivery system. If it's not a hash, it'll return
|
32
|
+
# the given value. But if the value doesn't a class, it'll raise an error.
|
33
33
|
#
|
34
34
|
# @return [Class] the defined API class
|
35
35
|
def client
|
@@ -73,22 +73,22 @@ module MailPlugger
|
|
73
73
|
end
|
74
74
|
|
75
75
|
# Tries to set up a default delivery system, if the 'delivery_system'
|
76
|
-
# wasn't defined in the Mail::Message object and we're using
|
76
|
+
# wasn't defined in the Mail::Message object, and we're using
|
77
77
|
# MailPlugger.plug_in then it returns with first key of the stored
|
78
78
|
# 'delivery_systems'.
|
79
|
-
# When we
|
79
|
+
# When we aren't using MailPlugger.plug_in method and 'delivery_options',
|
80
80
|
# 'client' and/or 'delivery_settings' is a hash, then it tries to get the
|
81
81
|
# 'delivery_system' from the hashes.
|
82
|
-
# Otherwise it returns with nil.
|
82
|
+
# Otherwise, it returns with nil.
|
83
83
|
#
|
84
84
|
# @return [Stirng/NilClass] the first key from the extracted keys or nil
|
85
85
|
def default_delivery_system_get
|
86
86
|
extract_keys&.first
|
87
87
|
end
|
88
88
|
|
89
|
-
# Extract 'delivery_options'. If it's a hash then it'll return the right
|
90
|
-
# options belongs to the delivery system. If it's not a hash it'll return
|
91
|
-
# the given value. But if the value doesn't an array it'll raise an error.
|
89
|
+
# Extract 'delivery_options'. If it's a hash, then it'll return the right
|
90
|
+
# options, belongs to the delivery system. If it's not a hash, it'll return
|
91
|
+
# the given value. But if the value doesn't an array, it'll raise an error.
|
92
92
|
#
|
93
93
|
# @return [Array] the options it'll collect from the Mail::Message object
|
94
94
|
def delivery_options
|
@@ -103,7 +103,7 @@ module MailPlugger
|
|
103
103
|
end
|
104
104
|
|
105
105
|
# Extract 'delivery_system' from the Mail::Message object or if it's not
|
106
|
-
# defined then use the default one. If it's still nil and one of the
|
106
|
+
# defined, then use the default one. If it's still nil and one of the
|
107
107
|
# 'delivery_options', 'client' and/or 'delivery_settings' is a hash and
|
108
108
|
# 'delivery_settings' doesn't contain 'delivery_system' then raise error.
|
109
109
|
#
|
@@ -121,8 +121,8 @@ module MailPlugger
|
|
121
121
|
# Check the given 'delivery_options', 'client' and 'delivery_settings' are
|
122
122
|
# hashes and if one of that does then check the 'delivery_system' is valid
|
123
123
|
# or not.
|
124
|
-
# If the given 'delivery_system' is nil or doesn't match with extracted
|
125
|
-
# then it will raise error.
|
124
|
+
# If the given 'delivery_system' is nil or doesn't match with extracted
|
125
|
+
# keys, then it will raise error.
|
126
126
|
def delivery_system_value_check
|
127
127
|
return unless need_delivery_system?
|
128
128
|
|
@@ -138,7 +138,7 @@ module MailPlugger
|
|
138
138
|
end
|
139
139
|
|
140
140
|
# Check that 'delivery_settings' has 'delivery_system' key or not.
|
141
|
-
# If 'delivery_settings' contains 'DELIVERY_SETTINGS_KEYS' then it
|
141
|
+
# If 'delivery_settings' contains 'DELIVERY_SETTINGS_KEYS' then it returns
|
142
142
|
# false, else true.
|
143
143
|
#
|
144
144
|
# @return [Boolean] true/false
|
@@ -163,9 +163,9 @@ module MailPlugger
|
|
163
163
|
end
|
164
164
|
end
|
165
165
|
|
166
|
-
# Return 'delivery_systems' array if it's exist. If not then extract keys
|
166
|
+
# Return 'delivery_systems' array if it's exist. If not, then extract keys
|
167
167
|
# from 'delivery_options', 'client' or 'delivery_settings',
|
168
|
-
# depends on which is a hash. If none of these are hashes then returns nil.
|
168
|
+
# depends on which is a hash. If none of these are hashes, then returns nil.
|
169
169
|
#
|
170
170
|
# @return [Array/NilClass] with the keys or nil
|
171
171
|
def extract_keys
|
@@ -175,7 +175,7 @@ module MailPlugger
|
|
175
175
|
end
|
176
176
|
|
177
177
|
# Extract keys from 'delivery_options', 'client' or 'delivery_settings',
|
178
|
-
# depends on which is a hash. If none of these are hashes then returns nil.
|
178
|
+
# depends on which is a hash. If none of these are hashes, then returns nil.
|
179
179
|
#
|
180
180
|
# @return [Array/NilClass] with the keys from one of the hash or nil
|
181
181
|
def extract_keys_from_other_variables
|
@@ -188,7 +188,7 @@ module MailPlugger
|
|
188
188
|
end&.keys
|
189
189
|
end
|
190
190
|
|
191
|
-
# How to
|
191
|
+
# How to extract the (unparsed) value of the mail message fields.
|
192
192
|
#
|
193
193
|
# @return [String] version dependent method call
|
194
194
|
def mail_field_value
|
@@ -247,9 +247,9 @@ module MailPlugger
|
|
247
247
|
false
|
248
248
|
end
|
249
249
|
|
250
|
-
# Extract 'settings'. If it's a hash then it'll return the right
|
251
|
-
# settings belongs to the delivery system. If 'delivery_settings' is nil
|
252
|
-
# it'll return an empty hash. But if the value doesn't a hash it'll raise
|
250
|
+
# Extract 'settings'. If it's a hash, then it'll return the right
|
251
|
+
# settings, belongs to the delivery system. If 'delivery_settings' is nil,
|
252
|
+
# it'll return an empty hash. But if the value doesn't a hash, it'll raise
|
253
253
|
# an error.
|
254
254
|
#
|
255
255
|
# @return [Hash] settings for Mail delivery_method and/or FakePlugger
|
data/lib/mail_plugger/version.rb
CHANGED
data/lib/mail_plugger.rb
CHANGED
@@ -3,12 +3,12 @@
|
|
3
3
|
require 'mail_plugger/error'
|
4
4
|
require 'mail_plugger/mail_helper'
|
5
5
|
require 'mail_plugger/delivery_method'
|
6
|
-
# If we are using this gem outside of Rails then do not load this code.
|
6
|
+
# If we are using this gem outside of Rails, then do not load this code.
|
7
7
|
require 'mail_plugger/railtie' if defined?(Rails)
|
8
8
|
require 'mail_plugger/version'
|
9
9
|
|
10
10
|
require 'fake_plugger/delivery_method'
|
11
|
-
# If we are using this gem outside of Rails then do not load this code.
|
11
|
+
# If we are using this gem outside of Rails, then do not load this code.
|
12
12
|
require 'fake_plugger/railtie' if defined?(Rails)
|
13
13
|
|
14
14
|
module MailPlugger
|
@@ -104,8 +104,8 @@ module MailPlugger
|
|
104
104
|
end
|
105
105
|
|
106
106
|
# Define 'client', 'delivery_options' and 'delivery_settings' setter
|
107
|
-
# methods. These methods are generating a hash where the key is the
|
108
|
-
# 'delivery_system'. This let us
|
107
|
+
# methods. These methods are generating a hash, where the key is the
|
108
|
+
# 'delivery_system'. This let us set/use more than one STMP/API.
|
109
109
|
%w[client delivery_options delivery_settings].each do |method|
|
110
110
|
define_method "#{method}=" do |value|
|
111
111
|
variable = instance_variable_get("@#{method}")
|
@@ -116,7 +116,7 @@ module MailPlugger
|
|
116
116
|
|
117
117
|
private
|
118
118
|
|
119
|
-
# Check 'delivery_system' is valid or not. If it's not valid then
|
119
|
+
# Check 'delivery_system' is valid or not. If it's not valid, then
|
120
120
|
# it will raise an error.
|
121
121
|
#
|
122
122
|
# @param [String/Symbol] delivery_system the name of the SMTP/API
|
@@ -132,7 +132,7 @@ module MailPlugger
|
|
132
132
|
return if delivery_system.is_a?(String) || delivery_system.is_a?(Symbol)
|
133
133
|
|
134
134
|
raise Error::WrongDeliverySystem, '"delivery_system" does not a ' \
|
135
|
-
|
135
|
+
'String or Symbol'
|
136
136
|
end
|
137
137
|
end
|
138
138
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mail_plugger
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.6.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Norbert Szivós
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-05-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: mail
|
@@ -24,6 +24,20 @@ dependencies:
|
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '2.5'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: net-smtp
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0.3'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0.3'
|
27
41
|
description: Delivery Method to send emails via SMTP(s) and API(s). We can use this
|
28
42
|
Delivery Method with Ruby on Rails ActionMailer or other solutions.
|
29
43
|
email:
|
@@ -54,6 +68,7 @@ metadata:
|
|
54
68
|
changelog_uri: https://github.com/MailToolbox/mail_plugger/blob/main/CHANGELOG.md
|
55
69
|
bug_tracker_uri: https://github.com/MailToolbox/mail_plugger/issues
|
56
70
|
documentation_uri: https://rubydoc.info/gems/mail_plugger
|
71
|
+
rubygems_mfa_required: 'true'
|
57
72
|
post_install_message:
|
58
73
|
rdoc_options: []
|
59
74
|
require_paths:
|
@@ -62,7 +77,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
62
77
|
requirements:
|
63
78
|
- - ">="
|
64
79
|
- !ruby/object:Gem::Version
|
65
|
-
version: 2.
|
80
|
+
version: 2.7.0
|
66
81
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
67
82
|
requirements:
|
68
83
|
- - ">="
|