diff --git a/README.md b/README.md index 20dddf2..764785b 100644 --- a/README.md +++ b/README.md @@ -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. diff --git a/bin/mailcatcher b/bin/mailcatcher index 527138b..a2dc063 100755 --- a/bin/mailcatcher +++ b/bin/mailcatcher @@ -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) diff --git a/lib/mail_catcher.rb b/lib/mail_catcher.rb index fd7b395..19922e0 100644 --- a/lib/mail_catcher.rb +++ b/lib/mail_catcher.rb @@ -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