Skip to content

Instantly share code, notes, and snippets.

@lian
Created November 6, 2013 23:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lian/7346290 to your computer and use it in GitHub Desktop.
Save lian/7346290 to your computer and use it in GitHub Desktop.
ruby-pop3-auth.rb
require 'socket'
serv = TCPServer.new("127.0.0.1", 110)
s = serv.accept
s.puts "+OK POP3 server ready"
while line = s.gets.strip
case line
when "CAPA"
s.puts("SASL PLAIN\n.")
when "AUTH PLAIN"
s.puts("+OK")
when /=$/
p Hash[ [:username, :password].zip(line.unpack("m0")[0].split("\x00")[1..-1]) ]
s.close
exit
else
p [:unkown, line]
s.close
exit
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment