mailhandler 1.0.24 → 1.0.25
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 +2 -2
- data/lib/mailhandler/receiving/mail.rb +44 -37
- 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: 923924f2168d404cb5fd28d97b77d19276e41fe7
|
4
|
+
data.tar.gz: 31843295da603ab56eccedafefac33fdc5584de6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 79e0f23fd3d186e623909cea7e601c1975ccfa157eb5833bc87106dae474b52ac0fd4c9fcce76ceb113df0158585e47fbff2f977261c629fbba9b2dbd24ca3fe
|
7
|
+
data.tar.gz: 47ccdcadd144b7b4b68d2e3c5e400c2ff1acec00760e1fb713003a68234290c2d9cf3d45a4859f476c66c79bd62546ce809e8cdbfc1e5d1d941654e48598d736
|
@@ -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_datetime(options[:since])
|
186
186
|
|
187
187
|
when :before
|
188
188
|
|
189
|
-
keys << 'BEFORE' << Net::IMAP.
|
189
|
+
keys << 'BEFORE' << Net::IMAP.format_datetime(options[:before])
|
190
190
|
|
191
191
|
else
|
192
192
|
|
@@ -7,41 +7,48 @@ module Mail
|
|
7
7
|
def find(options={}, &block)
|
8
8
|
|
9
9
|
options = validate_options(options)
|
10
|
-
|
11
10
|
options[:read_only] ? imap.examine(options[:mailbox]) : imap.select(options[:mailbox])
|
12
|
-
|
13
11
|
uids = imap.uid_search(options[:keys])
|
14
|
-
uids.reverse! if options[:what].to_sym == :last
|
15
|
-
uids = uids.first(options[:count]) if options[:count].is_a?(Integer)
|
16
|
-
uids.reverse! if (options[:what].to_sym == :last && options[:order].to_sym == :asc) ||
|
17
|
-
(options[:what].to_sym != :last && options[:order].to_sym == :desc)
|
18
|
-
|
19
|
-
|
20
|
-
if block_given?
|
21
|
-
|
22
|
-
uids.each do |uid|
|
23
|
-
uid = options[:uid].to_i unless options[:uid].nil?
|
24
|
-
fetchdata = imap.uid_fetch(uid, ['RFC822'])[0]
|
25
|
-
new_message = Mail.new(fetchdata.attr['RFC822'])
|
26
|
-
new_message.mark_for_delete = true if options[:delete_after_find]
|
27
|
-
if block.arity == 3
|
28
|
-
yield new_message, imap, uid
|
29
|
-
else
|
30
|
-
yield new_message
|
31
|
-
end
|
32
|
-
imap.uid_store(uid, "+FLAGS", [Net::IMAP::DELETED]) if options[:delete_after_find] && new_message.is_marked_for_delete?
|
33
|
-
break unless options[:uid].nil?
|
34
|
-
end
|
35
12
|
|
36
|
-
|
13
|
+
if uids.nil? || uids.empty?
|
14
|
+
|
15
|
+
[]
|
37
16
|
|
38
17
|
else
|
39
18
|
|
40
|
-
|
19
|
+
uids.reverse! if options[:what].to_sym == :last
|
20
|
+
uids = uids.first(options[:count]) if options[:count].is_a?(Integer)
|
21
|
+
uids.reverse! if (options[:what].to_sym == :last && options[:order].to_sym == :asc) ||
|
22
|
+
(options[:what].to_sym != :last && options[:order].to_sym == :desc)
|
23
|
+
|
24
|
+
if block_given?
|
25
|
+
|
26
|
+
uids.each do |uid|
|
27
|
+
|
28
|
+
uid = options[:uid].to_i unless options[:uid].nil?
|
29
|
+
fetchdata = imap.uid_fetch(uid, ['RFC822'])[0]
|
30
|
+
new_message = Mail.new(fetchdata.attr['RFC822'])
|
31
|
+
new_message.mark_for_delete = true if options[:delete_after_find]
|
32
|
+
|
33
|
+
if block.arity == 3
|
34
|
+
yield new_message, imap, uid
|
35
|
+
else
|
36
|
+
yield new_message
|
37
|
+
end
|
38
|
+
|
39
|
+
imap.uid_store(uid, "+FLAGS", [Net::IMAP::DELETED]) if options[:delete_after_find] && new_message.is_marked_for_delete?
|
40
|
+
break unless options[:uid].nil?
|
41
|
+
|
42
|
+
end
|
41
43
|
|
42
|
-
|
44
|
+
imap.expunge if options[:delete_after_find]
|
45
|
+
|
46
|
+
else
|
47
|
+
|
48
|
+
emails = []
|
43
49
|
|
44
50
|
uids.each do |uid|
|
51
|
+
|
45
52
|
uid = options[:uid].to_i unless options[:uid].nil?
|
46
53
|
fetchdata = imap.uid_fetch(uid, ['RFC822'])[0]
|
47
54
|
emails << Mail.new(fetchdata.attr['RFC822'])
|
@@ -50,10 +57,10 @@ module Mail
|
|
50
57
|
|
51
58
|
end
|
52
59
|
|
53
|
-
|
60
|
+
imap.expunge if options[:delete_after_find]
|
61
|
+
emails.size == 1 && options[:count] == 1 ? emails.first : emails
|
54
62
|
|
55
|
-
|
56
|
-
emails.size == 1 && options[:count] == 1 ? emails.first : emails
|
63
|
+
end
|
57
64
|
|
58
65
|
end
|
59
66
|
|
@@ -62,15 +69,15 @@ module Mail
|
|
62
69
|
# Start an IMAP session
|
63
70
|
def connect(config=Mail::Configuration.instance)
|
64
71
|
|
65
|
-
|
72
|
+
@imap = Net::IMAP.new(settings[:address], settings[:port], settings[:enable_ssl], nil, false)
|
66
73
|
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
+
if settings[:authentication].nil?
|
75
|
+
imap.login(settings[:user_name], settings[:password])
|
76
|
+
else
|
77
|
+
# Note that Net::IMAP#authenticate('LOGIN', ...) is not equal with Net::IMAP#login(...)!
|
78
|
+
# (see also http://www.ensta.fr/~diam/ruby/online/ruby-doc-stdlib/libdoc/net/imap/rdoc/classes/Net/IMAP.html#M000718)
|
79
|
+
imap.authenticate(settings[:authentication], settings[:user_name], settings[:password])
|
80
|
+
end
|
74
81
|
|
75
82
|
end
|
76
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.25
|
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-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: mail
|