-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmail_check.rb
More file actions
24 lines (20 loc) · 869 Bytes
/
mail_check.rb
File metadata and controls
24 lines (20 loc) · 869 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
begin
require_relative 'sys/load_app'
LoadApp.new(env: 'dev')
# Create a mail updated and add a mail source
updater = MailUpdater.new
updater.logger = Logger.new('log/message.log')
updater.ignore_pattern = /(all mail|important|trash|sent|drafts|arcana|spam|response code alert)/i
updater.mail_source = Offlineimap.new
# Register listeners - these actions will take effect when new mail arrives
updater.register MuIndex.new, :event => :new_mail
updater.register PlaySound.new, :event => :new_mail
updater.register ShowNotifier.new, :event => :new_mail
updater.register MessageLogger.new, :event => :new_mail
# Check for new mail
updater.process
rescue Exception => e
# As this is meant to run in the background, wrap this all in an exception check
puts e.message
puts e.backtrace.join("\n")
end