Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Net::IMAP uninitialized constant error

I really don't know where to start with this one, but I am (first time) using Net::IMAP and I am getting the following error:

NameError in EmailsController#connect
uninitialized constant Net::IMAP

Extracted source (around line #4):

2  
3 def connect
4  imap = Net::IMAP.new('outlook.office365.com')
5  imap.authenticate('LOGIN', '**@**.com', '**')
6  imap.examine('INBOX')
7  @emails = imap.search(["RECENT"])

Not really sure what is going on here, I don't have to have anything in my Gemfile.rb? Or anything else before I set the imap variable?

like image 382
Cameron Aziz Avatar asked Feb 10 '23 15:02

Cameron Aziz


1 Answers

You need to require 'net/imap' at the top of the file to bring Net::IMAP into scope.

like image 82
jimcavoli Avatar answered Feb 15 '23 16:02

jimcavoli