Edit File by line
/home/barbar84/public_h.../wp-conte.../plugins/sujqvwi/AnonR/anonr.TX.../opt/alt/ruby27/share/ruby/net
File: imap.rb
# frozen_string_literal: true
[0] Fix | Delete
#
[1] Fix | Delete
# = net/imap.rb
[2] Fix | Delete
#
[3] Fix | Delete
# Copyright (C) 2000 Shugo Maeda <shugo@ruby-lang.org>
[4] Fix | Delete
#
[5] Fix | Delete
# This library is distributed under the terms of the Ruby license.
[6] Fix | Delete
# You can freely distribute/modify this library.
[7] Fix | Delete
#
[8] Fix | Delete
# Documentation: Shugo Maeda, with RDoc conversion and overview by William
[9] Fix | Delete
# Webber.
[10] Fix | Delete
#
[11] Fix | Delete
# See Net::IMAP for documentation.
[12] Fix | Delete
#
[13] Fix | Delete
[14] Fix | Delete
[15] Fix | Delete
require "socket"
[16] Fix | Delete
require "monitor"
[17] Fix | Delete
require "digest/md5"
[18] Fix | Delete
require "strscan"
[19] Fix | Delete
require_relative 'protocol'
[20] Fix | Delete
begin
[21] Fix | Delete
require "openssl"
[22] Fix | Delete
rescue LoadError
[23] Fix | Delete
end
[24] Fix | Delete
[25] Fix | Delete
module Net
[26] Fix | Delete
[27] Fix | Delete
#
[28] Fix | Delete
# Net::IMAP implements Internet Message Access Protocol (IMAP) client
[29] Fix | Delete
# functionality. The protocol is described in [IMAP].
[30] Fix | Delete
#
[31] Fix | Delete
# == IMAP Overview
[32] Fix | Delete
#
[33] Fix | Delete
# An IMAP client connects to a server, and then authenticates
[34] Fix | Delete
# itself using either #authenticate() or #login(). Having
[35] Fix | Delete
# authenticated itself, there is a range of commands
[36] Fix | Delete
# available to it. Most work with mailboxes, which may be
[37] Fix | Delete
# arranged in an hierarchical namespace, and each of which
[38] Fix | Delete
# contains zero or more messages. How this is implemented on
[39] Fix | Delete
# the server is implementation-dependent; on a UNIX server, it
[40] Fix | Delete
# will frequently be implemented as files in mailbox format
[41] Fix | Delete
# within a hierarchy of directories.
[42] Fix | Delete
#
[43] Fix | Delete
# To work on the messages within a mailbox, the client must
[44] Fix | Delete
# first select that mailbox, using either #select() or (for
[45] Fix | Delete
# read-only access) #examine(). Once the client has successfully
[46] Fix | Delete
# selected a mailbox, they enter _selected_ state, and that
[47] Fix | Delete
# mailbox becomes the _current_ mailbox, on which mail-item
[48] Fix | Delete
# related commands implicitly operate.
[49] Fix | Delete
#
[50] Fix | Delete
# Messages have two sorts of identifiers: message sequence
[51] Fix | Delete
# numbers and UIDs.
[52] Fix | Delete
#
[53] Fix | Delete
# Message sequence numbers number messages within a mailbox
[54] Fix | Delete
# from 1 up to the number of items in the mailbox. If a new
[55] Fix | Delete
# message arrives during a session, it receives a sequence
[56] Fix | Delete
# number equal to the new size of the mailbox. If messages
[57] Fix | Delete
# are expunged from the mailbox, remaining messages have their
[58] Fix | Delete
# sequence numbers "shuffled down" to fill the gaps.
[59] Fix | Delete
#
[60] Fix | Delete
# UIDs, on the other hand, are permanently guaranteed not to
[61] Fix | Delete
# identify another message within the same mailbox, even if
[62] Fix | Delete
# the existing message is deleted. UIDs are required to
[63] Fix | Delete
# be assigned in ascending (but not necessarily sequential)
[64] Fix | Delete
# order within a mailbox; this means that if a non-IMAP client
[65] Fix | Delete
# rearranges the order of mailitems within a mailbox, the
[66] Fix | Delete
# UIDs have to be reassigned. An IMAP client thus cannot
[67] Fix | Delete
# rearrange message orders.
[68] Fix | Delete
#
[69] Fix | Delete
# == Examples of Usage
[70] Fix | Delete
#
[71] Fix | Delete
# === List sender and subject of all recent messages in the default mailbox
[72] Fix | Delete
#
[73] Fix | Delete
# imap = Net::IMAP.new('mail.example.com')
[74] Fix | Delete
# imap.authenticate('LOGIN', 'joe_user', 'joes_password')
[75] Fix | Delete
# imap.examine('INBOX')
[76] Fix | Delete
# imap.search(["RECENT"]).each do |message_id|
[77] Fix | Delete
# envelope = imap.fetch(message_id, "ENVELOPE")[0].attr["ENVELOPE"]
[78] Fix | Delete
# puts "#{envelope.from[0].name}: \t#{envelope.subject}"
[79] Fix | Delete
# end
[80] Fix | Delete
#
[81] Fix | Delete
# === Move all messages from April 2003 from "Mail/sent-mail" to "Mail/sent-apr03"
[82] Fix | Delete
#
[83] Fix | Delete
# imap = Net::IMAP.new('mail.example.com')
[84] Fix | Delete
# imap.authenticate('LOGIN', 'joe_user', 'joes_password')
[85] Fix | Delete
# imap.select('Mail/sent-mail')
[86] Fix | Delete
# if not imap.list('Mail/', 'sent-apr03')
[87] Fix | Delete
# imap.create('Mail/sent-apr03')
[88] Fix | Delete
# end
[89] Fix | Delete
# imap.search(["BEFORE", "30-Apr-2003", "SINCE", "1-Apr-2003"]).each do |message_id|
[90] Fix | Delete
# imap.copy(message_id, "Mail/sent-apr03")
[91] Fix | Delete
# imap.store(message_id, "+FLAGS", [:Deleted])
[92] Fix | Delete
# end
[93] Fix | Delete
# imap.expunge
[94] Fix | Delete
#
[95] Fix | Delete
# == Thread Safety
[96] Fix | Delete
#
[97] Fix | Delete
# Net::IMAP supports concurrent threads. For example,
[98] Fix | Delete
#
[99] Fix | Delete
# imap = Net::IMAP.new("imap.foo.net", "imap2")
[100] Fix | Delete
# imap.authenticate("cram-md5", "bar", "password")
[101] Fix | Delete
# imap.select("inbox")
[102] Fix | Delete
# fetch_thread = Thread.start { imap.fetch(1..-1, "UID") }
[103] Fix | Delete
# search_result = imap.search(["BODY", "hello"])
[104] Fix | Delete
# fetch_result = fetch_thread.value
[105] Fix | Delete
# imap.disconnect
[106] Fix | Delete
#
[107] Fix | Delete
# This script invokes the FETCH command and the SEARCH command concurrently.
[108] Fix | Delete
#
[109] Fix | Delete
# == Errors
[110] Fix | Delete
#
[111] Fix | Delete
# An IMAP server can send three different types of responses to indicate
[112] Fix | Delete
# failure:
[113] Fix | Delete
#
[114] Fix | Delete
# NO:: the attempted command could not be successfully completed. For
[115] Fix | Delete
# instance, the username/password used for logging in are incorrect;
[116] Fix | Delete
# the selected mailbox does not exist; etc.
[117] Fix | Delete
#
[118] Fix | Delete
# BAD:: the request from the client does not follow the server's
[119] Fix | Delete
# understanding of the IMAP protocol. This includes attempting
[120] Fix | Delete
# commands from the wrong client state; for instance, attempting
[121] Fix | Delete
# to perform a SEARCH command without having SELECTed a current
[122] Fix | Delete
# mailbox. It can also signal an internal server
[123] Fix | Delete
# failure (such as a disk crash) has occurred.
[124] Fix | Delete
#
[125] Fix | Delete
# BYE:: the server is saying goodbye. This can be part of a normal
[126] Fix | Delete
# logout sequence, and can be used as part of a login sequence
[127] Fix | Delete
# to indicate that the server is (for some reason) unwilling
[128] Fix | Delete
# to accept your connection. As a response to any other command,
[129] Fix | Delete
# it indicates either that the server is shutting down, or that
[130] Fix | Delete
# the server is timing out the client connection due to inactivity.
[131] Fix | Delete
#
[132] Fix | Delete
# These three error response are represented by the errors
[133] Fix | Delete
# Net::IMAP::NoResponseError, Net::IMAP::BadResponseError, and
[134] Fix | Delete
# Net::IMAP::ByeResponseError, all of which are subclasses of
[135] Fix | Delete
# Net::IMAP::ResponseError. Essentially, all methods that involve
[136] Fix | Delete
# sending a request to the server can generate one of these errors.
[137] Fix | Delete
# Only the most pertinent instances have been documented below.
[138] Fix | Delete
#
[139] Fix | Delete
# Because the IMAP class uses Sockets for communication, its methods
[140] Fix | Delete
# are also susceptible to the various errors that can occur when
[141] Fix | Delete
# working with sockets. These are generally represented as
[142] Fix | Delete
# Errno errors. For instance, any method that involves sending a
[143] Fix | Delete
# request to the server and/or receiving a response from it could
[144] Fix | Delete
# raise an Errno::EPIPE error if the network connection unexpectedly
[145] Fix | Delete
# goes down. See the socket(7), ip(7), tcp(7), socket(2), connect(2),
[146] Fix | Delete
# and associated man pages.
[147] Fix | Delete
#
[148] Fix | Delete
# Finally, a Net::IMAP::DataFormatError is thrown if low-level data
[149] Fix | Delete
# is found to be in an incorrect format (for instance, when converting
[150] Fix | Delete
# between UTF-8 and UTF-16), and Net::IMAP::ResponseParseError is
[151] Fix | Delete
# thrown if a server response is non-parseable.
[152] Fix | Delete
#
[153] Fix | Delete
#
[154] Fix | Delete
# == References
[155] Fix | Delete
#
[156] Fix | Delete
# [[IMAP]]
[157] Fix | Delete
# M. Crispin, "INTERNET MESSAGE ACCESS PROTOCOL - VERSION 4rev1",
[158] Fix | Delete
# RFC 2060, December 1996. (Note: since obsoleted by RFC 3501)
[159] Fix | Delete
#
[160] Fix | Delete
# [[LANGUAGE-TAGS]]
[161] Fix | Delete
# Alvestrand, H., "Tags for the Identification of
[162] Fix | Delete
# Languages", RFC 1766, March 1995.
[163] Fix | Delete
#
[164] Fix | Delete
# [[MD5]]
[165] Fix | Delete
# Myers, J., and M. Rose, "The Content-MD5 Header Field", RFC
[166] Fix | Delete
# 1864, October 1995.
[167] Fix | Delete
#
[168] Fix | Delete
# [[MIME-IMB]]
[169] Fix | Delete
# Freed, N., and N. Borenstein, "MIME (Multipurpose Internet
[170] Fix | Delete
# Mail Extensions) Part One: Format of Internet Message Bodies", RFC
[171] Fix | Delete
# 2045, November 1996.
[172] Fix | Delete
#
[173] Fix | Delete
# [[RFC-822]]
[174] Fix | Delete
# Crocker, D., "Standard for the Format of ARPA Internet Text
[175] Fix | Delete
# Messages", STD 11, RFC 822, University of Delaware, August 1982.
[176] Fix | Delete
#
[177] Fix | Delete
# [[RFC-2087]]
[178] Fix | Delete
# Myers, J., "IMAP4 QUOTA extension", RFC 2087, January 1997.
[179] Fix | Delete
#
[180] Fix | Delete
# [[RFC-2086]]
[181] Fix | Delete
# Myers, J., "IMAP4 ACL extension", RFC 2086, January 1997.
[182] Fix | Delete
#
[183] Fix | Delete
# [[RFC-2195]]
[184] Fix | Delete
# Klensin, J., Catoe, R., and Krumviede, P., "IMAP/POP AUTHorize Extension
[185] Fix | Delete
# for Simple Challenge/Response", RFC 2195, September 1997.
[186] Fix | Delete
#
[187] Fix | Delete
# [[SORT-THREAD-EXT]]
[188] Fix | Delete
# Crispin, M., "INTERNET MESSAGE ACCESS PROTOCOL - SORT and THREAD
[189] Fix | Delete
# Extensions", draft-ietf-imapext-sort, May 2003.
[190] Fix | Delete
#
[191] Fix | Delete
# [[OSSL]]
[192] Fix | Delete
# http://www.openssl.org
[193] Fix | Delete
#
[194] Fix | Delete
# [[RSSL]]
[195] Fix | Delete
# http://savannah.gnu.org/projects/rubypki
[196] Fix | Delete
#
[197] Fix | Delete
# [[UTF7]]
[198] Fix | Delete
# Goldsmith, D. and Davis, M., "UTF-7: A Mail-Safe Transformation Format of
[199] Fix | Delete
# Unicode", RFC 2152, May 1997.
[200] Fix | Delete
#
[201] Fix | Delete
class IMAP < Protocol
[202] Fix | Delete
include MonitorMixin
[203] Fix | Delete
if defined?(OpenSSL::SSL)
[204] Fix | Delete
include OpenSSL
[205] Fix | Delete
include SSL
[206] Fix | Delete
end
[207] Fix | Delete
[208] Fix | Delete
# Returns an initial greeting response from the server.
[209] Fix | Delete
attr_reader :greeting
[210] Fix | Delete
[211] Fix | Delete
# Returns recorded untagged responses. For example:
[212] Fix | Delete
#
[213] Fix | Delete
# imap.select("inbox")
[214] Fix | Delete
# p imap.responses["EXISTS"][-1]
[215] Fix | Delete
# #=> 2
[216] Fix | Delete
# p imap.responses["UIDVALIDITY"][-1]
[217] Fix | Delete
# #=> 968263756
[218] Fix | Delete
attr_reader :responses
[219] Fix | Delete
[220] Fix | Delete
# Returns all response handlers.
[221] Fix | Delete
attr_reader :response_handlers
[222] Fix | Delete
[223] Fix | Delete
# Seconds to wait until a connection is opened.
[224] Fix | Delete
# If the IMAP object cannot open a connection within this time,
[225] Fix | Delete
# it raises a Net::OpenTimeout exception. The default value is 30 seconds.
[226] Fix | Delete
attr_reader :open_timeout
[227] Fix | Delete
[228] Fix | Delete
# The thread to receive exceptions.
[229] Fix | Delete
attr_accessor :client_thread
[230] Fix | Delete
[231] Fix | Delete
# Flag indicating a message has been seen.
[232] Fix | Delete
SEEN = :Seen
[233] Fix | Delete
[234] Fix | Delete
# Flag indicating a message has been answered.
[235] Fix | Delete
ANSWERED = :Answered
[236] Fix | Delete
[237] Fix | Delete
# Flag indicating a message has been flagged for special or urgent
[238] Fix | Delete
# attention.
[239] Fix | Delete
FLAGGED = :Flagged
[240] Fix | Delete
[241] Fix | Delete
# Flag indicating a message has been marked for deletion. This
[242] Fix | Delete
# will occur when the mailbox is closed or expunged.
[243] Fix | Delete
DELETED = :Deleted
[244] Fix | Delete
[245] Fix | Delete
# Flag indicating a message is only a draft or work-in-progress version.
[246] Fix | Delete
DRAFT = :Draft
[247] Fix | Delete
[248] Fix | Delete
# Flag indicating that the message is "recent," meaning that this
[249] Fix | Delete
# session is the first session in which the client has been notified
[250] Fix | Delete
# of this message.
[251] Fix | Delete
RECENT = :Recent
[252] Fix | Delete
[253] Fix | Delete
# Flag indicating that a mailbox context name cannot contain
[254] Fix | Delete
# children.
[255] Fix | Delete
NOINFERIORS = :Noinferiors
[256] Fix | Delete
[257] Fix | Delete
# Flag indicating that a mailbox is not selected.
[258] Fix | Delete
NOSELECT = :Noselect
[259] Fix | Delete
[260] Fix | Delete
# Flag indicating that a mailbox has been marked "interesting" by
[261] Fix | Delete
# the server; this commonly indicates that the mailbox contains
[262] Fix | Delete
# new messages.
[263] Fix | Delete
MARKED = :Marked
[264] Fix | Delete
[265] Fix | Delete
# Flag indicating that the mailbox does not contains new messages.
[266] Fix | Delete
UNMARKED = :Unmarked
[267] Fix | Delete
[268] Fix | Delete
# Returns the debug mode.
[269] Fix | Delete
def self.debug
[270] Fix | Delete
return @@debug
[271] Fix | Delete
end
[272] Fix | Delete
[273] Fix | Delete
# Sets the debug mode.
[274] Fix | Delete
def self.debug=(val)
[275] Fix | Delete
return @@debug = val
[276] Fix | Delete
end
[277] Fix | Delete
[278] Fix | Delete
# Returns the max number of flags interned to symbols.
[279] Fix | Delete
def self.max_flag_count
[280] Fix | Delete
return @@max_flag_count
[281] Fix | Delete
end
[282] Fix | Delete
[283] Fix | Delete
# Sets the max number of flags interned to symbols.
[284] Fix | Delete
def self.max_flag_count=(count)
[285] Fix | Delete
@@max_flag_count = count
[286] Fix | Delete
end
[287] Fix | Delete
[288] Fix | Delete
# Adds an authenticator for Net::IMAP#authenticate. +auth_type+
[289] Fix | Delete
# is the type of authentication this authenticator supports
[290] Fix | Delete
# (for instance, "LOGIN"). The +authenticator+ is an object
[291] Fix | Delete
# which defines a process() method to handle authentication with
[292] Fix | Delete
# the server. See Net::IMAP::LoginAuthenticator,
[293] Fix | Delete
# Net::IMAP::CramMD5Authenticator, and Net::IMAP::DigestMD5Authenticator
[294] Fix | Delete
# for examples.
[295] Fix | Delete
#
[296] Fix | Delete
#
[297] Fix | Delete
# If +auth_type+ refers to an existing authenticator, it will be
[298] Fix | Delete
# replaced by the new one.
[299] Fix | Delete
def self.add_authenticator(auth_type, authenticator)
[300] Fix | Delete
@@authenticators[auth_type] = authenticator
[301] Fix | Delete
end
[302] Fix | Delete
[303] Fix | Delete
# The default port for IMAP connections, port 143
[304] Fix | Delete
def self.default_port
[305] Fix | Delete
return PORT
[306] Fix | Delete
end
[307] Fix | Delete
[308] Fix | Delete
# The default port for IMAPS connections, port 993
[309] Fix | Delete
def self.default_tls_port
[310] Fix | Delete
return SSL_PORT
[311] Fix | Delete
end
[312] Fix | Delete
[313] Fix | Delete
class << self
[314] Fix | Delete
alias default_imap_port default_port
[315] Fix | Delete
alias default_imaps_port default_tls_port
[316] Fix | Delete
alias default_ssl_port default_tls_port
[317] Fix | Delete
end
[318] Fix | Delete
[319] Fix | Delete
# Disconnects from the server.
[320] Fix | Delete
def disconnect
[321] Fix | Delete
return if disconnected?
[322] Fix | Delete
begin
[323] Fix | Delete
begin
[324] Fix | Delete
# try to call SSL::SSLSocket#io.
[325] Fix | Delete
@sock.io.shutdown
[326] Fix | Delete
rescue NoMethodError
[327] Fix | Delete
# @sock is not an SSL::SSLSocket.
[328] Fix | Delete
@sock.shutdown
[329] Fix | Delete
end
[330] Fix | Delete
rescue Errno::ENOTCONN
[331] Fix | Delete
# ignore `Errno::ENOTCONN: Socket is not connected' on some platforms.
[332] Fix | Delete
rescue Exception => e
[333] Fix | Delete
@receiver_thread.raise(e)
[334] Fix | Delete
end
[335] Fix | Delete
@receiver_thread.join
[336] Fix | Delete
synchronize do
[337] Fix | Delete
@sock.close
[338] Fix | Delete
end
[339] Fix | Delete
raise e if e
[340] Fix | Delete
end
[341] Fix | Delete
[342] Fix | Delete
# Returns true if disconnected from the server.
[343] Fix | Delete
def disconnected?
[344] Fix | Delete
return @sock.closed?
[345] Fix | Delete
end
[346] Fix | Delete
[347] Fix | Delete
# Sends a CAPABILITY command, and returns an array of
[348] Fix | Delete
# capabilities that the server supports. Each capability
[349] Fix | Delete
# is a string. See [IMAP] for a list of possible
[350] Fix | Delete
# capabilities.
[351] Fix | Delete
#
[352] Fix | Delete
# Note that the Net::IMAP class does not modify its
[353] Fix | Delete
# behaviour according to the capabilities of the server;
[354] Fix | Delete
# it is up to the user of the class to ensure that
[355] Fix | Delete
# a certain capability is supported by a server before
[356] Fix | Delete
# using it.
[357] Fix | Delete
def capability
[358] Fix | Delete
synchronize do
[359] Fix | Delete
send_command("CAPABILITY")
[360] Fix | Delete
return @responses.delete("CAPABILITY")[-1]
[361] Fix | Delete
end
[362] Fix | Delete
end
[363] Fix | Delete
[364] Fix | Delete
# Sends a NOOP command to the server. It does nothing.
[365] Fix | Delete
def noop
[366] Fix | Delete
send_command("NOOP")
[367] Fix | Delete
end
[368] Fix | Delete
[369] Fix | Delete
# Sends a LOGOUT command to inform the server that the client is
[370] Fix | Delete
# done with the connection.
[371] Fix | Delete
def logout
[372] Fix | Delete
send_command("LOGOUT")
[373] Fix | Delete
end
[374] Fix | Delete
[375] Fix | Delete
# Sends a STARTTLS command to start TLS session.
[376] Fix | Delete
def starttls(options = {}, verify = true)
[377] Fix | Delete
send_command("STARTTLS") do |resp|
[378] Fix | Delete
if resp.kind_of?(TaggedResponse) && resp.name == "OK"
[379] Fix | Delete
begin
[380] Fix | Delete
# for backward compatibility
[381] Fix | Delete
certs = options.to_str
[382] Fix | Delete
options = create_ssl_params(certs, verify)
[383] Fix | Delete
rescue NoMethodError
[384] Fix | Delete
end
[385] Fix | Delete
start_tls_session(options)
[386] Fix | Delete
end
[387] Fix | Delete
end
[388] Fix | Delete
end
[389] Fix | Delete
[390] Fix | Delete
# Sends an AUTHENTICATE command to authenticate the client.
[391] Fix | Delete
# The +auth_type+ parameter is a string that represents
[392] Fix | Delete
# the authentication mechanism to be used. Currently Net::IMAP
[393] Fix | Delete
# supports the authentication mechanisms:
[394] Fix | Delete
#
[395] Fix | Delete
# LOGIN:: login using cleartext user and password.
[396] Fix | Delete
# CRAM-MD5:: login with cleartext user and encrypted password
[397] Fix | Delete
# (see [RFC-2195] for a full description). This
[398] Fix | Delete
# mechanism requires that the server have the user's
[399] Fix | Delete
# password stored in clear-text password.
[400] Fix | Delete
#
[401] Fix | Delete
# For both of these mechanisms, there should be two +args+: username
[402] Fix | Delete
# and (cleartext) password. A server may not support one or the other
[403] Fix | Delete
# of these mechanisms; check #capability() for a capability of
[404] Fix | Delete
# the form "AUTH=LOGIN" or "AUTH=CRAM-MD5".
[405] Fix | Delete
#
[406] Fix | Delete
# Authentication is done using the appropriate authenticator object:
[407] Fix | Delete
# see @@authenticators for more information on plugging in your own
[408] Fix | Delete
# authenticator.
[409] Fix | Delete
#
[410] Fix | Delete
# For example:
[411] Fix | Delete
#
[412] Fix | Delete
# imap.authenticate('LOGIN', user, password)
[413] Fix | Delete
#
[414] Fix | Delete
# A Net::IMAP::NoResponseError is raised if authentication fails.
[415] Fix | Delete
def authenticate(auth_type, *args)
[416] Fix | Delete
auth_type = auth_type.upcase
[417] Fix | Delete
unless @@authenticators.has_key?(auth_type)
[418] Fix | Delete
raise ArgumentError,
[419] Fix | Delete
format('unknown auth type - "%s"', auth_type)
[420] Fix | Delete
end
[421] Fix | Delete
authenticator = @@authenticators[auth_type].new(*args)
[422] Fix | Delete
send_command("AUTHENTICATE", auth_type) do |resp|
[423] Fix | Delete
if resp.instance_of?(ContinuationRequest)
[424] Fix | Delete
data = authenticator.process(resp.data.text.unpack("m")[0])
[425] Fix | Delete
s = [data].pack("m0")
[426] Fix | Delete
send_string_data(s)
[427] Fix | Delete
put_string(CRLF)
[428] Fix | Delete
end
[429] Fix | Delete
end
[430] Fix | Delete
end
[431] Fix | Delete
[432] Fix | Delete
# Sends a LOGIN command to identify the client and carries
[433] Fix | Delete
# the plaintext +password+ authenticating this +user+. Note
[434] Fix | Delete
# that, unlike calling #authenticate() with an +auth_type+
[435] Fix | Delete
# of "LOGIN", #login() does *not* use the login authenticator.
[436] Fix | Delete
#
[437] Fix | Delete
# A Net::IMAP::NoResponseError is raised if authentication fails.
[438] Fix | Delete
def login(user, password)
[439] Fix | Delete
send_command("LOGIN", user, password)
[440] Fix | Delete
end
[441] Fix | Delete
[442] Fix | Delete
# Sends a SELECT command to select a +mailbox+ so that messages
[443] Fix | Delete
# in the +mailbox+ can be accessed.
[444] Fix | Delete
#
[445] Fix | Delete
# After you have selected a mailbox, you may retrieve the
[446] Fix | Delete
# number of items in that mailbox from @responses["EXISTS"][-1],
[447] Fix | Delete
# and the number of recent messages from @responses["RECENT"][-1].
[448] Fix | Delete
# Note that these values can change if new messages arrive
[449] Fix | Delete
# during a session; see #add_response_handler() for a way of
[450] Fix | Delete
# detecting this event.
[451] Fix | Delete
#
[452] Fix | Delete
# A Net::IMAP::NoResponseError is raised if the mailbox does not
[453] Fix | Delete
# exist or is for some reason non-selectable.
[454] Fix | Delete
def select(mailbox)
[455] Fix | Delete
synchronize do
[456] Fix | Delete
@responses.clear
[457] Fix | Delete
send_command("SELECT", mailbox)
[458] Fix | Delete
end
[459] Fix | Delete
end
[460] Fix | Delete
[461] Fix | Delete
# Sends a EXAMINE command to select a +mailbox+ so that messages
[462] Fix | Delete
# in the +mailbox+ can be accessed. Behaves the same as #select(),
[463] Fix | Delete
# except that the selected +mailbox+ is identified as read-only.
[464] Fix | Delete
#
[465] Fix | Delete
# A Net::IMAP::NoResponseError is raised if the mailbox does not
[466] Fix | Delete
# exist or is for some reason non-examinable.
[467] Fix | Delete
def examine(mailbox)
[468] Fix | Delete
synchronize do
[469] Fix | Delete
@responses.clear
[470] Fix | Delete
send_command("EXAMINE", mailbox)
[471] Fix | Delete
end
[472] Fix | Delete
end
[473] Fix | Delete
[474] Fix | Delete
# Sends a CREATE command to create a new +mailbox+.
[475] Fix | Delete
#
[476] Fix | Delete
# A Net::IMAP::NoResponseError is raised if a mailbox with that name
[477] Fix | Delete
# cannot be created.
[478] Fix | Delete
def create(mailbox)
[479] Fix | Delete
send_command("CREATE", mailbox)
[480] Fix | Delete
end
[481] Fix | Delete
[482] Fix | Delete
# Sends a DELETE command to remove the +mailbox+.
[483] Fix | Delete
#
[484] Fix | Delete
# A Net::IMAP::NoResponseError is raised if a mailbox with that name
[485] Fix | Delete
# cannot be deleted, either because it does not exist or because the
[486] Fix | Delete
# client does not have permission to delete it.
[487] Fix | Delete
def delete(mailbox)
[488] Fix | Delete
send_command("DELETE", mailbox)
[489] Fix | Delete
end
[490] Fix | Delete
[491] Fix | Delete
# Sends a RENAME command to change the name of the +mailbox+ to
[492] Fix | Delete
# +newname+.
[493] Fix | Delete
#
[494] Fix | Delete
# A Net::IMAP::NoResponseError is raised if a mailbox with the
[495] Fix | Delete
# name +mailbox+ cannot be renamed to +newname+ for whatever
[496] Fix | Delete
# reason; for instance, because +mailbox+ does not exist, or
[497] Fix | Delete
# because there is already a mailbox with the name +newname+.
[498] Fix | Delete
def rename(mailbox, newname)
[499] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function