mailhandler 1.0.32 → 1.0.33
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/mailhandler/receiver.rb +2 -3
- data/lib/mailhandler/receiving/imap.rb +41 -32
- data/lib/mailhandler/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b888851bd9c92766c8abb3399b4bc7115dfd54ff
|
4
|
+
data.tar.gz: 39d2842b2fe5be561a99d6a77bf9c2b99cc8f49f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b285a314daaa40d85d5133888b21c7a2340df5906c24f98a6165b38d2b3525fc666f54020a6e79aa9989719474ab9bfc6688f5aad753f1e18010a2c63183fb2d
|
7
|
+
data.tar.gz: e55151fa11ab16befe97d21e43463bcdb3e356676c98932b2ec810b5a8d0d3bc6602d2582faff96896f50ddc5f7301d00573ce8f8967bfaaba0928ccce5e476d
|
data/lib/mailhandler/receiver.rb
CHANGED
@@ -17,7 +17,7 @@ module MailHandler
|
|
17
17
|
module DEFAULTS
|
18
18
|
|
19
19
|
MAX_SEARCH_DURATION = 240 # maximum time for search to last in [seconds]
|
20
|
-
SEARCH_FREQUENCY =
|
20
|
+
SEARCH_FREQUENCY = 0.5 # how frequently to check for email in inbox [seconds]
|
21
21
|
|
22
22
|
end
|
23
23
|
|
@@ -51,7 +51,6 @@ module MailHandler
|
|
51
51
|
received = checker.find(options)
|
52
52
|
update_search_details
|
53
53
|
notify_observers(search)
|
54
|
-
|
55
54
|
break if received
|
56
55
|
sleep search_frequency
|
57
56
|
|
@@ -63,7 +62,7 @@ module MailHandler
|
|
63
62
|
ensure
|
64
63
|
|
65
64
|
checker.stop
|
66
|
-
|
65
|
+
|
67
66
|
end
|
68
67
|
|
69
68
|
private
|
@@ -17,9 +17,14 @@ module MailHandler
|
|
17
17
|
:authentication,
|
18
18
|
:use_ssl
|
19
19
|
|
20
|
+
# Connection is closed by default after each search.
|
21
|
+
# By setting this flag, closing connection is ignored and you need to close it manually.
|
22
|
+
attr_accessor :manual_connection_manage
|
23
|
+
|
20
24
|
def initialize
|
21
25
|
|
22
26
|
super
|
27
|
+
@manual_connection_manage = false
|
23
28
|
@available_search_options = AVAILABLE_SEARCH_OPTIONS
|
24
29
|
|
25
30
|
end
|
@@ -35,41 +40,64 @@ module MailHandler
|
|
35
40
|
|
36
41
|
def start
|
37
42
|
|
38
|
-
|
39
|
-
|
43
|
+
unless manual_connection_manage
|
44
|
+
init_retriever
|
45
|
+
connect
|
46
|
+
end
|
40
47
|
|
41
48
|
end
|
42
49
|
|
43
50
|
def stop
|
44
51
|
|
45
|
-
|
52
|
+
unless manual_connection_manage
|
53
|
+
disconnect
|
54
|
+
end
|
46
55
|
|
47
56
|
end
|
48
57
|
|
49
|
-
|
58
|
+
def connect
|
50
59
|
|
51
|
-
|
60
|
+
mailer.connect
|
52
61
|
|
53
|
-
|
62
|
+
end
|
63
|
+
|
64
|
+
def disconnect
|
65
|
+
|
66
|
+
mailer.disconnect unless mailer.imap_connection.disconnected?
|
54
67
|
|
55
68
|
end
|
56
69
|
|
57
|
-
|
70
|
+
# delegate retrieval details to Mail library
|
71
|
+
def init_retriever
|
58
72
|
|
59
|
-
|
60
|
-
|
73
|
+
# set imap settings if they are not set
|
74
|
+
unless retriever_set?
|
75
|
+
|
76
|
+
imap_settings = retriever_settings
|
77
|
+
|
78
|
+
Mail.defaults do
|
79
|
+
|
80
|
+
retriever_method :imap,
|
81
|
+
imap_settings
|
82
|
+
|
83
|
+
end
|
84
|
+
|
85
|
+
end
|
61
86
|
|
62
87
|
end
|
63
88
|
|
64
|
-
|
89
|
+
private
|
65
90
|
|
66
|
-
|
91
|
+
def mailer
|
92
|
+
|
93
|
+
@mailer ||= Mail.retriever_method
|
67
94
|
|
68
95
|
end
|
69
96
|
|
70
|
-
def
|
97
|
+
def reconnect
|
71
98
|
|
72
|
-
|
99
|
+
disconnect
|
100
|
+
connect
|
73
101
|
|
74
102
|
end
|
75
103
|
|
@@ -94,25 +122,6 @@ module MailHandler
|
|
94
122
|
|
95
123
|
RETRY_ON_ERROR_COUNT = 3
|
96
124
|
|
97
|
-
# delegate retrieval details to Mail library
|
98
|
-
def init_retriever
|
99
|
-
|
100
|
-
# set imap settings if they are not set
|
101
|
-
unless retriever_set?
|
102
|
-
|
103
|
-
imap_settings = retriever_settings
|
104
|
-
|
105
|
-
Mail.defaults do
|
106
|
-
|
107
|
-
retriever_method :imap,
|
108
|
-
imap_settings
|
109
|
-
|
110
|
-
end
|
111
|
-
|
112
|
-
end
|
113
|
-
|
114
|
-
end
|
115
|
-
|
116
125
|
def retriever_set?
|
117
126
|
|
118
127
|
Mail.retriever_method.settings == retriever_settings
|
data/lib/mailhandler/version.rb
CHANGED
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.
|
4
|
+
version: 1.0.33
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Igor Balos
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2017-05-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: mail
|
@@ -115,7 +115,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
115
115
|
version: 1.9.3
|
116
116
|
requirements: []
|
117
117
|
rubyforge_project:
|
118
|
-
rubygems_version: 2.
|
118
|
+
rubygems_version: 2.6.11
|
119
119
|
signing_key:
|
120
120
|
specification_version: 4
|
121
121
|
summary: Postmark email receiving and sending handler.
|