Browse files

Merge pull request #2 from capita/master

Specifying SMTP and POP3 ports on the command line
  • Loading branch information...
2 parents 8a76f72 + 631c36e commit eacd84e0e79474f1d9639b7124f9b6b4d204a46e @rvanlieshout rvanlieshout committed Sep 13, 2011
Showing with 18 additions and 7 deletions.
  1. +1 −0 .gitignore
  2. +1 −1 VERSION
  3. +12 −2 bin/post_office
  4. +2 −2 lib/pop_server.rb
  5. +2 −2 lib/smtp_server.rb
  6. BIN pkg/post_office-0.3.2.gem
View
1 .gitignore
@@ -0,0 +1 @@
+.idea
View
2 VERSION
@@ -1 +1 @@
-0.3.1
+0.3.1
View
14 bin/post_office
@@ -24,6 +24,16 @@ optparse = OptionParser.new do |opts|
opts.on( '-l', '--logfile FILE', 'Write log to FILE. Outputs to STDOUT (or /var/log/post_office.log when daemonized) by default.' ) do |file|
options[:logfile] = file
end
+
+ options[:smtp_port] = nil
+ opts.on( '-smtp', '--smtp PORT', 'Specify SMTP port to use' ) do |port|
+ options[:smtp_port] = port
+ end
+
+ options[:pop3_port] = nil
+ opts.on( '-pop3', '--pop3 PORT', 'Specify POP3 port to use' ) do |port|
+ options[:pop3_port] = port
+ end
options[:startup_item] = nil
opts.on('--install-osx-startup-item', 'Installs Post Office as OS X Startup Item') do
@@ -60,8 +70,8 @@ $log = Logger.new(options[:logfile] || STDOUT)
$log.level = options[:verbose] ? Logger::DEBUG : Logger::INFO
begin
- smtp_server = Thread.new{ SMTPServer.new }
- pop_server = Thread.new{ POPServer.new }
+ smtp_server = Thread.new{ SMTPServer.new(options[:smtp_port] || 25) }
+ pop_server = Thread.new{ POPServer.new(options[:pop3_port]) || 110 }
smtp_server.join
pop_server.join
View
4 lib/pop_server.rb
@@ -6,8 +6,8 @@
class POPServer < GenericServer
# Create new server listening on port 110
- def initialize
- super(:port => 110)
+ def initialize(port)
+ super(:port => port)
end
# Send a greeting to client
View
4 lib/smtp_server.rb
@@ -7,9 +7,9 @@ class SMTPServer < GenericServer
attr_accessor :client_data
# Create new server listening on port 25
- def initialize
+ def initialize(port)
self.client_data = Hash.new
- super(:port => 25)
+ super(:port => port)
end
# Send a greeting to client
View
BIN pkg/post_office-0.3.2.gem
Binary file not shown.

0 comments on commit eacd84e

Please sign in to comment.