bcbiff 0.2.0 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +4 -3
- data/bcbiff.gemspec +1 -1
- data/lib/bcbiff.rb +25 -24
- metadata +3 -3
data/README.md
CHANGED
@@ -73,9 +73,6 @@ your system and run bcbiff once a minute or so.
|
|
73
73
|
|
74
74
|
Bcbiff will run with Ruby 1.8.7+ and 1.9.2+.
|
75
75
|
|
76
|
-
See `Gemfile` for dependency. Run `bundle install` to install what's
|
77
|
-
missing.
|
78
|
-
|
79
76
|
Bcbiff calls the `sendmail` command to send a mail. Sendmail (or any
|
80
77
|
compatible software such as qmail or Postfix) must be properly
|
81
78
|
configured.
|
@@ -86,6 +83,10 @@ if bcbiff(1) fails to locate the one on your system, follow the
|
|
86
83
|
instruction displayed, and let me know if it's pretty much common on
|
87
84
|
the platform.
|
88
85
|
|
86
|
+
## INSTALLATION
|
87
|
+
|
88
|
+
`gem install bcbiff`
|
89
|
+
|
89
90
|
## SEE ALSO
|
90
91
|
|
91
92
|
* [Boxcar](http://boxcar.io/)
|
data/bcbiff.gemspec
CHANGED
data/lib/bcbiff.rb
CHANGED
@@ -34,7 +34,7 @@ require 'yaml'
|
|
34
34
|
require 'mail'
|
35
35
|
require 'shellwords'
|
36
36
|
|
37
|
-
BCBIFF_VERSION = '0.2.
|
37
|
+
BCBIFF_VERSION = '0.2.1'
|
38
38
|
|
39
39
|
CERTS_PATHS = [
|
40
40
|
'/etc/ssl/cert.pem', # FreeBSD
|
@@ -129,34 +129,35 @@ def check_mails(options)
|
|
129
129
|
File.open(msgids_file, File::RDWR | File::CREAT, 0600) {|f|
|
130
130
|
f.flock(File::LOCK_EX | File::LOCK_NB) or break
|
131
131
|
|
132
|
+
msgids = YAML.load(f) || []
|
133
|
+
|
132
134
|
imap = Net::IMAP.new(options[:host], options[:port], options[:ssl], certs_path, true)
|
133
135
|
imap.login(options[:username], options[:password])
|
134
136
|
folders = options[:folders] || ['Inbox']
|
135
|
-
unseen = folders.inject([]) { |unseen, folder|
|
136
|
-
imap.select(folder)
|
137
|
-
unseen.concat(imap.search('UNSEEN'))
|
138
|
-
}
|
139
|
-
return if unseen.empty?
|
140
|
-
|
141
|
-
msgids = YAML.load(f) || []
|
142
137
|
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
next if
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
138
|
+
folders.each { |folder|
|
139
|
+
imap.select(folder)
|
140
|
+
unseen = imap.search('UNSEEN')
|
141
|
+
next if unseen.empty?
|
142
|
+
|
143
|
+
imap.fetch(unseen, item = 'RFC822.HEADER').each { |data|
|
144
|
+
mail = Mail.read_from_string(data.attr[item])
|
145
|
+
msgid = mail.message_id
|
146
|
+
next if msgids.include?(msgid)
|
147
|
+
msgids << msgid
|
148
|
+
|
149
|
+
(header = mail.header).fields.each { |field|
|
150
|
+
case name = field.name
|
151
|
+
when /\A(From|Subject|Date)\z/i
|
152
|
+
# preserve
|
153
|
+
else
|
154
|
+
header[name] = nil
|
155
|
+
end
|
156
|
+
}
|
157
157
|
|
158
|
-
|
159
|
-
|
158
|
+
open("| sendmail #{mailto.shellescape}", 'w') { |sendmail|
|
159
|
+
sendmail.print mail.encoded
|
160
|
+
}
|
160
161
|
}
|
161
162
|
}
|
162
163
|
msgids.slice!(0...-IDCACHE_SIZE) if msgids.size > IDCACHE_SIZE
|
metadata
CHANGED