Library imap
A library implementing a minor subset of the IMAP protocol, currently the CAPABILITY, LOGIN and AUTHENTICATE functions. The library was initially written by Brandon Enright and later extended and converted to OO-form by Patrik Karlsson <patrik@cqure.net>
The library consists of a Helper
, class which is the main
interface for script writers, and the IMAP
class providing
all protocol-level functionality.
The following example illustrates the recommended use of the library:
local helper = imap.Helper:new(host, port) helper:connect() helper:login("user","password","PLAIN") helper:close()
Authors:
Copyright © Same as Nmap--See https://nmap.org/book/man-legal.html
Source: https://svn.nmap.org/nmap/nselib/imap.lua
Functions
- authenticate (self, username, pass, mech)
Authenticate to the server (non PLAIN text mode) Currently supported algorithms are CRAM-MD5 and CRAM-SHA1
- capabilities (self)
Retrieves a list of server capabilities (eg. supported authentication mechanisms, QUOTA, UIDPLUS, ACL ...)
- capabilities (self)
Retrieves a list of server capabilities (eg. supported authentication mechanisms, QUOTA, UIDPLUS, ACL ...)
- close (self)
Closes the connection to the IMAP server
- close (self)
Closes the connection to the IMAP server
- connect (self)
Connects to the IMAP server
- connect (self)
Connects to the IMAP server
- login (self, username, password, mech)
Login to the server using either plain-text or using the authentication mechanism provided in the mech argument.
- login (self, username, password, mech)
Login to the server using either plain-text or using the authentication mechanism provided in the mech argument.
- new (self, host, port, options)
Creates a new instance of the IMAP class
- receive (self)
Receives a response from the IMAP server
- send (self, cmd, params)
Sends a request to the IMAP server
Functions
- authenticate (self, username, pass, mech)
-
Authenticate to the server (non PLAIN text mode) Currently supported algorithms are CRAM-MD5 and CRAM-SHA1
Parameters
- self
- username
- string containing the username
- pass
- string containing the password
- mech
- string containing a authentication mechanism, currently CRAM-MD5 or CRAM-SHA1
Return values:
- status true if login was successful, false on failure
- err string containing the error message if status was false
- capabilities (self)
-
Retrieves a list of server capabilities (eg. supported authentication mechanisms, QUOTA, UIDPLUS, ACL ...)
Parameters
- self
Return values:
- status true on success, false on failure
- capas array containing the capabilities that are supported
- capabilities (self)
-
Retrieves a list of server capabilities (eg. supported authentication mechanisms, QUOTA, UIDPLUS, ACL ...)
Parameters
- self
Return values:
- status true on success, false on failure
- capas array containing the capabilities that are supported
- close (self)
-
Closes the connection to the IMAP server
Parameters
- self
Return value:
true on success, false on failure - close (self)
-
Closes the connection to the IMAP server
Parameters
- self
Return value:
true on success, false on failure - connect (self)
-
Connects to the IMAP server
Parameters
- self
Return value:
status true on success, false on failure - connect (self)
-
Connects to the IMAP server
Parameters
- self
Return value:
status true on success, false on failure - login (self, username, password, mech)
-
Login to the server using either plain-text or using the authentication mechanism provided in the mech argument.
Parameters
- self
- username
- string containing the username
- password
- string containing the password
- mech
- [optional] containing the authentication mechanism to use
Return value:
status true on success, false on failure - login (self, username, password, mech)
-
Login to the server using either plain-text or using the authentication mechanism provided in the mech argument.
Parameters
- self
- username
- string containing the username
- password
- string containing the password
- mech
- [optional] containing the authentication mechanism to use
Return value:
status true on success, false on failure - new (self, host, port, options)
-
Creates a new instance of the IMAP class
Parameters
- self
- host
- table as received by the script action method
- port
- table as received by the script action method
- options
- table containing options, currently <code>timeout<code> - number containing the seconds to wait for a response
- receive (self)
-
Receives a response from the IMAP server
Parameters
- self
Return values:
- status true on success, false on failure
- data string containing the received data
- send (self, cmd, params)
-
Sends a request to the IMAP server
Parameters
- self
- cmd
- string containing the command to send to the server eg. eg. (AUTHENTICATE, LOGIN)
- params
- string containing the command parameters
Return values:
- true on success, false on failure
- err string containing the error if status was false