Created
June 12, 2014 12:39
-
-
Save bsa7/860a3d5ade7858b6beb4 to your computer and use it in GitHub Desktop.
ruby - mailman init
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
require 'colorize' | |
require 'rubygems' | |
require 'bundler/setup' | |
require 'mailman' | |
Mailman.config.maildir = 'Mail' | |
Mailman.config.poll_interval = 5 | |
Mailman.config.logger = Logger.new('log/mailman.log') | |
Mailman.config.imap = { | |
server: 'mail.server.org', | |
port: 993, # usually 995, 993 for gmail | |
ssl: true, | |
username: 'inbox@server.com', | |
password: 'password' | |
} | |
#------------------------------------------------------------------------------------------------- | |
Mailman::Application.run do | |
puts "mailman runned" | |
default do | |
begin | |
puts "incoming mail".green | |
# IncomingMessage.receive(message) ## Troubles | |
puts "#{message}".yellow | |
rescue Exception => e | |
Mailman.logger.error "Exception occured while receiving message:\n#{message}" | |
Mailman.logger.error [e, *e.backtrace].join('\n') | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment