mail_room 0.5.1 → 0.5.2
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 +10 -0
- data/README.md +1 -1
- data/lib/mail_room/delivery/sidekiq.rb +15 -1
- data/lib/mail_room/mailbox.rb +2 -0
- data/lib/mail_room/mailbox_watcher.rb +6 -0
- data/lib/mail_room/version.rb +1 -1
- data/mail_room.gemspec +1 -0
- data/spec/lib/mailbox_watcher_spec.rb +24 -3
- metadata +16 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 836563b572db61eacd01d2363273d998863e9831
|
4
|
+
data.tar.gz: de0cab71b636b3c7ffe0f08cd021896e403940c3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9648c21785544fab432cedeca09c6c28ffd7d993f7ff90c30c1bb2d893e00517687f233118ae945be43fe1c0123ce7f0b2a0addf78c7b5fb22876fae81718df9
|
7
|
+
data.tar.gz: 503a0ac11cf7e0dddb4299c608ba5d87a5820419afb08ed8a65aeed6e04c6e56a54133f61239f193c63a8f11384fe91540b16ad7dac2a81cbbad4044e794ef1d
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -195,7 +195,7 @@ This setting allows configuration of the IMAP search command sent to the server.
|
|
195
195
|
|
196
196
|
## IMAP Server Configuration ##
|
197
197
|
|
198
|
-
You can set per-mailbox configuration for the IMAP server's `host` (default: 'imap.gmail.com'), `port` (default: 993),
|
198
|
+
You can set per-mailbox configuration for the IMAP server's `host` (default: 'imap.gmail.com'), `port` (default: 993), `ssl` (default: true), and `start_tls` (default: false).
|
199
199
|
|
200
200
|
If you're seeing the error `Please log in via your web browser: https://support.google.com/mail/accounts/answer/78754 (Failure)`, you need to configure your Gmail account to allow less secure apps to access it: https://support.google.com/accounts/answer/6010255.
|
201
201
|
|
@@ -1,6 +1,7 @@
|
|
1
1
|
require "redis"
|
2
2
|
require "securerandom"
|
3
3
|
require "json"
|
4
|
+
require "charlock_holmes"
|
4
5
|
|
5
6
|
module MailRoom
|
6
7
|
module Delivery
|
@@ -53,7 +54,7 @@ module MailRoom
|
|
53
54
|
def item_for(message)
|
54
55
|
{
|
55
56
|
'class' => options.worker,
|
56
|
-
'args' => [message],
|
57
|
+
'args' => [utf8_encode_message(message)],
|
57
58
|
|
58
59
|
'queue' => options.queue,
|
59
60
|
'jid' => SecureRandom.hex(12),
|
@@ -61,6 +62,19 @@ module MailRoom
|
|
61
62
|
'enqueued_at' => Time.now.to_f
|
62
63
|
}
|
63
64
|
end
|
65
|
+
|
66
|
+
def utf8_encode_message(message)
|
67
|
+
message = message.dup
|
68
|
+
|
69
|
+
message.force_encoding("UTF-8")
|
70
|
+
return message if message.valid_encoding?
|
71
|
+
|
72
|
+
detection = CharlockHolmes::EncodingDetector.detect(message)
|
73
|
+
return message unless detection && detection[:encoding]
|
74
|
+
|
75
|
+
# Convert non-UTF-8 body UTF-8 so it can be dumped as JSON.
|
76
|
+
CharlockHolmes::Converter.convert(message, detection[:encoding], 'UTF-8')
|
77
|
+
end
|
64
78
|
end
|
65
79
|
end
|
66
80
|
end
|
data/lib/mail_room/mailbox.rb
CHANGED
@@ -6,6 +6,7 @@ module MailRoom
|
|
6
6
|
:host,
|
7
7
|
:port,
|
8
8
|
:ssl,
|
9
|
+
:start_tls,
|
9
10
|
:search_command,
|
10
11
|
:name,
|
11
12
|
:delete_after_delivery,
|
@@ -27,6 +28,7 @@ module MailRoom
|
|
27
28
|
:host => 'imap.gmail.com',
|
28
29
|
:port => 993,
|
29
30
|
:ssl => true,
|
31
|
+
:start_tls => false,
|
30
32
|
:delete_after_delivery => false,
|
31
33
|
:delivery_options => {}
|
32
34
|
}
|
@@ -65,6 +65,7 @@ module MailRoom
|
|
65
65
|
# log in and set the mailbox
|
66
66
|
def setup
|
67
67
|
reset
|
68
|
+
start_tls
|
68
69
|
log_in
|
69
70
|
set_mailbox
|
70
71
|
end
|
@@ -77,6 +78,11 @@ module MailRoom
|
|
77
78
|
@idling = false
|
78
79
|
end
|
79
80
|
|
81
|
+
# start a TLS session
|
82
|
+
def start_tls
|
83
|
+
imap.starttls if @mailbox.start_tls
|
84
|
+
end
|
85
|
+
|
80
86
|
# send the imap login command to google
|
81
87
|
def log_in
|
82
88
|
imap.login(@mailbox.email, @mailbox.password)
|
data/lib/mail_room/version.rb
CHANGED
data/mail_room.gemspec
CHANGED
@@ -37,10 +37,17 @@ describe MailRoom::MailboxWatcher do
|
|
37
37
|
end
|
38
38
|
|
39
39
|
describe '#setup' do
|
40
|
+
let(:imap) {stub(:login => true, :select => true)}
|
41
|
+
|
42
|
+
let(:mailbox) {
|
43
|
+
MailRoom::Mailbox.new(:email => 'user1@gmail.com', :password => 'password', :name => 'inbox', )
|
44
|
+
}
|
45
|
+
|
46
|
+
let(:watcher) {
|
47
|
+
MailRoom::MailboxWatcher.new(mailbox)
|
48
|
+
}
|
49
|
+
|
40
50
|
it 'logs in and sets the mailbox to watch' do
|
41
|
-
imap = stub(:login => true, :select => true)
|
42
|
-
mailbox = stub(:email => 'user1@gmail.com', :password => 'password', :name => 'inbox')
|
43
|
-
watcher = MailRoom::MailboxWatcher.new(mailbox)
|
44
51
|
watcher.stubs(:imap).returns(imap)
|
45
52
|
|
46
53
|
watcher.setup
|
@@ -49,6 +56,20 @@ describe MailRoom::MailboxWatcher do
|
|
49
56
|
watcher.logged_in?.should eq(true)
|
50
57
|
imap.should have_received(:select).with('inbox')
|
51
58
|
end
|
59
|
+
|
60
|
+
context 'with start_tls configured as true' do
|
61
|
+
before(:each) do
|
62
|
+
mailbox.start_tls = true
|
63
|
+
imap.stubs(:starttls)
|
64
|
+
watcher.stubs(:imap).returns(imap)
|
65
|
+
end
|
66
|
+
|
67
|
+
it 'sets up tls session on imap setup' do
|
68
|
+
watcher.setup
|
69
|
+
|
70
|
+
imap.should have_received(:starttls)
|
71
|
+
end
|
72
|
+
end
|
52
73
|
end
|
53
74
|
|
54
75
|
describe '#idle' do
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mail_room
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tony Pitale
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-09-
|
11
|
+
date: 2015-09-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
@@ -150,6 +150,20 @@ dependencies:
|
|
150
150
|
- - ">="
|
151
151
|
- !ruby/object:Gem::Version
|
152
152
|
version: '0'
|
153
|
+
- !ruby/object:Gem::Dependency
|
154
|
+
name: charlock_holmes
|
155
|
+
requirement: !ruby/object:Gem::Requirement
|
156
|
+
requirements:
|
157
|
+
- - ">="
|
158
|
+
- !ruby/object:Gem::Version
|
159
|
+
version: '0'
|
160
|
+
type: :development
|
161
|
+
prerelease: false
|
162
|
+
version_requirements: !ruby/object:Gem::Requirement
|
163
|
+
requirements:
|
164
|
+
- - ">="
|
165
|
+
- !ruby/object:Gem::Version
|
166
|
+
version: '0'
|
153
167
|
description: mail_room will proxy email (gmail) from IMAP to a delivery method
|
154
168
|
email:
|
155
169
|
- tpitale@gmail.com
|