Copyright (C) 2000 Shugo Maeda <shugo@ruby-lang.org>
This library is distributed under the terms of the Ruby license. You can freely distribute/modify this library.
Net::IMAP implements Internet Message Access Protocol (IMAP) clients.
Object
Creates a new Net::IMAP object and connects it to the specified port on the named host.
Returns an initial greeting response from the server.
Returns recorded untagged responses.
ex).
imap.select("inbox") p imap.responses["EXISTS"][-1] #=> [2] p imap.responses["UIDVALIDITY"][-1] #=> [968263756]
Disconnects from the server.
Sends a CAPABILITY command, and returns a listing of capabilities that the server supports.
Sends a NOOP command to the server. It does nothing.
Sends a LOGOUT command to inform the server that the client is done with the connection.
Sends an AUTEHNTICATE command to authenticate the client. The auth_type parameter is a string that represents the authentication mechanism to be used. Currently Net::IMAP supports "LOGIN" and "CRAM-MD5" for the auth_type.
ex).
imap.authenticate('LOGIN', user, password)
Sends a LOGIN command to identify the client and carries the plaintext password authenticating this user.
Sends a SELECT command to select a mailbox so that messages in the mailbox can be accessed.
Sends a EXAMINE command to select a mailbox so that messages in the mailbox can be accessed. However, the selected mailbox is identified as read-only.
Sends a CREATE command to create a new mailbox.
Sends a DELETE command to remove the mailbox.
Sends a RENAME command to change the name of the mailbox to the newname.
Sends a SUBSCRIBE command to add the specified mailbox name to the server's set of "active" or "subscribed" mailboxes.
Sends a UNSUBSCRIBE command to remove the specified mailbox name from the server's set of "active" or "subscribed" mailboxes.
Sends a LIST command, and returns a subset of names from the complete set of all names available to the client.
ex).
imap.create("foo/bar") imap.create("foo/baz") p imap.list("", "foo/%") #=> [[[:NoSelect], "/", "foo/"], [[:NoInferiors], "/", "foo/baz"], [[:NoInferiors], "/", "foo/bar"]]
Sends a LSUB command, and returns a subset of names from the set of names that the user has declared as being "active" or "subscribed".
Sends a STATUS command, and returns the status of the indicated mailbox.
ex).
p imap.status("inbox", ["MESSAGES", "RECENT"]) #=> {"RECENT"=>0, "MESSAGES"=>5}
Sends a APPEND command to append the message to the end of the mailbox.
ex).
imap.append("inbox", <<EOF.gsub(/\n/, "\r\n"), [:Seen], Time.now) Subject: hello From: shugo@ruby-lang.org To: shugo@ruby-lang.org hello world EOF
Sends a CHECK command to request a checkpoint of the currently selected mailbox.
Sends a CLOSE command to close the currently selected mailbox. The CLOSE command permanently removes from the mailbox all messages that have the \Deleted flag set.
Sends a EXPUNGE command to permanently remove from the currently selected mailbox all messages that have the \Deleted flag set.
Sends a SEARCH command to search the mailbox for messages that match the given searching criteria, and returns message sequence numbers (search) or unique identifiers (uid_search).
ex).
p imap.search(["SUBJECT", "hello"]) #=> [1, 6, 7, 8]
Sends a FETCH command to retrieve data associated with a message in the mailbox. the set parameter is a number or an array of numbers or a Range object. the number is a message sequence number (fetch) or a unique identifier (uid_fetch).
ex).
p imap.fetch(6..-1, "UID") #=> [[6, {"UID"=>28}], [7, {"UID"=>29}], [8, {"UID"=>30}]]
Sends a STORE command to alter data associated with a message in the mailbox. the set parameter is a number or an array of numbers or a Range object. the number is a message sequence number (fetch) or a unique identifier (uid_fetch).
ex).
p imap.store(6..-1, "+FLAGS", [:Deleted]) #=> [[6, {"FLAGS"=>[:Deleted]}], [7, {"FLAGS"=>[:Seen, :Deleted]}], [8, {"FLAGS"=>[:Seen, :Deleted]}]]
Sends a COPY command to copy the specified message(s) to the end of the specified destination mailbox. the set parameter is a number or an array of numbers or a Range object. the number is a message sequence number (fetch) or a unique identifier (uid_fetch).
Sends a SORT command to sort messages in the mailbox.
ex).
p imap.sort(["FROM"], ["ALL"], "US-ASCII") #=> [1, 2, 3, 5, 6, 7, 8, 4, 9] p imap.sort(["DATE"], ["SUBJECT", "hello"], "US-ASCII") #=> [6, 7, 8, 1]