Ruby Net::IMAP library provides a good API for IMAP stuff (http://railsapi.com/doc开发者_如何学Go/ruby-v1.8/classes/Net/IMAP.html). There are two methods related to closing the IMAP connection: logout() and disconnect(). In which turn are they supposed to be called?
logout
will simply log the user out of the server while disconnect
will completely close the socket. I would use logout if you want to keep the connection open (like maybe logging into another mailbox using the same socket) and disconnect when you don't need to do anymore work with the IMAP server. As for a sequence, logout should be used before disconnect.
精彩评论