mailhandler 1.0.26 → 1.0.27
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/mailhandler/receiving/imap.rb +3 -3
- data/lib/mailhandler/receiving/mail.rb +17 -17
- data/lib/mailhandler/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 312566ee726f5b9dfebce785b387733856e1ce6b
|
4
|
+
data.tar.gz: 808d6790c07347ba88607893870c83817c968369
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 43055df6d4ffa6bfb05b02cbd362dfa01455bb6c466f17b571a9520b9cd4de0f34a7232eeab3d930dd32848f5d46bf89ef05a8e0a59b5a9e9ab6abcdb6bb1085
|
7
|
+
data.tar.gz: 74ee5fe56db299d830b3e1355ba1a64ccfa43d9967972b54f4ec5d9141e12a12283646188a1e43de333aa11d3bb58feb78507c889df47cf6cb7cb83770d1bdf0
|
@@ -140,7 +140,7 @@ module MailHandler
|
|
140
140
|
|
141
141
|
def imap_search(retry_count, options)
|
142
142
|
|
143
|
-
result = mailer.
|
143
|
+
result = mailer.find_emails(:what => :last, :count => search_options[:count], :order => :desc, :keys => imap_filter_keys(options), :delete_after_find => options[:archive])
|
144
144
|
(result.kind_of? Array)? result : [result]
|
145
145
|
|
146
146
|
# Silently ignore IMAP search errors, [RETRY_ON_ERROR_COUNT] times
|
@@ -182,11 +182,11 @@ module MailHandler
|
|
182
182
|
|
183
183
|
when :since
|
184
184
|
|
185
|
-
keys << 'SINCE' << Net::IMAP.
|
185
|
+
keys << 'SINCE' << Net::IMAP.format_date(options[:since])
|
186
186
|
|
187
187
|
when :before
|
188
188
|
|
189
|
-
keys << 'BEFORE' << Net::IMAP.
|
189
|
+
keys << 'BEFORE' << Net::IMAP.format_date(options[:before])
|
190
190
|
|
191
191
|
else
|
192
192
|
|
@@ -2,13 +2,13 @@ module Mail
|
|
2
2
|
|
3
3
|
class IMAP
|
4
4
|
|
5
|
-
attr_accessor :
|
5
|
+
attr_accessor :imap_connection
|
6
6
|
|
7
|
-
def
|
7
|
+
def find_emails(options={}, &block)
|
8
8
|
|
9
9
|
options = validate_options(options)
|
10
|
-
options[:read_only] ?
|
11
|
-
uids =
|
10
|
+
options[:read_only] ? imap_connection.examine(options[:mailbox]) : imap_connection.select(options[:mailbox])
|
11
|
+
uids = imap_connection.uid_search(options[:keys])
|
12
12
|
|
13
13
|
uids.reverse! if options[:what].to_sym == :last
|
14
14
|
uids = uids.first(options[:count]) if options[:count].is_a?(Integer)
|
@@ -20,22 +20,22 @@ module Mail
|
|
20
20
|
uids.each do |uid|
|
21
21
|
|
22
22
|
uid = options[:uid].to_i unless options[:uid].nil?
|
23
|
-
fetchdata =
|
23
|
+
fetchdata = imap_connection.uid_fetch(uid, ['RFC822'])[0]
|
24
24
|
new_message = Mail.new(fetchdata.attr['RFC822'])
|
25
25
|
new_message.mark_for_delete = true if options[:delete_after_find]
|
26
26
|
|
27
27
|
if block.arity == 3
|
28
|
-
yield new_message,
|
28
|
+
yield new_message, imap_connection, uid
|
29
29
|
else
|
30
30
|
yield new_message
|
31
31
|
end
|
32
32
|
|
33
|
-
|
33
|
+
imap_connection.uid_store(uid, "+FLAGS", [Net::IMAP::DELETED]) if options[:delete_after_find] && new_message.is_marked_for_delete?
|
34
34
|
break unless options[:uid].nil?
|
35
35
|
|
36
36
|
end
|
37
37
|
|
38
|
-
|
38
|
+
imap_connection.expunge if options[:delete_after_find]
|
39
39
|
|
40
40
|
else
|
41
41
|
|
@@ -44,14 +44,14 @@ module Mail
|
|
44
44
|
uids.each do |uid|
|
45
45
|
|
46
46
|
uid = options[:uid].to_i unless options[:uid].nil?
|
47
|
-
fetchdata =
|
47
|
+
fetchdata = imap_connection.uid_fetch(uid, ['RFC822'])[0]
|
48
48
|
emails << Mail.new(fetchdata.attr['RFC822'])
|
49
|
-
|
49
|
+
imap_connection.uid_store(uid, "+FLAGS", [Net::IMAP::DELETED]) if options[:delete_after_find]
|
50
50
|
break unless options[:uid].nil?
|
51
51
|
|
52
52
|
end
|
53
53
|
|
54
|
-
|
54
|
+
imap_connection.expunge if options[:delete_after_find]
|
55
55
|
emails.size == 1 && options[:count] == 1 ? emails.first : emails
|
56
56
|
|
57
57
|
end
|
@@ -61,23 +61,23 @@ module Mail
|
|
61
61
|
# Start an IMAP session
|
62
62
|
def connect(config=Mail::Configuration.instance)
|
63
63
|
|
64
|
-
@
|
64
|
+
@imap_connection = Net::IMAP.new(settings[:address], settings[:port], settings[:enable_ssl], nil, false)
|
65
65
|
|
66
66
|
if settings[:authentication].nil?
|
67
|
-
|
67
|
+
imap_connection.login(settings[:user_name], settings[:password])
|
68
68
|
else
|
69
69
|
# Note that Net::IMAP#authenticate('LOGIN', ...) is not equal with Net::IMAP#login(...)!
|
70
|
-
# (see also http://www.ensta.fr/~diam/ruby/online/ruby-doc-stdlib/libdoc/net/
|
71
|
-
|
70
|
+
# (see also http://www.ensta.fr/~diam/ruby/online/ruby-doc-stdlib/libdoc/net/imap_connection/rdoc/classes/Net/IMAP.html#M000718)
|
71
|
+
imap_connection.authenticate(settings[:authentication], settings[:user_name], settings[:password])
|
72
72
|
end
|
73
73
|
|
74
74
|
end
|
75
75
|
|
76
76
|
def disconnect
|
77
77
|
|
78
|
-
if defined?(
|
78
|
+
if defined?(imap_connection) && imap_connection && !imap_connection.disconnected?
|
79
79
|
|
80
|
-
|
80
|
+
imap_connection.disconnect
|
81
81
|
|
82
82
|
end
|
83
83
|
|
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.27
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Igor Balos
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-02-
|
11
|
+
date: 2016-02-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: mail
|