Wednesday, June 22, 2011

Ruby code for POP3 auth

Simple Ruby code for pop3 auth (Use at your own risk)


def Connect(server,port,username,password)
puts " try ... #{server}:#{port} - #{username}:#{password}"
Net::POP3.enable_ssl(OpenSSL::SSL::VERIFY_NONE) # enable SSL default port 995
auth = Net::POP3.start(server, port, username, password)

rescue SocketError, Timeout::Error, OpenSSL::SSL::SSLError,EOFError
puts "Connect Error: #{$!}"

rescue Errno::ECONNREFUSED, Errno::ECONNRESET
puts "Connect Error: #{$!}"
sleep 0.60

rescue Net::POPAuthenticationError
puts "Connect Error: #{$!}"
else
auth.finish
return username,password
end

No comments: