I need to retrieve emails from my Gmail account using Ruby on Rails. I''m currently using this piece of code, but it gives me a timeout error everytime. require ''net/pop'' pop = Net::POP3.new ''mail.isp.com'' pop.start ''username-C43h488GkGQ@public.gmane.org'', ''password'' if pop.mails.empty? puts "No mail." else puts "You have #{pop.mails.length} new messages." puts "Downloading..." pop.mails.each_with_index do|m,i| File.open( "inbox/#{i}", ''w+'' ) do|f| f.write m.pop end m.delete end end This is the error I recieve /usr/lib/ruby/1.8/timeout.rb:60:in `new'': execution expired (Timeout::Error) from /usr/lib/ruby/1.8/net/protocol.rb:206:in `old_open'' from /usr/lib/ruby/1.8/net/protocol.rb:206:in `old_open'' from /usr/lib/ruby/1.8/net/pop.rb:438:in `do_start'' from /usr/lib/ruby/1.8/net/pop.rb:432:in `start'' from script/mail.rb:4 Any help will be appreciated! -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Have you tried> pop = Net::POP3.new ''pop.gmail.com''Christophe Le 19 avr. 2010 à 12:48, Shreyas Satish a écrit :> > > I need to retrieve emails from my Gmail account using Ruby on Rails. I''m > currently using this piece of code, but it gives me a timeout error > everytime. > > require ''net/pop'' > > pop = Net::POP3.new ''mail.isp.com'' > pop.start ''username-C43h488GkGQ@public.gmane.org'', ''password'' > > if pop.mails.empty? > puts "No mail." > else > puts "You have #{pop.mails.length} new messages." > puts "Downloading..." > > pop.mails.each_with_index do|m,i| > File.open( "inbox/#{i}", ''w+'' ) do|f| > f.write m.pop > end > > m.delete > end > end > > This is the error I recieve > > /usr/lib/ruby/1.8/timeout.rb:60:in `new'': execution expired > (Timeout::Error) > from /usr/lib/ruby/1.8/net/protocol.rb:206:in `old_open'' > from /usr/lib/ruby/1.8/net/protocol.rb:206:in `old_open'' > from /usr/lib/ruby/1.8/net/pop.rb:438:in `do_start'' > from /usr/lib/ruby/1.8/net/pop.rb:432:in `start'' > from script/mail.rb:4 > > Any help will be appreciated! > -- > Posted via http://www.ruby-forum.com/. > > -- > You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. > To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. > For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en. >-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Christophe Decaux wrote:> Have you tried >> pop = Net::POP3.new ''pop.gmail.com'' > > Christophe > > Le 19 avr. 2010 � 12:48, Shreyas Satish a �crit :Tried it.Ain''t working. -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Try SSL? http://mail.google.com/support/bin/answer.py?hl=en&answer=13287 Larry On Mon, Apr 19, 2010 at 6:10 AM, Shreyas Satish <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> Christophe Decaux wrote: >> Have you tried >>> pop = Net::POP3.new ''pop.gmail.com'' >> >> Christophe >> >> Le 19 avr. 2010 � 12:48, Shreyas Satish a �crit : > > Tried it.Ain''t working. > -- > Posted via http://www.ruby-forum.com/. > > -- > You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. > To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. > For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en. > >-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
I''ve used Fetcher plugin for that. Worked for me http://github.com/look/fetcher On Mon, Apr 19, 2010 at 7:17 PM, Larry Meadors <larry.meadors-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>wrote:> Try SSL? > > http://mail.google.com/support/bin/answer.py?hl=en&answer=13287 > > Larry > > > On Mon, Apr 19, 2010 at 6:10 AM, Shreyas Satish <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> > wrote: > > Christophe Decaux wrote: > >> Have you tried > >>> pop = Net::POP3.new ''pop.gmail.com'' > >> > >> Christophe > >> > >> Le 19 avr. 2010 � 12:48, Shreyas Satish a �crit : > > > > Tried it.Ain''t working. > > -- > > Posted via http://www.ruby-forum.com/. > > > > -- > > You received this message because you are subscribed to the Google Groups > "Ruby on Rails: Talk" group. > > To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > > To unsubscribe from this group, send email to > rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org<rubyonrails-talk%2Bunsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> > . > > For more options, visit this group at > http://groups.google.com/group/rubyonrails-talk?hl=en. > > > > > > -- > You received this message because you are subscribed to the Google Groups > "Ruby on Rails: Talk" group. > To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to > rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org<rubyonrails-talk%2Bunsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> > . > For more options, visit this group at > http://groups.google.com/group/rubyonrails-talk?hl=en. > >-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
=begin Tested with ruby 1.8.7 on a Debian machine, with my own gmail account. ruby -rubygems "from name" "from email" "to name" "to email" "subject" "body" =end require ''net/smtp'' require ''tlsmail'' Net::SMTP.enable_tls OpenSSL::SSL::VERIFY_NONE $SERVER = ''smtp.gmail.com'' $PORT = ''587'' $DOMAIN = ''loclahost''#HELO domain $USERNAME = ''username'' $PASSWORD = ''password'' from_name = ARGV[0] from_email = ARGV[1] to_name = ARGV[2] to_email = ARGV[3] subject = ARGV[4] body = ARGV[5] msg = <<EOF From: #{from_name} <#{from_email}> To: #{to_name} <#{to_email}> Subject: #{subject} #{body} EOF Net::SMTP.start( $SERVER, $PORT, $DOMAIN, $USERNAME, $PASSWORD, :plain ) do |smtp| smtp.sendmail msg, from_email, to_email end I use this to send email. maybe you can tweak it a bit to retrieve emails. On Apr 19, 4:59 pm, Vladimir Rybas <vladimirry...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> I''ve used Fetcher plugin for that. Worked for mehttp://github.com/look/fetcher > > On Mon, Apr 19, 2010 at 7:17 PM, Larry Meadors <larry.mead...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>wrote: > > > > > Try SSL? > > >http://mail.google.com/support/bin/answer.py?hl=en&answer=13287 > > > Larry > > > On Mon, Apr 19, 2010 at 6:10 AM, Shreyas Satish <li...-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> > > wrote: > > > Christophe Decaux wrote: > > >> Have you tried > > >>> pop = Net::POP3.new ''pop.gmail.com'' > > > >> Christophe > > > >> Le 19 avr. 2010 12:48, Shreyas Satish a crit : > > > > Tried it.Ain''t working. > > > -- > > > Posted viahttp://www.ruby-forum.com/. > > > > -- > > > You received this message because you are subscribed to the Google Groups > > "Ruby on Rails: Talk" group. > > > To post to this group, send email to rubyonrails-talk-/JYPxA39Uh4Ykp1iOSErHA@public.gmane.orgm. > > > To unsubscribe from this group, send email to > > rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org<rubyonrails-talk%2Bunsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> > > . > > > For more options, visit this group at > >http://groups.google.com/group/rubyonrails-talk?hl=en. > > > -- > > You received this message because you are subscribed to the Google Groups > > "Ruby on Rails: Talk" group. > > To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > > To unsubscribe from this group, send email to > > rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org<rubyonrails-talk%2Bunsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> > > . > > For more options, visit this group at > >http://groups.google.com/group/rubyonrails-talk?hl=en. > > -- > You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. > To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. > For more options, visit this group athttp://groups.google.com/group/rubyonrails-talk?hl=en.-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.