mailhandler 1.0.5 → 1.0.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/mailhandler/receiving/imap.rb +46 -17
- data/lib/mailhandler/version.rb +1 -1
- data/readme.md +9 -11
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ba85d85b84b4c2e817d68569e19c27cbf69e04d5
|
4
|
+
data.tar.gz: d4f67dfcf82e2c85c085d3654902352469f4f5be
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6838dbf01a6b48e13ccd4e0397e4c236ee9757691c43e102662668bb3a41f03fbfb2f88a3b36f2f3eeb492abce5e4d91a9a8d86a0a89d70db06fb5b4908eae36
|
7
|
+
data.tar.gz: a8909cb9a470f336b5cf17d5e3fa2cb55cdbb9fb0efd3fc18fa6e2e92c8b8d28369828459aeea75e2766d03aa16e480b5ed03ad0e77f2d7b490fd3123c77a803
|
@@ -8,6 +8,13 @@ module MailHandler
|
|
8
8
|
|
9
9
|
class IMAPChecker < Checker
|
10
10
|
|
11
|
+
attr_accessor :address,
|
12
|
+
:port,
|
13
|
+
:username,
|
14
|
+
:password,
|
15
|
+
:authentication,
|
16
|
+
:use_ssl
|
17
|
+
|
11
18
|
AVAILABLE_SEARCH_OPTIONS = [
|
12
19
|
|
13
20
|
:by_subject,
|
@@ -22,27 +29,11 @@ module MailHandler
|
|
22
29
|
|
23
30
|
end
|
24
31
|
|
25
|
-
# delegate retrieval details to Mail library
|
26
|
-
def details(address, port, username, password, use_ssl, authentication = nil)
|
27
|
-
|
28
|
-
Mail.defaults do
|
29
|
-
|
30
|
-
retriever_method :imap,
|
31
|
-
:address => address,
|
32
|
-
:port => port,
|
33
|
-
:user_name => username,
|
34
|
-
:password => password,
|
35
|
-
:authentication => authentication,
|
36
|
-
:enable_ssl => use_ssl
|
37
|
-
|
38
|
-
end
|
39
|
-
|
40
|
-
end
|
41
|
-
|
42
32
|
def find(options)
|
43
33
|
|
44
34
|
verify_and_set_search_options(options)
|
45
35
|
validate_options(options)
|
36
|
+
init_retriever
|
46
37
|
emails = find_emails(search_options)
|
47
38
|
|
48
39
|
unless emails.empty?
|
@@ -61,6 +52,44 @@ module MailHandler
|
|
61
52
|
|
62
53
|
private
|
63
54
|
|
55
|
+
# delegate retrieval details to Mail library
|
56
|
+
def init_retriever
|
57
|
+
|
58
|
+
# set imap settings if they are not set
|
59
|
+
unless retriever_set?
|
60
|
+
|
61
|
+
imap_settings = retriever_settings
|
62
|
+
|
63
|
+
Mail.defaults do
|
64
|
+
|
65
|
+
retriever_method :imap,
|
66
|
+
imap_settings
|
67
|
+
|
68
|
+
end
|
69
|
+
|
70
|
+
end
|
71
|
+
|
72
|
+
end
|
73
|
+
|
74
|
+
def retriever_set?
|
75
|
+
|
76
|
+
Mail.retriever_method.settings == retriever_settings
|
77
|
+
|
78
|
+
end
|
79
|
+
|
80
|
+
def retriever_settings
|
81
|
+
|
82
|
+
{
|
83
|
+
:address => address,
|
84
|
+
:port => port,
|
85
|
+
:user_name => username,
|
86
|
+
:password => password,
|
87
|
+
:authentication => authentication,
|
88
|
+
:enable_ssl => use_ssl
|
89
|
+
}
|
90
|
+
|
91
|
+
end
|
92
|
+
|
64
93
|
def find_emails(options)
|
65
94
|
|
66
95
|
if options[:archive]
|
data/lib/mailhandler/version.rb
CHANGED
data/readme.md
CHANGED
@@ -29,7 +29,7 @@ Checking emails locally option can be used when you have emails stored in certai
|
|
29
29
|
They can be the same if you don't plan to archive checked files.
|
30
30
|
|
31
31
|
``` ruby
|
32
|
-
email_receiver = MailHandler
|
32
|
+
email_receiver = MailHandler.receiver(:folder) do |checker|
|
33
33
|
checker.inbox_folder = folder_of_your_inbox
|
34
34
|
checker.archive_folder = folder_of_your_inbox_archive_folder
|
35
35
|
end
|
@@ -40,14 +40,12 @@ end
|
|
40
40
|
If you plan to check for an email in your inbox which support IMAP, you can use mailhandler with provided IMAP settings.
|
41
41
|
|
42
42
|
``` ruby
|
43
|
-
email_receiver = MailHandler
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
use_ssl
|
50
|
-
)
|
43
|
+
email_receiver = MailHandler.receiver(:imap) do |checker|
|
44
|
+
checker.address = 'imap.googlemail.com'
|
45
|
+
checker.port = 993
|
46
|
+
checker.username = 'username'
|
47
|
+
checker.password = 'password'
|
48
|
+
checker.use_ssl = true
|
51
49
|
end
|
52
50
|
```
|
53
51
|
Email receiving handler will be referenced below as `email_receiver`
|
@@ -114,7 +112,7 @@ To send email you can use SMTP protocol or Postmark.
|
|
114
112
|
To send email with Postmark, you need to choose type of sending, api token options.
|
115
113
|
|
116
114
|
``` ruby
|
117
|
-
email_sender = MailHandler
|
115
|
+
email_sender = MailHandler.sender(type) do |dispatcher|
|
118
116
|
dispatcher.api_token = api_token
|
119
117
|
end
|
120
118
|
```
|
@@ -127,7 +125,7 @@ end
|
|
127
125
|
To send email with SMTP you need to configure standard SMTP settings.
|
128
126
|
|
129
127
|
``` ruby
|
130
|
-
email_sender = MailHandler
|
128
|
+
email_sender = MailHandler.sender(:smtp) do |dispatcher|
|
131
129
|
dispatcher.address = address
|
132
130
|
dispatcher.port = port
|
133
131
|
dispatcher.domain = domain
|