[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Net::POP3 and Firewall

Mike Ho

10/2/2007 2:04:00 PM

Hi,
I'm trying to use Net::POP3 from behind a firewall and I can't get past
this error
C:/ruby/lib/ruby/1.8/net/protocol.rb:206:in `initialize': Bad file
descriptor - connect(2) (Errno::EBADF)

I had a similar error when trying to access a url via http but I got
around it by using a Net::HTTP::Proxy i.e.

host = 'whatever '
path = '/../ etc'

proxy_addr = 'my.proxy.addr'
proxy_port = myProxyPort

response = Net::HTTP::Proxy(proxy_addr, proxy_port).get_response(host,
path)
puts response


I've been unable to find anything similar for Net::POP3 ie code like
this

pop = Net::POP3.new(...)

just dies and gives the error at the start of this post.

What do I need to do? Are there some ENV vars that need setting? I've
spent a day Googling etc. but go nowhere!

Thanks

Mike
--
Posted via http://www.ruby-....

3 Answers

Mike Ho

10/2/2007 5:50:00 PM

0

This code woks on my home PC - i.e. no firewall. Does anyone know what's
needed for it to run from behind a firewall?
###############
require 'net/pop'


pop = Net::POP3.new('pop.mail.yahoo.co.uk', 110, false)
pop.start('myUserName', 'myPwd')
if pop.mails.empty?
puts 'No mail.'
else
i = 0
pop.each_mail do |m|
File.open("inbox/#{i}", 'w') do |f|

f.write m.pop
end


i += 1
end
puts "#{pop.mails.size} mails popped."
end
pop.finish

#################

I'd really appreciate any thoughts or comments.

Thanks

Mike
--
Posted via http://www.ruby-....

Daniel Bye

10/2/2007 6:18:00 PM

0

On Wed, Oct 03, 2007 at 02:50:19AM +0900, Mike Ho wrote:
> This code woks on my home PC - i.e. no firewall. Does anyone know what's
> needed for it to run from behind a firewall?
> ###############
> require 'net/pop'
>
>
> pop = Net::POP3.new('pop.mail.yahoo.co.uk', 110, false)
> pop.start('myUserName', 'myPwd')
> if pop.mails.empty?
> puts 'No mail.'
> else
> i = 0
> pop.each_mail do |m|
> File.open("inbox/#{i}", 'w') do |f|
>
> f.write m.pop
> end
>
>
> i += 1
> end
> puts "#{pop.mails.size} mails popped."
> end
> pop.finish
>
> #################
>
> I'd really appreciate any thoughts or comments.

I don't know of any programmatic way to do this - have you spoken to your
firewall administrator? He will need to allow POP3 traffic out to the
Internet (at least from the box hosting your app to the POP3 server it is
trying to contact) and back again.

You could also check out SOCKS, which may enable you to proxy through
the firewall.

Dan

--
Daniel Bye
_
ASCII ribbon campaign ( )
- against HTML, vCards and X
- proprietary attachments in e-mail /

Poornima Dhanasekar

2/20/2009 1:07:00 PM

0

Hello,

I am troubling wit fetching my .xls attachments from my mail.i did
this with the help if IMAP.but i wan to do the same in using POP3.i got
the text files with the contents and some of bar codes.but i couldn't
get the original attachments from my mail.Plz help me.Thanks in
advance.my code is.


require 'rubygems'
require 'net/pop'


Net::POP3.enable_ssl(OpenSSL::SSL::VERIFY_NONE)
pop = Net::POP3.new('pop.gmail.com', Net::POP3.default_pop3s_port,
false)
pop.start('poornima.dgl@gmail.com', 'password')
if pop.mails.empty?
puts 'No mail.'
else
i = 0
pop.each_mail do |m|
File.open("inbox/#{i}", 'w') do |f|
f.write m.pop
end
i += 1
end
puts "#{pop.mails.size} mails popped."
end
pop.finish
--
Posted via http://www.ruby-....