NET::IMAP / Runner problems


#1

Hello,

I have a runner script that is meant to check a mailbox using imap and
insert them into the application. The method I am using to do this was
taken directly off the rails wiki:

require ‘net/imap’ # above the class, not within it

def self.check_mail
imap = Net::IMAP.new(‘localhost’)
imap.authenticate(‘LOGIN’, ‘username’, ‘password’)
imap.select(‘INBOX’)
imap.search([‘ALL’]).each do |message_id|
msg = imap.fetch(message_id,‘RFC822’)[0].attr[‘RFC822’]

  MailReader.receive(msg)
  #Mark message as deleted and it will be removed from storage when

user session closd
imap.store(message_id, “+FLAGS”, [:Deleted])
end
end

The following is the output I receive when I run the runner script:

/usr/lib/ruby/gems/1.8/gems/rails-1.1.6/lib/commands/runner.rb:27:
/usr/lib/ruby/gems/1.8/gems/activesupport-1.3.1/lib/active_support/dependencies.rb:123:in
const_missing': uninitialized constant SSL (NameError) from /usr/lib/ruby/gems/1.8/gems/activesupport-1.3.1/lib/active_support/dependencies.rb:133:inconst_missing’
from /usr/lib/ruby/1.8/net/imap.rb:204
from
/usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:27:in require' from /usr/lib/ruby/gems/1.8/gems/activesupport-1.3.1/lib/active_support/dependencies.rb:147:inrequire’
from script/…/config/…/app/models/mailer.rb:1
from
/usr/lib/ruby/gems/1.8/gems/activesupport-1.3.1/lib/active_support/dependencies.rb:140:in
load' from /usr/lib/ruby/gems/1.8/gems/activesupport-1.3.1/lib/active_support/dependencies.rb:56:inrequire_or_load’
from
/usr/lib/ruby/gems/1.8/gems/activesupport-1.3.1/lib/active_support/dependencies.rb:30:in
depend_on' from /usr/lib/ruby/gems/1.8/gems/activesupport-1.3.1/lib/active_support/dependencies.rb:85:inrequire_dependency’
from
/usr/lib/ruby/gems/1.8/gems/activesupport-1.3.1/lib/active_support/dependencies.rb:98:in
const_missing' from /usr/lib/ruby/gems/1.8/gems/activesupport-1.3.1/lib/active_support/dependencies.rb:131:inconst_missing’
from (eval):1
from
/usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:27:in eval' from /usr/lib/ruby/gems/1.8/gems/rails-1.1.6/lib/commands/runner.rb:27 from /usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:27:inrequire’
from
/usr/lib/ruby/gems/1.8/gems/activesupport-1.3.1/lib/active_support/dependencies.rb:147:in
`require’
from script/runner:3

Any ideas?


#2

I’ve narrowed it down to an issue with ‘net/imap’, if I comment out
everything but the require line the same errors occur. Does net/imap
require OpenSSL be installed or something?


#3

And another discovery… it only happens in the Rails environment. If
I type

“require ‘net/imap’” into the rails console I get:

require ‘net/imap’
NameError: uninitialized constant SSL
from
/usr/lib/ruby/gems/1.8/gems/activesupport-1.3.1/lib/active_support/dependencies.rb:123:in
const_missing' from /usr/lib/ruby/gems/1.8/gems/activesupport-1.3.1/lib/active_support/dependencies.rb:133:inconst_missing’
from /usr/lib/ruby/1.8/net/imap.rb:204
from
/usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:27:in require' from /usr/lib/ruby/gems/1.8/gems/activesupport-1.3.1/lib/active_support/dependencies.rb:147:inrequire’
from (irb):1

however when I type it into irb it get no error at all…


#4

I commented out line 204 of /usr/lib/ruby/1.8/net/imap and it worked
fine afterwards. I’m guessing that ubuntu doesn’t have some package
installed by default that other distros do… (like SendMail and
GCC…)

It will probably cause me more problems down the road, but at least for
now I can use net/imap.