Adding command line options from amc-projects/mailcatcher@f7a1b2f6ef, thanks to schlick.

This commit is contained in:
Samuel Cochran 2010-10-25 23:32:56 +08:00
parent e141415c62
commit 3ac1bf9cad
3 changed files with 27 additions and 6 deletions

View File

@ -11,6 +11,7 @@ MailCatcher runs a super simple SMTP server which catches any message sent to it
* Rewrites HTML enabling display of embedded, inline images/etc. (currently very basic)
* Lists attachments and allows separate downloading of parts.
* Written super-simply in EventMachine, easy to dig in and change.
* Command line options to override the default SMTP/HTTP IP and port settings.
## Caveats
@ -21,7 +22,6 @@ MailCatcher runs a super simple SMTP server which catches any message sent to it
## TODO
* Command line options.
* Websockets for immediate mail viewing.
* Download link to view original message in mail client.
* Growl support.

View File

@ -14,6 +14,26 @@ options = {}
OptionParser.new do |opts|
opts.banner = 'Usage: mailcatcher [options]'
options[:smtp_ip] = '127.0.0.1'
opts.on('--smtp-ip IP', 'Set the ip address of the smtp server') do |ip|
options[:smtp_ip] = ip
end
options[:smtp_port] = 1025
opts.on('--smtp-port PORT', Integer, 'Set the port of the smtp server') do |port|
options[:smtp_port] = port
end
options[:http_ip] = '127.0.0.1'
opts.on('--http-ip IP', 'Set the ip address of the http server') do |ip|
options[:http_ip] = ip
end
options[:http_port] = 1080
opts.on('--http-port PORT', Integer, 'Set the port address of the http server') do |port|
options[:http_port] = port
end
options[:verbose] = false
opts.on('-v', '--verbose', 'Be more verbose') do
options[:verbose] = true
@ -21,11 +41,8 @@ OptionParser.new do |opts|
opts.on('-h', '--help', 'Display this help information') do
puts opts
exit
exit!
end
end.parse!
puts 'Starting mail catcher'
puts '==> smtp://127.0.0.1:1025'
puts '==> http://127.0.0.1:1080'
MailCatcher.run
MailCatcher.run(options)

View File

@ -204,6 +204,10 @@ module MailCatcher
options[:http_ip] ||= '127.0.0.1'
options[:http_port] ||= 1080
puts "Starting MailCatcher"
puts "==> smtp://#{options[:smtp_ip]}:#{options[:smtp_port]}"
puts "==> http://#{options[:http_ip]}:#{options[:http_port]}"
Thin::Logging.silent = true
EM::run do
EM::start_server options[:smtp_ip], options[:smtp_port], SmtpServer