Changes the (remote) directory.
Returns the status (STAT command). pathname - when stat is invoked with pathname as a parameter it acts like
list but alot faster and over the same tcp session.
Sends an AUTHENTICATE command to authenticate the client. The auth_type
parameter is a string that represents the authentication mechanism to be used. Currently Net::IMAP
supports the authentication mechanisms:
LOGIN:: login using cleartext user and password. CRAM-MD5:: login with cleartext user and encrypted password (see [RFC-2195] for a full description). This mechanism requires that the server have the user's password stored in clear-text password.
For both of these mechanisms, there should be two args
: username and (cleartext) password. A server may not support one or the other of these mechanisms; check capability()
for a capability of the form “AUTH=LOGIN” or “AUTH=CRAM-MD5”.
Authentication is done using the appropriate authenticator object: see @@authenticators for more information on plugging in your own authenticator.
For example:
imap.authenticate('LOGIN', user, password)
A Net::IMAP::NoResponseError
is raised if authentication fails.
Sends a CREATE command to create a new mailbox
.
A Net::IMAP::NoResponseError
is raised if a mailbox with that name cannot be created.
Sends a STATUS command, and returns the status of the indicated mailbox
. attr
is a list of one or more attributes whose statuses are to be requested. Supported attributes include:
MESSAGES:: the number of messages in the mailbox. RECENT:: the number of recent messages in the mailbox. UNSEEN:: the number of unseen messages in the mailbox.
The return value is a hash of attributes. For example:
p imap.status("inbox", ["MESSAGES", "RECENT"]) #=> {"RECENT"=>0, "MESSAGES"=>44}
A Net::IMAP::NoResponseError
is raised if status values for mailbox
cannot be returned; for instance, because it does not exist.
Sends a CHECK command to request a checkpoint of the currently selected mailbox. This performs implementation-specific housekeeping; for instance, reconciling the mailbox’s in-memory and on-disk state.
Sends a SEARCH command to search the mailbox for messages that match the given searching criteria, and returns message sequence numbers. keys
can either be a string holding the entire search string, or a single-dimension array of search keywords and arguments. The following are some common search criteria; see [IMAP] section 6.4.4 for a full list.
a set of message sequence numbers. ‘,’ indicates an interval, ‘:’ indicates a range. For instance, ‘2,10:12,15’ means “2,10,11,12,15”.
messages with an internal date strictly before <date>. The date argument has a format similar to 8-Aug-2002.
messages that contain <string> within their body.
messages containing <string> in their CC field.
messages that contain <string> in their FROM field.
messages with the Recent, but not the Seen, flag set.
negate the following search key.
“or” two search keys together.
messages with an internal date exactly equal to <date>, which has a format similar to 8-Aug-2002.
messages with an internal date on or after <date>.
messages with <string> in their subject.
messages with <string> in their TO field.
For example:
p imap.search(["SUBJECT", "hello", "NOT", "NEW"]) #=> [1, 6, 7, 8]
Starts a POP3
session and iterates over each POPMail
object, yielding it to the block
. This method is equivalent to:
Net::POP3.start(address, port, account, password) do |pop| pop.each_mail do |m| yield m end end
This method raises a POPAuthenticationError
if authentication fails.
Net::POP3.foreach('pop.example.com', 110, 'YourAccount', 'YourPassword') do |m| file.write m.pop m.delete if $DELETE end
Returns the number of messages on the POP server.
Returns an array of Net::POPMail
objects, representing all the messages on the server. This array is renewed when the session restarts; otherwise, it is fetched from the server the first time this method is called (directly or indirectly) and cached.
This method raises a POPError
if an error occurs.
This method sends a message. If msgstr
is given, sends it as a message. If block is given, yield a message writer stream. You must write message before the block is closed.
# Example 1 (by string) smtp.data(<<EndMessage) From: john@example.com To: betty@example.com Subject: I found a bug Check vm.c:58879. EndMessage # Example 2 (by block) smtp.data {|f| f.puts "From: john@example.com" f.puts "To: betty@example.com" f.puts "Subject: I found a bug" f.puts "" f.puts "Check vm.c:58879." }
Returns the path from an FTP
URI
.
RFC 1738 specifically states that the path for an FTP
URI
does not include the / which separates the URI
path from the URI
host. Example:
ftp://ftp.example.com/pub/ruby
The above URI
indicates that the client should connect to ftp.example.com then cd pub/ruby from the initial login directory.
If you want to cd to an absolute directory, you must include an escaped / (%2F) in the path. Example:
ftp://ftp.example.com/%2Fpub/ruby
This method will then return “/pub/ruby”
Produces the summary text. Each line of the summary is yielded to the block (without newline).
sdone
Already summarized short style options keyed hash.
ldone
Already summarized long style options keyed hash.
width
Width of left side (option part). In other words, the right side (description part) starts after width
columns.
max
Maximum width of left side -> the options are filled within max
columns.
indent
Prefix string indents all summarized lines.
Adds sw
according to sopts
, lopts
and nlopts
.
sw
OptionParser::Switch
instance to be added.
sopts
Short style option list.
lopts
Long style option list.
nlopts
Negated long style options list.
Searches key
in id
list. The result is returned or yielded if a block is given. If it isn’t found, nil is returned.
Creates the summary table, passing each line to the block
(without newline). The arguments args
are passed along to the summarize method which is called on every option.
Iterates the given block for each prime number.
Returns the cached prime numbers.