From: Shashank Date Date: 2005-08-25T23:32:00+09:00 Subject: Re: [ANN] gmailer 0.0.3 Hi Park, --- Park Heesob wrote: > > Now you can connect with proxy server like this > > GMailer.connect(:username=>name,:password=>pwd, > :proxy_host=>proxy,:proxy_port=>8080, > :proxy_user=>user,:proxy_pass=>pass) { |g| > ... > } > > But proxy connection needs some tests. > I tested it with both with and without proxy. On Win 2K Pro and ruby 1.8.2 (2004-12-25) [i386-mswin32] it error'd on the following code, in both cases (different errors): #------------------------- require "gmailer" name = "stdate" pwd = gets proxy = "firewall.corp.proxy.com" GMailer.connect(name,pwd) do |g| # Now you can connect with proxy server like this # GMailer.connect(:username=>name,:password=>pwd, # :proxy_host=>proxy,:proxy_port=>80) do |g| #:proxy_user=>user,:proxy_pass=>pass) puts "------ fetch" g.fetch(:label=>"my_label") {|snapshot| puts "Total # of conversations of my_label = " + snapshot.box_total.to_s } puts "------ get contact" g.fetch(:contact=>"freq").each do |item| puts "Name: #{item['name']} \nEmail: #{item['email']}" end puts "------ send" g.send( :to => "shanko_date@yahoo.com", :subj => "Hello There!", :body => "Hi...\n\nBlah blah blah~...", :files => ["./junk.jpeg"] ) puts "------ get labels" labels = g.get_labels p labels puts "------ get messages" g.get_messages(:label=>labels[0]).each {|m| puts "Subject: #{m['subj']} / Snippet: #{m['snippet']}" if m['new?'] } end __END__ #-------------------------------------------------------------------------- =================================== Here is the transcript with Proxy: =================================== C:\atest>ruby tst_gmailer3.rb my password here :-) c:/ruby/lib/ruby/1.8/net/protocol.rb:83:in `initialize': getaddrinfo: servname not supported for ai_socktype. (SocketError) from c:/ruby/lib/ruby/1.8/net/protocol.rb:83:in `new' from c:/ruby/lib/ruby/1.8/net/protocol.rb:83:in `connect' from c:/ruby/lib/ruby/1.8/net/protocol.rb:82:in `timeout' from c:/ruby/lib/ruby/1.8/timeout.rb:55:in `timeout' from c:/ruby/lib/ruby/1.8/net/protocol.rb:82:in `connect' from c:/ruby/lib/ruby/1.8/net/protocol.rb:64:in `initialize' from c:/ruby/lib/ruby/site_ruby/1.8/net/protocols.rb:37:in `initialize' from c:/ruby/lib/ruby/1.8/net/http.rb:430:in `open' from c:/ruby/lib/ruby/1.8/net/http.rb:430:in `do_start' from c:/ruby/lib/ruby/1.8/net/http.rb:419:in `start' from c:/ruby/lib/ruby/site_ruby/1.8/gmailer.rb:148:in `connectNoCookie' from c:/ruby/lib/ruby/site_ruby/1.8/gmailer.rb:217:in `connect' from tst_gmailer3.rb:10 =================================== And here without proxy: =================================== C:\atest>ruby tst_gmailer3.rb my password here :-) ------ fetch Total # of conversations of my_label = 0 ------ get contact Name: shanko_date Email: shanko_date@yahoo.com Name: shashank Email: shashank@juno.com ------ send ------ get labels [] ------ get messages c:/ruby/lib/ruby/site_ruby/1.8/gmailer.rb:305:in `+': cannot convert nil into String (TypeError) from c:/ruby/lib/ruby/site_ruby/1.8/gmailer.rb:305:in `fetchBox' from c:/ruby/lib/ruby/site_ruby/1.8/gmailer.rb:379:in `fetch' from c:/ruby/lib/ruby/site_ruby/1.8/gmailer.rb:502:in `get_messages' from tst_gmailer3.rb:37 from tst_gmailer3.rb:7:in `connect' from tst_gmailer3.rb:7 C:\atest> =================================== HTH, -- shanko __________________________________________________ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com