Name
Net::IMAP — IMAP access class
Synopsis
Net::IMAP
is a class
for Internet Message Access Protocol Version 4 (IMAP4) client-side
connection. IMAP4 allows you to store and manage messages in the
server side.
Required Library
require “net/imap”
Example
require "net/imap" imap = Net::IMAP::new("imap.ruby-lang.org") imap.login("matz", "skwkgjv;") imap.select("inbox") fetch_result = imap.fetch(1..-1, "UID") search_result = imap.search(["BODY", "hello"]) imap.disconnect
Class Methods
Net::IMAP::add_authenticator(
auth_type
,
authenticator
)
Adds an authenticator for
Net::IMAP#authenticate
.Net::IMAP::debug
Returns
true
if in the debug mode.Net::IMAP::debug=
bool
Sets the debug mode.
Net::IMAP::new(
host
[,
port
=143])
Creates a new
Net::IMAP
object and connects it to the specifiedport
on the namedhost
.
Instance Methods
-
imap
.append(
mailbox
,
message
[,
flags
[,
date_time
]])
Appends the
message
to the end of themailbox
.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
imap
.authenticate(
auth_type
,
arg...
)
Authenticates the client. The
auth_type
parameter is a string that represents the authentication mechanism to be used. CurrentlyNet::IMAP
supports"LOGIN"
and"CRAM-MD5"
for theauth_type
.imap.authenticate('CRAM-MD5", "matz", "crampass")
imap
.capability
Returns an array of capabilities that the server supports.
imap.capability # => ["IMAP4", "IMAP4REV1", "NAMESPACE", ...]
imap
.check
Requests a checkpoint ...
Get Ruby in a Nutshell now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.