2010-10-24 20:51:17 -04:00
|
|
|
require 'eventmachine'
|
|
|
|
require 'thin'
|
|
|
|
|
|
|
|
module MailCatcher
|
2010-10-27 15:12:26 -04:00
|
|
|
autoload :Events, 'mail_catcher/events'
|
|
|
|
autoload :Mail, 'mail_catcher/mail'
|
|
|
|
autoload :Smtp, 'mail_catcher/smtp'
|
|
|
|
autoload :Web, 'mail_catcher/web'
|
2010-10-24 20:51:17 -04:00
|
|
|
|
2010-10-24 21:23:19 -04:00
|
|
|
def self.run(options = {})
|
|
|
|
options[:smtp_ip] ||= '127.0.0.1'
|
|
|
|
options[:smtp_port] ||= 1025
|
|
|
|
options[:http_ip] ||= '127.0.0.1'
|
|
|
|
options[:http_port] ||= 1080
|
|
|
|
|
2010-10-25 11:32:56 -04:00
|
|
|
puts "Starting MailCatcher"
|
|
|
|
puts "==> smtp://#{options[:smtp_ip]}:#{options[:smtp_port]}"
|
|
|
|
puts "==> http://#{options[:http_ip]}:#{options[:http_port]}"
|
|
|
|
|
2010-10-24 20:51:17 -04:00
|
|
|
Thin::Logging.silent = true
|
2010-10-27 15:12:26 -04:00
|
|
|
EventMachine.run do
|
|
|
|
EventMachine.start_server options[:smtp_ip], options[:smtp_port], Smtp
|
|
|
|
Thin::Server.start options[:http_ip], options[:http_port], Web
|
2010-10-24 20:51:17 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|