mailman 0.7.2 → 0.7.3
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/CHANGELOG.md +12 -1
- data/README.md +10 -3
- data/USER_GUIDE.md +11 -4
- data/lib/mailman/application.rb +11 -2
- data/lib/mailman/receiver/imap.rb +27 -3
- data/lib/mailman/receiver/pop3.rb +18 -5
- data/lib/mailman/version.rb +1 -1
- metadata +5 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 95cd28c23630aa811c3a0f9299730e745bc29a8a
|
4
|
+
data.tar.gz: 52e2f0d09f4452e08a16d5a51b9f7d85b45ba93b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: dc09cb996cc8418a81a15d02c9585807256d62c8d0ade276930005689bbab99e570d42c0fa45fb19b50e2b4c03b2bea8fe202c9347262f207456ff06495e56de
|
7
|
+
data.tar.gz: 35aa8a40870ffa6439cda844fc47a9269a5650411ea4ce0223d867f5c027f66818a2447782bed53e512860c85bd84735a1f5cdeeb8f637732960d83b0aaea09e
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,14 @@
|
|
1
|
+
## 0.7.3 (March 17, 2015)
|
2
|
+
Features
|
3
|
+
starttls for imap
|
4
|
+
allow passing options to openssl for pop3/imap
|
5
|
+
|
6
|
+
Security fixes
|
7
|
+
Enable certificate validation for pop3
|
8
|
+
|
9
|
+
Bugfixes
|
10
|
+
added retry logic to handle connection errors gracefully
|
11
|
+
|
1
12
|
## 0.7.2 (June 9, 2014)
|
2
13
|
|
3
14
|
Bugfixes
|
@@ -26,7 +37,7 @@ Features
|
|
26
37
|
|
27
38
|
Features
|
28
39
|
|
29
|
-
- IMAP: Mark messages as seen instead of deleting them (see [5b6aef0](https://github.com/
|
40
|
+
- IMAP: Mark messages as seen instead of deleting them (see [5b6aef0](https://github.com/mailman/mailman/commit/5b6aef0163f0f28c790abf3083cbda7cbc9cc13f) for details on how revert to the previous behaviour)
|
30
41
|
|
31
42
|
Bugfixes
|
32
43
|
|
data/README.md
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# Mailman [](https://secure.travis-ci.org/mailman/mailman)
|
2
2
|
|
3
3
|
Mailman is an incoming mail processing microframework (with POP3 and Maildir
|
4
4
|
support), that works with Rails "out of the box".
|
@@ -12,7 +12,7 @@ Mailman::Application.run do
|
|
12
12
|
end
|
13
13
|
```
|
14
14
|
|
15
|
-
See the [User Guide](https://github.com/
|
15
|
+
See the [User Guide](https://github.com/mailman/mailman/blob/master/USER_GUIDE.md) for more information.
|
16
16
|
|
17
17
|
**If you'd like to maintain this gem, email jonathan@titanous.com.**
|
18
18
|
|
@@ -22,7 +22,14 @@ See the [User Guide](https://github.com/titanous/mailman/blob/master/USER_GUIDE.
|
|
22
22
|
|
23
23
|
## Compatibility
|
24
24
|
|
25
|
-
Tested on Ruby 2.0, 1.9.3, JRuby, and Rubinius.
|
25
|
+
Tested on Ruby 2.1, 2.0, 1.9.3, JRuby, and Rubinius.
|
26
|
+
|
27
|
+
### Ruby < 2.0.0
|
28
|
+
|
29
|
+
In order to use this gem with ruby versions older then 2.0.0, you have to
|
30
|
+
restrict the maildir gem to the latest supported version in your `Gemfile`:
|
31
|
+
|
32
|
+
gem 'maildir', '< 2.1.0'
|
26
33
|
|
27
34
|
## Thanks
|
28
35
|
|
data/USER_GUIDE.md
CHANGED
@@ -185,24 +185,31 @@ after processing*. If you want to keep a copy of messages, it is recommended
|
|
185
185
|
that you use a mail retriever with the Maildir receiver. You could also use
|
186
186
|
Gmail and set it to keep messages after they have been retrieved with POP3.
|
187
187
|
|
188
|
+
You can pass a Hash to `ssl` with
|
189
|
+
[SSL context options](http://www.ruby-doc.org/stdlib/libdoc/openssl/rdoc/OpenSSL/SSL/SSLContext.html).
|
190
|
+
For example, when you have a self-signed certificate: `ssl: { ca_file: '/etc/pki/my_ca.pem' }`.
|
191
|
+
|
188
192
|
|
189
193
|
### IMAP
|
190
194
|
|
191
|
-
The IMAP receiver is enabled when the `Mailman.config.imap` hash is set.
|
195
|
+
The IMAP receiver is enabled when the `Mailman.config.imap` hash is set.
|
192
196
|
Polling can be set with `Mailman.config.poll_interval`. This will read all unread messages in the INBOX by default.
|
193
197
|
Here are example settings for gmail.
|
194
198
|
|
195
199
|
```ruby
|
196
200
|
Mailman.config.imap = {
|
197
|
-
server: 'imap.gmail.com',
|
198
|
-
port: 993,
|
201
|
+
server: 'imap.gmail.com',
|
202
|
+
port: 993, # you usually don't need to set this, but it's there if you need to
|
199
203
|
ssl: true,
|
204
|
+
# Use starttls instead of ssl (do not specify both)
|
205
|
+
#starttls: true,
|
200
206
|
username: 'foo@somedomain.com',
|
201
207
|
password: 'totallyunsecuredpassword'
|
202
208
|
}
|
203
209
|
|
204
210
|
```
|
205
211
|
* When using gmail, remember to [enable IMAP](https://support.google.com/mail/troubleshooter/1668960)
|
212
|
+
* You can pass a Hash to `ssl`, just like with POP3.
|
206
213
|
|
207
214
|
### Maildir
|
208
215
|
|
@@ -243,7 +250,7 @@ Mailman.config.pop3 = {
|
|
243
250
|
:username => 'chunkybacon@gmail.com',
|
244
251
|
:password => 'foobar',
|
245
252
|
:server => 'pop.gmail.com',
|
246
|
-
:port => 995, #
|
253
|
+
:port => 995, # you can usually omit this, but it's there
|
247
254
|
:ssl => true # defaults to false
|
248
255
|
}
|
249
256
|
```
|
data/lib/mailman/application.rb
CHANGED
@@ -133,14 +133,23 @@ module Mailman
|
|
133
133
|
end
|
134
134
|
Mailman.logger.info(polling_msg)
|
135
135
|
|
136
|
+
tries ||= 5
|
136
137
|
loop do
|
137
138
|
begin
|
138
139
|
connection.connect
|
139
140
|
connection.get_messages
|
140
|
-
rescue SystemCallError => e
|
141
|
+
rescue SystemCallError, EOFError => e
|
141
142
|
Mailman.logger.error e.message
|
143
|
+
unless (tries -= 1).zero?
|
144
|
+
Mailman.logger.error "Retrying..."
|
145
|
+
begin
|
146
|
+
connection.disconnect
|
147
|
+
rescue # don't crash in the crash handler
|
148
|
+
end
|
149
|
+
retry
|
150
|
+
end
|
142
151
|
ensure
|
143
|
-
connection.disconnect
|
152
|
+
connection.started? && connection.disconnect
|
144
153
|
end
|
145
154
|
|
146
155
|
break unless polling?
|
@@ -13,7 +13,11 @@ module Mailman
|
|
13
13
|
# messages to
|
14
14
|
# @option options [String] :server the server to connect to
|
15
15
|
# @option options [Integer] :port the port to connect to
|
16
|
-
# @option options [Boolean] :ssl
|
16
|
+
# @option options [Boolean,Hash] :ssl if options is true, then an attempt will
|
17
|
+
# be made to use SSL (now TLS) to connect to the server. A Hash can be used
|
18
|
+
# to enable ssl and supply SSL context options.
|
19
|
+
# @option options [Boolean] :starttls use STARTTLS command to start
|
20
|
+
# TLS session.
|
17
21
|
# @option options [String] :username the username to authenticate with
|
18
22
|
# @option options [String] :password the password to authenticate with
|
19
23
|
# @option options [String] :folder the mail folder to search
|
@@ -28,22 +32,34 @@ module Mailman
|
|
28
32
|
@password = options[:password]
|
29
33
|
@filter = options[:filter] || 'UNSEEN'
|
30
34
|
@done_flags = options[:done_flags] || [Net::IMAP::SEEN]
|
31
|
-
@port = options[:port] || 143
|
32
35
|
@ssl = options[:ssl] || false
|
36
|
+
@starttls = options[:starttls] || false
|
37
|
+
@port = options[:port] || (@ssl ? 993 : 143)
|
33
38
|
@folder = options[:folder] || "INBOX"
|
39
|
+
|
40
|
+
if @starttls && @ssl
|
41
|
+
raise StandardError.new("either specify ssl or starttls, not both")
|
42
|
+
end
|
34
43
|
end
|
35
44
|
|
36
45
|
# Connects to the IMAP server.
|
37
46
|
def connect
|
47
|
+
tries ||= 5
|
38
48
|
if @connection.nil? or @connection.disconnected?
|
39
49
|
@connection = Net::IMAP.new(@server, port: @port, ssl: @ssl)
|
50
|
+
if @starttls
|
51
|
+
@connection.starttls
|
52
|
+
end
|
40
53
|
@connection.login(@username, @password)
|
41
54
|
end
|
42
55
|
@connection.select(@folder)
|
56
|
+
rescue Net::IMAP::ByeResponseError, Net::IMAP::NoResponseError => e
|
57
|
+
retry unless (tries -= 1).zero?
|
43
58
|
end
|
44
59
|
|
45
60
|
# Disconnects from the IMAP server.
|
46
61
|
def disconnect
|
62
|
+
return false if @connection.nil?
|
47
63
|
@connection.logout
|
48
64
|
@connection.disconnected? ? true : @connection.disconnect rescue nil
|
49
65
|
end
|
@@ -53,13 +69,21 @@ module Mailman
|
|
53
69
|
def get_messages
|
54
70
|
@connection.search(@filter).each do |message|
|
55
71
|
body = @connection.fetch(message, "RFC822")[0].attr["RFC822"]
|
56
|
-
|
72
|
+
begin
|
73
|
+
@processor.process(body)
|
74
|
+
rescue StandardError => error
|
75
|
+
Mailman.logger.error "Error encountered processing message: #{message.inspect}\n #{error.class.to_s}: #{error.message}\n #{error.backtrace.join("\n")}"
|
76
|
+
next
|
77
|
+
end
|
57
78
|
@connection.store(message, "+FLAGS", @done_flags)
|
58
79
|
end
|
59
80
|
# Clears messages that have the Deleted flag set
|
60
81
|
@connection.expunge
|
61
82
|
end
|
62
83
|
|
84
|
+
def started?
|
85
|
+
not (!@connection.nil? && @connection.disconnected?)
|
86
|
+
end
|
63
87
|
end
|
64
88
|
end
|
65
89
|
end
|
@@ -12,16 +12,21 @@ module Mailman
|
|
12
12
|
# @option options [MessageProcessor] :processor the processor to pass new
|
13
13
|
# messages to
|
14
14
|
# @option options [String] :server the server to connect to
|
15
|
-
# @option options [Integer] :port the port to connect to
|
15
|
+
# @option options [Integer] :port the port to connect to (default 110, or 995 for ssl)
|
16
16
|
# @option options [String] :username the username to authenticate with
|
17
17
|
# @option options [String] :password the password to authenticate with
|
18
|
-
# @option options [true,false] :ssl enable SSL
|
18
|
+
# @option options [true,false,Hash] :ssl enable SSL
|
19
19
|
def initialize(options)
|
20
20
|
@processor = options[:processor]
|
21
21
|
@username = options[:username]
|
22
22
|
@password = options[:password]
|
23
|
-
|
24
|
-
@connection.
|
23
|
+
port = options[:port] || (options[:ssl] ? 995 : 110)
|
24
|
+
@connection = Net::POP3.new(options[:server], port)
|
25
|
+
if options[:ssl].is_a? Hash
|
26
|
+
@connection.enable_ssl(options[:ssl])
|
27
|
+
elsif options[:ssl]
|
28
|
+
@connection.enable_ssl
|
29
|
+
end
|
25
30
|
@connection.open_timeout = options[:open_timeout] if options[:open_timeout]
|
26
31
|
@connection.read_timeout = options[:read_timeout] if options[:read_timeout]
|
27
32
|
end
|
@@ -40,11 +45,19 @@ module Mailman
|
|
40
45
|
# deleting them.
|
41
46
|
def get_messages
|
42
47
|
@connection.each_mail do |message|
|
43
|
-
|
48
|
+
begin
|
49
|
+
@processor.process(message.pop)
|
50
|
+
rescue StandardError => error
|
51
|
+
Mailman.logger.error "Error encountered processing message: #{message.inspect}\n #{error.class.to_s}: #{error.message}\n #{error.backtrace.join("\n")}"
|
52
|
+
next
|
53
|
+
end
|
44
54
|
end
|
45
55
|
@connection.delete_all
|
46
56
|
end
|
47
57
|
|
58
|
+
def started?
|
59
|
+
@connection.started?
|
60
|
+
end
|
48
61
|
end
|
49
62
|
end
|
50
63
|
end
|
data/lib/mailman/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mailman
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.7.
|
4
|
+
version: 0.7.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jonathan Rudenberg
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2015-03-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: mail
|
@@ -86,14 +86,14 @@ dependencies:
|
|
86
86
|
requirements:
|
87
87
|
- - "~>"
|
88
88
|
- !ruby/object:Gem::Version
|
89
|
-
version: '
|
89
|
+
version: '3.0'
|
90
90
|
type: :development
|
91
91
|
prerelease: false
|
92
92
|
version_requirements: !ruby/object:Gem::Requirement
|
93
93
|
requirements:
|
94
94
|
- - "~>"
|
95
95
|
- !ruby/object:Gem::Version
|
96
|
-
version: '
|
96
|
+
version: '3.0'
|
97
97
|
description: Mailman makes it easy to process incoming emails with a simple routing
|
98
98
|
DSL
|
99
99
|
email:
|
@@ -126,7 +126,7 @@ files:
|
|
126
126
|
- lib/mailman/route/string_matcher.rb
|
127
127
|
- lib/mailman/router.rb
|
128
128
|
- lib/mailman/version.rb
|
129
|
-
homepage: https://github.com/
|
129
|
+
homepage: https://github.com/mailman/mailman
|
130
130
|
licenses: []
|
131
131
|
metadata: {}
|
132
132
|
post_install_message:
|