Net::POP3 and Firewall

M

Mike Ho

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
 
M

Mike Ho

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
 
D

Daniel Bye

--sdtB3X0nJg68CQEu
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

This code woks on my home PC - i.e. no firewall. Does anyone know what's= =20
needed for it to run from behind a firewall?
###############
require 'net/pop'
=20
=20
pop =3D Net::pOP3.new('pop.mail.yahoo.co.uk', 110, false)
pop.start('myUserName', 'myPwd')
if pop.mails.empty?
puts 'No mail.'
else
i =3D 0
pop.each_mail do |m|
File.open("inbox/#{i}", 'w') do |f|
=20
f.write m.pop
end
=20
=20
i +=3D 1
end
puts "#{pop.mails.size} mails popped."
end
pop.finish
=20
#################
=20
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=20
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

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

--sdtB3X0nJg68CQEu
Content-Type: application/pgp-signature
Content-Disposition: inline

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.4 (FreeBSD)

iD8DBQFHAok4ixf5fBYiFmoRAnXcAKDFmk/R9GdeCOL0H/eA1Tb5MbJkbwCbB6E9
xYufqwTYBi31KN1BI9wQJSc=
=+B0c
-----END PGP SIGNATURE-----

--sdtB3X0nJg68CQEu--
 
P

Poornima Dhanasekar

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('(e-mail address removed)', '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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,015
Latest member
AmbrosePal

Latest Threads

Top