mailhandler 1.0.59 → 1.0.61

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: 922df060ca41561a56d889b8a68c1f772d49ac30667c8c98a1df11caddb96cfa
4
- data.tar.gz: 8e2b840dbe67e91dd5db768ea6dfe77365d4ecacee1957818ad186f8d936588d
3
+ metadata.gz: de40ee0be87a056910ae5518108c764c7eb9ac8c3966bf493785fffc91e7cb5b
4
+ data.tar.gz: 021c325cb06ded1e127b2eda02ab4aacd01dc39be42b0f2a43b65354d505742f
5
5
  SHA512:
6
- metadata.gz: 263a717a84589e47f673f92209002b8bf3c9f5affc8ac103d36e44e77bfa2000626e9c73b2d4669b0c21a3f568cdc20f186a05f380a97526e4db19f5927dd0a7
7
- data.tar.gz: a86f93fecdfd7985ddb393dc42a132ad14b0ed8fe738d0eb9ec3c5abdd0e6e89e224a87b3beec57acc7616c9656a46c895dce10d0807c951646c5064540e134b
6
+ metadata.gz: ceef3cf4ad8ae793e321999dfe4b4ee7e9e4eb3334baf7de3d98b89990228b64984a553566c66fe5f3eefe981422e776382ab54d4a95e7e7ba7594f33a2020e4
7
+ data.tar.gz: 0ceca108ee81c36e280d24b5580860ab156bfda4c807b7a25addfb9cb2939e45b3b5234c0d4f3ac0fe099699959e1b4e10c22f450b5f6eee63aac573bfadc351
@@ -0,0 +1,43 @@
1
+ version: 2.1
2
+
3
+ workflows:
4
+ ruby-tests:
5
+ jobs:
6
+ - unit-tests:
7
+ name: ruby24
8
+ version: "2.4.6"
9
+ - unit-tests:
10
+ name: ruby25
11
+ version: "2.5.5"
12
+ requires:
13
+ - ruby24
14
+ - unit-tests:
15
+ name: ruby27
16
+ version: "2.7.5"
17
+ requires:
18
+ - ruby25
19
+ - unit-tests:
20
+ name: ruby30
21
+ version: "3.0.0"
22
+ requires:
23
+ - ruby27
24
+
25
+ jobs:
26
+ unit-tests:
27
+ parameters:
28
+ version:
29
+ type: string
30
+ docker:
31
+ - image: cimg/ruby:<< parameters.version >>
32
+ steps:
33
+ - checkout
34
+ - run:
35
+ name: Versions
36
+ command: |
37
+ echo "ruby: $(ruby --version)"
38
+ - run:
39
+ name: Install dependencies
40
+ command: bundle install
41
+ - run:
42
+ name: Run tests
43
+ command: bundle exec rspec
data/LICENSE CHANGED
@@ -1,7 +1,7 @@
1
1
  MailHandler
2
2
 
3
- https://github.com/wildbit/mailhandler
4
- Copyright (c) 2016 Balos Igor
3
+ https://github.com/ActiveCampaign/mailhandler
4
+ Copyright (c) 2022 Balos Igor
5
5
 
6
6
  The MIT License
7
7
 
@@ -3,8 +3,8 @@ module Mail
3
3
  class SMTP
4
4
  def deliver_raw!(raw_source_email, smtp_from, smtp_to)
5
5
  response = start_smtp_session do |smtp|
6
- Mail::SMTPConnection.new(:connection => smtp, :return_response => true).
7
- deliver_raw!(raw_source_email, smtp_from, smtp_to)
6
+ Mail::SMTPConnection.new(connection: smtp, return_response: true)
7
+ .deliver_raw!(raw_source_email, smtp_from, smtp_to)
8
8
  end
9
9
 
10
10
  settings[:return_response] ? response : self
@@ -19,4 +19,4 @@ module Mail
19
19
  settings[:return_response] ? response : self
20
20
  end
21
21
  end
22
- end
22
+ end
@@ -94,7 +94,7 @@ module MailHandler
94
94
  end
95
95
 
96
96
  def validate_used_options(options)
97
- error_message = "#{(options.keys - available_search_options)} - Incorrect search option values,"\
97
+ error_message = "#{options.keys - available_search_options} - Incorrect search option values,"\
98
98
  " options are #{available_search_options}."
99
99
  raise MailHandler::Error, error_message unless (options.keys - available_search_options).empty?
100
100
  end
@@ -1,11 +1,11 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require 'mail'
4
- require_relative 'base.rb'
4
+ require_relative 'base'
5
5
  require_relative '../errors'
6
- require_relative 'filelist/base.rb'
7
- require_relative 'filelist/filter/base.rb'
8
- require_relative 'filelist/filter/email.rb'
6
+ require_relative 'filelist/base'
7
+ require_relative 'filelist/filter/base'
8
+ require_relative 'filelist/filter/email'
9
9
 
10
10
  module MailHandler
11
11
  module Receiving
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require 'mail'
4
- require_relative 'base.rb'
4
+ require_relative 'base'
5
5
  require_relative '../errors'
6
6
 
7
7
  module MailHandler
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require 'postmark'
4
- require_relative 'base.rb'
4
+ require_relative 'base'
5
5
 
6
6
  module MailHandler
7
7
  module Sending
@@ -14,10 +14,10 @@ module MailHandler
14
14
  :http_read_timeout
15
15
 
16
16
  def initialize(api_token = nil)
17
- @type = :postmark_api
17
+ super(:postmark_api)
18
18
  @host = DEFAULTS[:host]
19
19
  @api_token = api_token
20
- @use_ssl = false
20
+ @use_ssl = true
21
21
 
22
22
  @http_open_timeout = DEFAULTS[:open_timeout]
23
23
  @http_read_timeout = DEFAULTS[:read_timeout]
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require_relative 'api.rb'
3
+ require_relative 'api'
4
4
  require_relative '../errors'
5
5
 
6
6
  module MailHandler
@@ -9,6 +9,10 @@ module MailHandler
9
9
  class Sender
10
10
  attr_reader :type
11
11
 
12
+ def initialize(type)
13
+ @type = type
14
+ end
15
+
12
16
  def send(_email)
13
17
  raise MailHandler::InterfaceError, 'Send interface not implemented.'
14
18
  end
@@ -1,29 +1,20 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require_relative 'base'
4
- require_relative "../extensions/mail/smtp"
4
+ require_relative '../extensions/mail/smtp'
5
5
 
6
6
  module MailHandler
7
7
  module Sending
8
8
  # class which describes methods to send and receive emails
9
9
  class SMTPSender < Sender
10
- attr_accessor :address,
11
- :port,
12
- :domain,
13
- :username,
14
- :password,
15
- :authentication,
16
- :use_ssl,
17
- :openssl_verify_mode
18
-
19
- attr_accessor :open_timeout,
20
- :read_timeout,
21
- :save_response
10
+ attr_accessor :address, :port, :domain, :username, :password, :authentication, :use_ssl, :openssl_verify_mode,
11
+ :open_timeout, :read_timeout, :save_response
22
12
 
23
13
  def initialize
24
- @type = :smtp
14
+ super :smtp
15
+
25
16
  @authentication = 'plain'
26
- @use_ssl = false
17
+ @use_ssl = true
27
18
  @save_response = true
28
19
 
29
20
  @open_timeout = 60
@@ -42,6 +33,14 @@ module MailHandler
42
33
  save_response ? response : nil
43
34
  end
44
35
 
36
+ def can_authenticate?
37
+ method_name = 'start_smtp_session' # Mail::SMTP private method
38
+ configure_sending(Mail.new).delivery_method.send(method_name)
39
+ true
40
+ rescue Net::SMTPAuthenticationError
41
+ false
42
+ end
43
+
45
44
  def valid_response?(response)
46
45
  response.string.to_s.downcase.include?('250 2.0.0 ok')
47
46
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module MailHandler
4
- VERSION = '1.0.59'
4
+ VERSION = '1.0.61'
5
5
  end
data/mailhandler.gemspec CHANGED
@@ -11,14 +11,14 @@ Gem::Specification.new do |s|
11
11
  s.license = 'MIT'
12
12
 
13
13
  s.authors = ['Igor Balos']
14
- s.email = ['ibalosh@gmail.com', 'igor@wildbit.com']
14
+ s.email = ['ibalosh@gmail.com', 'ibalos@activecampaign.com']
15
15
 
16
16
  s.summary = 'Postmark email receiving and sending handler.'
17
17
  s.description = 'Use this gem to send emails through SMTP and Postmark API and check if email arrived.'
18
18
 
19
19
  s.files = `git ls-files`.split($INPUT_RECORD_SEPARATOR)
20
20
  s.test_files = `git ls-files -- {spec}/*`.split("\n")
21
- s.homepage = 'https://github.com/wildbit/mailhandler'
21
+ s.homepage = 'https://github.com/ActiveCampaign/mailhandler'
22
22
  s.require_paths = ['lib']
23
23
 
24
24
  s.post_install_message = '
data/postmark.png ADDED
Binary file
data/readme.md CHANGED
@@ -1,10 +1,12 @@
1
- <img src="http://assets.wildbit.com/postmark/misc/mailhandler-logo@2x.png" alt="MailHandler Logo" title="MailHandler" width="148" height="148" align="right">
1
+ <a href="https://postmarkapp.com">
2
+ <img src="postmark.png" alt="Postmark Logo" title="Postmark" width="120" height="120" align="right">
3
+ </a>
2
4
 
3
5
  # MailHandler Gem
4
6
 
5
- [![Build Status](https://travis-ci.org/wildbit/mailhandler.svg?branch=master)](https://travis-ci.org/wildbit/mailhandler)
7
+ [![Build Status](https://circleci.com/gh/ActiveCampaign/mailhandler.svg?style=shield)](https://circleci.com/gh/ActiveCampaign/mailhandler)
6
8
 
7
- MailHandler is a simple wrapper on top of [Mail gem](https://github.com/mikel/mail) and [Postmark gem](https://github.com/wildbit/postmark-gem) libraries. It allows you to send and retrieve emails and at the same time get details on how long these operations took.
9
+ MailHandler is a simple wrapper on top of [Mail gem](https://github.com/mikel/mail) and [Postmark gem](https://github.com/ActiveCampaign/postmark-gem) libraries. It allows you to send and retrieve emails and at the same time get details on how long these operations took.
8
10
  Main purpose of the gem is easier email sending/delivery testing with notification option if sending or retrieving email is taking too long.
9
11
 
10
12
  The library supports sending email by standard SMTP protocol and by Postmark API. More importantly it also allows checking email delivery by IMAP protocol, or by folder if you have a local mailbox.
@@ -195,7 +197,7 @@ Once email sending is finished, you can check sending result by looking at: `ema
195
197
 
196
198
  ### License
197
199
 
198
- MailHandler Library is licensed under the [MIT](http://www.opensource.org/licenses/mit-license.php "Read more about the MIT license form") license. Refere to the [LICENSE](https://github.com/wildbit/mailhandler/blob/master/LICENSE) file for more information.
200
+ MailHandler Library is licensed under the [MIT](http://www.opensource.org/licenses/mit-license.php "Read more about the MIT license form") license. Refere to the [LICENSE](https://github.com/ActiveCampaign/mailhandler/blob/master/LICENSE) file for more information.
199
201
 
200
202
 
201
203
 
@@ -8,7 +8,7 @@ describe MailHandler::Receiver do
8
8
 
9
9
  let(:default_search_option) { { by_subject: 'test' } }
10
10
  let(:receiving_duration) { 5 }
11
- let(:found_email) { Mail.new { subject 'test email' } }
11
+ let(:found_email) { Mail.new { subject :"test email" } }
12
12
  let(:checker) do
13
13
  checker = instance_double('Checker')
14
14
 
@@ -72,17 +72,17 @@ describe MailHandler::Receiver do
72
72
  checker
73
73
  end
74
74
 
75
- it "raise error" do
75
+ it 'raise error' do
76
76
  receiver.max_search_duration = 3
77
- receiver.validate_result=true
78
- expect { receiver.find_email(default_search_option) }.
79
- to raise_error(MailHandler::SearchEmailError,
80
- "Email searched by {:by_subject=>\"test\"} not found for 3 seconds.")
77
+ receiver.validate_result = true
78
+ expect { receiver.find_email(default_search_option) }
79
+ .to raise_error(MailHandler::SearchEmailError,
80
+ 'Email searched by {:by_subject=>"test"} not found for 3 seconds.')
81
81
  end
82
82
 
83
- it "do not raise error" do
83
+ it 'do not raise error' do
84
84
  receiver.max_search_duration = 3
85
- receiver.validate_result=false
85
+ receiver.validate_result = false
86
86
  expect(receiver.find_email(default_search_option)).to be false
87
87
  end
88
88
  end
@@ -20,7 +20,7 @@ describe MailHandler::Sender do
20
20
  Mail.new do
21
21
  from 'sheldon@bigbangtheory.com'
22
22
  to 'lenard@bigbangtheory.com'
23
- subject 'Hello!'
23
+ subject :Hello!
24
24
  body 'Hello Sheldon!'
25
25
  end
26
26
  end
@@ -13,7 +13,7 @@ describe MailHandler::Sending::PostmarkBatchAPISender do
13
13
  aggregate_failures 'init details' do
14
14
  expect(sender.api_token).to eq api_token
15
15
  expect(sender.type).to eq :postmark_api
16
- expect(sender.use_ssl).to be false
16
+ expect(sender.use_ssl).to be true
17
17
  expect(sender.host).to eq 'api.postmarkapp.com'
18
18
  end
19
19
  end
@@ -13,7 +13,7 @@ describe MailHandler::Sending::PostmarkAPISender do
13
13
  aggregate_failures 'init details' do
14
14
  expect(sender.api_token).to eq api_token
15
15
  expect(sender.type).to eq :postmark_api
16
- expect(sender.use_ssl).to be false
16
+ expect(sender.use_ssl).to be true
17
17
  expect(sender.host).to eq 'api.postmarkapp.com'
18
18
  end
19
19
  end
@@ -27,12 +27,22 @@ describe MailHandler::Sending::SMTPSender do
27
27
  end
28
28
  end
29
29
 
30
+ it 'can_authenticated' do
31
+ sender = smtp_sender.new
32
+ expect { sender.can_authenticate? }.to raise_error Errno::ECONNREFUSED
33
+ end
34
+
35
+ it 'type' do
36
+ sender = smtp_sender.new
37
+ expect(sender.type).to eq :smtp
38
+ end
39
+
30
40
  it 'save response' do
31
41
  expect(smtp_sender.new.save_response).to be true
32
42
  end
33
43
 
34
44
  it 'use ssl' do
35
- expect(smtp_sender.new.use_ssl).to be false
45
+ expect(smtp_sender.new.use_ssl).to be true
36
46
  end
37
47
 
38
48
  it 'authentication' do
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mailhandler
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.59
4
+ version: 1.0.61
5
5
  platform: ruby
6
6
  authors:
7
7
  - Igor Balos
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-04-19 00:00:00.000000000 Z
11
+ date: 2022-12-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: mail
@@ -42,14 +42,14 @@ description: Use this gem to send emails through SMTP and Postmark API and check
42
42
  email arrived.
43
43
  email:
44
44
  - ibalosh@gmail.com
45
- - igor@wildbit.com
45
+ - ibalos@activecampaign.com
46
46
  executables: []
47
47
  extensions: []
48
48
  extra_rdoc_files: []
49
49
  files:
50
+ - ".circleci/config.yml"
50
51
  - ".gitignore"
51
52
  - ".rubocop.yml"
52
- - ".travis.yml"
53
53
  - Gemfile
54
54
  - LICENSE
55
55
  - Rakefile
@@ -76,6 +76,7 @@ files:
76
76
  - lib/mailhandler/sending/smtp.rb
77
77
  - lib/mailhandler/version.rb
78
78
  - mailhandler.gemspec
79
+ - postmark.png
79
80
  - readme.md
80
81
  - spec/data/email-uni1.txt
81
82
  - spec/data/email-uni2.txt
@@ -94,7 +95,7 @@ files:
94
95
  - spec/unit/mailhandler/sending/sender_api_spec.rb
95
96
  - spec/unit/mailhandler/sending/sender_smtp_spec.rb
96
97
  - spec/unit/mailhandler_spec.rb
97
- homepage: https://github.com/wildbit/mailhandler
98
+ homepage: https://github.com/ActiveCampaign/mailhandler
98
99
  licenses:
99
100
  - MIT
100
101
  metadata: {}
data/.travis.yml DELETED
@@ -1,7 +0,0 @@
1
- language: ruby
2
- rvm:
3
- - 2.0.0
4
- - 2.1.6
5
- - 2.2.2
6
-
7
- script: bundle exec rake