|
IP*Works! V6 | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Object | +--ipworks.Pop
The POP bean is used retrieve electronic mail from Internet Post Office servers (POP).
The POP bean implements a standard internet post office (POP3) client as specified in RFC 1725.
To connect to a MailServer first set the
appropriate User and Password and then connect by calling the Connect method. Upon successful
connection to the MailServer , the number of waiting messages is shown
by the MessageCount property. A message is selected by setting the MessageNumber property to a number between 1 and MessageCount (inclusive). Then, message text and/or headers are received by calling the Retrieve method.
The message text is received through the Transfer event,
whereas the message headers are received through the Header event.
Additionally, up to MaxLines from the message body are provided
in the MessageText property. The
body of the message is also saved in the file specified by the LocalFile property. StartTransfer and EndTransfer events are fired at the
beginning and end of message transmission. The PITrail event provides a
trace of the interaction between the client and server (excluding message
transfers).
| Field Summary | |
static int |
amAPOP
|
static int |
amCRAMMD5
|
static int |
amUserPassword
|
static int |
fwNone
|
static int |
fwSOCKS4
|
static int |
fwSOCKS5
|
static int |
fwTunnel
|
| Constructor Summary | |
Pop()
|
|
| Method Summary | |
void |
addPopEventListener(PopEventListener l)
|
java.lang.String |
config(java.lang.String configurationString)
Sets or retrieves a beanconfiguration setting. |
void |
connect()
Connects to the mail server and attempts to login. |
void |
delete()
Delete a message specified by MessageNumber on the server. |
void |
disconnect()
Disconnects from the mail server. |
void |
doEvents()
Processes events from the internal message queue. |
int |
getAuthMechanism()
The authentication mechanism to be used when connecting to the mail server. |
java.lang.String |
getFirewallHost()
Name or IP address of firewall (optional). |
java.lang.String |
getFirewallPassword()
A password if authentication is to be used when connecting through the firewall. |
int |
getFirewallPort()
Port of the firewall to connect to. |
int |
getFirewallType()
Determines the type of firewall to connect through. |
java.lang.String |
getFirewallUser()
A user name if authentication is to be used connecting through a firewall. |
java.lang.String |
getLastReply()
The last reply from the server. |
java.lang.String |
getLocalFile()
The path to a local file for downloading the message body. |
java.lang.String |
getLocalHost()
The name of the local host or user-assigned IP interface through which connections are initiated or accepted. |
int |
getMailPort()
The server port for POP (default 110). |
java.lang.String |
getMailServer()
The name or address of a mail server (internet post office server). |
int |
getMaxLines()
The maximum number of message lines besides headers to retrieve. |
java.lang.String |
getMessageCc()
The value of the Cc header of the last retrieved message. |
int |
getMessageCount()
The number of messages waiting in the mailbox. |
java.lang.String |
getMessageDate()
The value of the Date: header of the last retrieved message. |
java.lang.String |
getMessageFrom()
The value of the From header of the last retrieved message. |
java.lang.String |
getMessageHeaders()
The full headers of the message as retrieved from the server. |
int |
getMessageNumber()
Current (selected) message. |
java.lang.String |
getMessageReplyTo()
The value of the Reply-To header of the last retrieved message. |
int |
getMessageSize()
The size in bytes of the current message. |
java.lang.String |
getMessageSubject()
The value of the Subject header of the last retrieved message. |
java.lang.String |
getMessageText()
The full text of the message as retrieved from the server. |
java.lang.String |
getMessageTo()
The value of the To header of the last retrieved message. |
java.lang.String |
getMessageUID()
The unique id of the message as specified by the server. |
java.lang.String |
getPassword()
The password for the mailbox user. |
int |
getTimeout()
A timeout for the bean. |
int |
getTotalSize()
Cumulative size in bytes of messages in the mailbox (including headers). |
java.lang.String |
getUser()
The user id for the mailbox. |
void |
interrupt()
Interrupt the current method. |
boolean |
isConnected()
Shows whether the bean is connected. |
boolean |
isIdle()
The current status of the component. |
void |
listMessageSizes()
Retrieves a list of all message sizes from the server. |
void |
listMessageUIDs()
Retrieves a list of all message UID-s from the server. |
java.lang.String |
localizeDate(java.lang.String dateTime)
Converts a valid RFC 822 message date to local date and time. |
void |
removePopEventListener(PopEventListener l)
|
void |
reset()
Reset all changes and revert back to the state when the user first connected. |
void |
retrieve()
Retrieve a message specified by MessageNumber from the server. |
void |
retrieveHeaders()
Retrieve headers for a message specified by MessageNumber . |
void |
setAuthMechanism(int authMechanism)
The authentication mechanism to be used when connecting to the mail server. |
void |
setCommand(java.lang.String command)
Can be used to send additional commands directly to the server. |
void |
setConnected(boolean connected)
Shows whether the bean is connected. |
void |
setFirewallHost(java.lang.String firewallHost)
Name or IP address of firewall (optional). |
void |
setFirewallPassword(java.lang.String firewallPassword)
A password if authentication is to be used when connecting through the firewall. |
void |
setFirewallPort(int firewallPort)
Port of the firewall to connect to. |
void |
setFirewallType(int firewallType)
Determines the type of firewall to connect through. |
void |
setFirewallUser(java.lang.String firewallUser)
A user name if authentication is to be used connecting through a firewall. |
void |
setLocalFile(java.lang.String localFile)
The path to a local file for downloading the message body. |
void |
setLocalHost(java.lang.String localHost)
The name of the local host or user-assigned IP interface through which connections are initiated or accepted. |
void |
setMailPort(int mailPort)
The server port for POP (default 110). |
void |
setMailServer(java.lang.String mailServer)
The name or address of a mail server (internet post office server). |
void |
setMaxLines(int maxLines)
The maximum number of message lines besides headers to retrieve. |
void |
setMessageNumber(int messageNumber)
Current (selected) message. |
void |
setPassword(java.lang.String password)
The password for the mailbox user. |
void |
setTimeout(int timeout)
A timeout for the bean. |
void |
setUser(java.lang.String user)
The user id for the mailbox. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
public static final int amUserPassword
public static final int amCRAMMD5
public static final int amAPOP
public static final int fwNone
public static final int fwTunnel
public static final int fwSOCKS4
public static final int fwSOCKS5
| Constructor Detail |
public Pop()
| Method Detail |
public int getAuthMechanism()
By default, AuthMechanism is amUserPassword (0), and default plaintext
authentication is used to login to the server. Other, more secure, options
include amCRAMMD5 (1) for CRAM-MD5, and amAPOP (2) for APOP authentication.
public void setAuthMechanism(int authMechanism)
throws IPWorksException
By default, AuthMechanism is amUserPassword (0), and default plaintext
authentication is used to login to the server. Other, more secure, options
include amCRAMMD5 (1) for CRAM-MD5, and amAPOP (2) for APOP authentication.
IPWorksException
public void setCommand(java.lang.String command)
throws IPWorksException
Check the LastReply property and/or trap the PITrail events
coming from the server to get the response.
IPWorksExceptionpublic boolean isConnected()
Use this property to determine whether the bean is connected to the remote host or not.
public void setConnected(boolean connected)
throws IPWorksException
Use this property to determine whether the bean is connected to the remote host or not.
IPWorksExceptionpublic java.lang.String getFirewallHost()
If a FirewallHost is given, requested connections will be
authenticated through the specified firewall when connecting.
If the FirewallHost property is set to a Domain Name, a DNS request
is initiated. Upon successful termination of the request, the FirewallHost property is set to the corresponding address. If the
search is not successful, an error is returned.
public void setFirewallHost(java.lang.String firewallHost)
throws IPWorksException
If a FirewallHost is given, requested connections will be
authenticated through the specified firewall when connecting.
If the FirewallHost property is set to a Domain Name, a DNS request
is initiated. Upon successful termination of the request, the FirewallHost property is set to the corresponding address. If the
search is not successful, an error is returned.
IPWorksExceptionpublic java.lang.String getFirewallPassword()
if FirewallHost is specified, the FirewallUser and FirewallPassword properties are used to connect and authenticate
to the given firewall. If the authentication fails, a trappable error is fired.
public void setFirewallPassword(java.lang.String firewallPassword)
throws IPWorksException
if FirewallHost is specified, the FirewallUser and FirewallPassword properties are used to connect and authenticate
to the given firewall. If the authentication fails, a trappable error is fired.
IPWorksExceptionpublic int getFirewallPort()
The TCP port for the FirewallHost . See the
description of the FirewallHost property for
details.
Note that the FirewallPort is set automatically
when FirewallType is set to a valid value. See the
description of the FirewallType property for
details.
public void setFirewallPort(int firewallPort)
throws IPWorksException
The TCP port for the FirewallHost . See the
description of the FirewallHost property for
details.
Note that the FirewallPort is set automatically
when FirewallType is set to a valid value. See the
description of the FirewallType property for
details.
IPWorksExceptionpublic int getFirewallType()
The applicable values are the following:
FirewallPort is set to 80.
FirewallPort is set to 1080.
FirewallPort is set to 1080.
public void setFirewallType(int firewallType)
throws IPWorksException
The applicable values are the following:
FirewallPort is set to 80.
FirewallPort is set to 1080.
FirewallPort is set to 1080.
IPWorksExceptionpublic java.lang.String getFirewallUser()
if FirewallHost is specified, the FirewallUser and FirewallPassword properties are used to connect and authenticate
to the given firewall. If the authentication fails, a trappable error is fired.
public void setFirewallUser(java.lang.String firewallUser)
throws IPWorksException
if FirewallHost is specified, the FirewallUser and FirewallPassword properties are used to connect and authenticate
to the given firewall. If the authentication fails, a trappable error is fired.
IPWorksExceptionpublic boolean isIdle()
Idle will be False if the component is currently busy (communicating
and/or waiting for an answer), and True at all other times.
public java.lang.String getLastReply()
This is the last reply received from the server. It
can be used for information purposes. The same information
and more can also be retrieved through the PITrail event.
public java.lang.String getLocalFile()
The LocalFile property is used when retrieving a message.
If LocalFile is empty then
the received data is provided through the parameters of the Transfer event
public void setLocalFile(java.lang.String localFile)
throws IPWorksException
The LocalFile property is used when retrieving a message.
If LocalFile is empty then
the received data is provided through the parameters of the Transfer event
IPWorksExceptionpublic java.lang.String getLocalHost()
The LocalHost property contains the name of the local host
as obtained by the gethostname() system call, or if the
user has assigned an IP address, the value of that address.
In multihomed hosts (machines with more than one IP interface) setting LocalHost to the value of an interface will make the bean initiate connections (or accept in the case of server beans) only through that interface.
If the bean is connected, the LocalHost property shows
the IP address of the interface through which the connection
is made in internet dotted format (aaa.bbb.ccc.ddd). In most
cases, this is the address of the local host, except for multihomed
hosts (machines with more than one IP interface).
NOTE: LocalHost is not persistent. You must always set it in
code, and never in the property window.
public void setLocalHost(java.lang.String localHost)
throws IPWorksException
The LocalHost property contains the name of the local host
as obtained by the gethostname() system call, or if the
user has assigned an IP address, the value of that address.
In multihomed hosts (machines with more than one IP interface) setting LocalHost to the value of an interface will make the bean initiate connections (or accept in the case of server beans) only through that interface.
If the bean is connected, the LocalHost property shows
the IP address of the interface through which the connection
is made in internet dotted format (aaa.bbb.ccc.ddd). In most
cases, this is the address of the local host, except for multihomed
hosts (machines with more than one IP interface).
NOTE: LocalHost is not persistent. You must always set it in
code, and never in the property window.
IPWorksExceptionpublic int getMailPort()
A valid port number (a value between 1 and 65535) is required for the connection to take place. The property must be set before a connection is attempted and cannot be changed once a connection is established. Any attempt to change this property while connected will fail with an error.
public void setMailPort(int mailPort)
throws IPWorksException
A valid port number (a value between 1 and 65535) is required for the connection to take place. The property must be set before a connection is attempted and cannot be changed once a connection is established. Any attempt to change this property while connected will fail with an error.
IPWorksExceptionpublic java.lang.String getMailServer()
The MailServer property specifies the IP address (IP number in
dotted internet format) or Domain Name of the mail server.
It is set before a connection is attempted and cannot be changed
once a connection is in progress.
If the MailServer property is set to a Domain Name, a DNS request
is initiated and upon successful termination of the request, the MailServer property is set to the corresponding address. If the
search is not successful the bean throws an IPWorksException
raises an IPWorksException exception
.
If the bean is configured to use a SOCKS firewall, the value assigned to this property may be preceded with a "*". If this is the case, the host name is passed to the firewall unresolved and the firewall performs the DNS resolution.
public void setMailServer(java.lang.String mailServer)
throws IPWorksException
The MailServer property specifies the IP address (IP number in
dotted internet format) or Domain Name of the mail server.
It is set before a connection is attempted and cannot be changed
once a connection is in progress.
If the MailServer property is set to a Domain Name, a DNS request
is initiated and upon successful termination of the request, the MailServer property is set to the corresponding address. If the
search is not successful the bean throws an IPWorksException
raises an IPWorksException exception
.
If the bean is configured to use a SOCKS firewall, the value assigned to this property may be preceded with a "*". If this is the case, the host name is passed to the firewall unresolved and the firewall performs the DNS resolution.
IPWorksExceptionpublic int getMaxLines()
The MaxLines property is to limit the number
of text lines besides headers retrieved for messages.
It can be used
to preview message headers and a portion of
their contents, without incurring the overhead of
downloading the entire message.
The default value of the property is 0. In this case the entire message will be retrieved, without interruptions.
public void setMaxLines(int maxLines)
throws IPWorksException
The MaxLines property is to limit the number
of text lines besides headers retrieved for messages.
It can be used
to preview message headers and a portion of
their contents, without incurring the overhead of
downloading the entire message.
The default value of the property is 0. In this case the entire message will be retrieved, without interruptions.
IPWorksExceptionpublic java.lang.String getMessageCc()
The same information may also be retrieved through the Header event.
public int getMessageCount()
When the bean is not connected to the server, the value of
the MessageCount property is 0. When connected, it contains
the number of messages in the mail box as reported by the POP server.
public java.lang.String getMessageDate()
The same information may also be retrieved through the Header event.
public java.lang.String getMessageFrom()
The same information may also be retrieved through the Header event.
public java.lang.String getMessageHeaders()
If the bean is not connected, or MessageNumber does not
contain a valid message number, the value of this property is an
empty string. Otherwise, it contains the full headers of the mail message
as reported by the server.
The MailServer is asked about the headers of the message only
if the MessageNumber property has changed. If MessageNumber has not changed, the bean returns a cached value.
Example (Connect and Retrieve Message)
POPControl.MailServer = "MyPOPServer"
POPControl.User = "username"
POPControl.Password = "password"
POPControl.Connect()
POPControl.MessageNumber = 1
MessageText = POPControl.MessageText
MessageHeaders = POPControl.MessageHeaders
public int getMessageNumber()
The MessageNumber property specifies a message number in between
1 and MessageCount . The various bean methods related to
single messages use this property as a message pointer (see method
descriptions and the MessageSize property).
public void setMessageNumber(int messageNumber)
throws IPWorksException
The MessageNumber property specifies a message number in between
1 and MessageCount . The various bean methods related to
single messages use this property as a message pointer (see method
descriptions and the MessageSize property).
IPWorksExceptionpublic java.lang.String getMessageReplyTo()
The same information may also be retrieved through the Header event.
public int getMessageSize()
If the bean is not connected, or MessageNumber does not
contain a valid message number, the value of this property is 0.
Otherwise, it contains the size of the mail message (including
headers) as reported by the server.
The MailServer is asked about the size of the message only
if the MessageNumber property has changed. If MessageNumber has not changed, the bean returns a cached value.
public java.lang.String getMessageSubject()
The same information may also be retrieved through the Header event.
public java.lang.String getMessageText()
If the bean is not connected, or MessageNumber does not
contain a valid message number, the value of this property is an
empty string. Otherwise, it contains the text of the mail message
as reported by the server (a maximum of MaxLines ).
The MailServer is asked about the text of the message only
if the MessageNumber property has changed. If MessageNumber has not changed, the bean returns a cached value.
Example (Connect and Retrieve Message)
POPControl.MailServer = "MyPOPServer"
POPControl.User = "username"
POPControl.Password = "password"
POPControl.Connect()
POPControl.MessageNumber = 1
MessageText = POPControl.MessageText
MessageHeaders = POPControl.MessageHeaders
public java.lang.String getMessageTo()
The same information may also be retrieved through the Header event.
public java.lang.String getMessageUID()
If the bean is not connected, or MessageNumber does not
contain a valid message number, the value of this property is an
empty string. Otherwise, it contains the UID of the mail message
as reported by the server.
The MailServer is asked about the UID of the message only
if the MessageNumber property has changed. If MessageNumber has not changed, the bean returns a cached value.
public java.lang.String getPassword()
This property must be set before the bean connects to the MailServer .
public void setPassword(java.lang.String password)
throws IPWorksException
This property must be set before the bean connects to the MailServer .
IPWorksExceptionpublic int getTimeout()
If the Timeout property is set to 0, all operations
will run uninterrupted until successful completion, or an error condition
is encountered.
If Timeout is set to a positive value, the bean will
wait for the operation to complete before returning control.
The bean will use DoEvents to enter an efficient wait loop
during any potential waiting period, making sure that all system events
are processed immediately as they arrive. This ensures that the host
application does not "freeze" and remains responsive.
If Timeout expires, and the operation is not yet complete,
the bean throws an IPWorksException
raises an IPWorksException exception
.
Please note that by default, all timeouts are inactivity timeouts ,
i.e. the timeout period is extended by Timeout seconds when
data is successfully sent or received.
Optionally, the behavior of the bean may be changed to absolute timeouts , i.e. the bean will wait for a maximum
of Timeout seconds since the beginning of the operation, without
extending the timeout period during communications.
This behavior is controlled by theAbsoluteTimeoutconfiguration setting.
The default value for the Timeout property is 60 (seconds).
public void setTimeout(int timeout)
throws IPWorksException
If the Timeout property is set to 0, all operations
will run uninterrupted until successful completion, or an error condition
is encountered.
If Timeout is set to a positive value, the bean will
wait for the operation to complete before returning control.
The bean will use DoEvents to enter an efficient wait loop
during any potential waiting period, making sure that all system events
are processed immediately as they arrive. This ensures that the host
application does not "freeze" and remains responsive.
If Timeout expires, and the operation is not yet complete,
the bean throws an IPWorksException
raises an IPWorksException exception
.
Please note that by default, all timeouts are inactivity timeouts ,
i.e. the timeout period is extended by Timeout seconds when
data is successfully sent or received.
Optionally, the behavior of the bean may be changed to absolute timeouts , i.e. the bean will wait for a maximum
of Timeout seconds since the beginning of the operation, without
extending the timeout period during communications.
This behavior is controlled by theAbsoluteTimeoutconfiguration setting.
The default value for the Timeout property is 60 (seconds).
IPWorksExceptionpublic int getTotalSize()
When the bean is not connected to the server, the value of
the TotalSize property is 0. When connected, it contains
the cumulative size of all the messages in the mail box as reported
by the POP server.
public java.lang.String getUser()
This property must be set before the bean connects to the MailServer .
public void setUser(java.lang.String user)
throws IPWorksException
This property must be set before the bean connects to the MailServer .
IPWorksException
public java.lang.String config(java.lang.String configurationString)
throws IPWorksException
Config is a generic method available in every bean.
It is used to set and retrieveconfiguration settingsfor the
bean.
Configuration settings are similar in functionality to properties,
but they are rarely used. In order to avoid "polluting" the property
namespace of the bean, access to these internal properties is provided through the Config method.
To set a configuration setting named PROPERTY , you must call Config("PROPERTY=VALUE") , where VALUE is the value of the setting expressed as a string. For boolean values, use the strings "True", "False", "0", "1", "Yes", or "No" (case does not matter).
To read (query) the value of a configuration setting, you must call Config("PROPERTY") . The value will be returned as a string.
IPWorksException
public void connect()
throws IPWorksException
Connects to the mail server and attempts to login using the current User and Password . Then it retrieves initial statistics about
the mailbox contents ( MessageCount and TotalSize ).
Example (Connect to POP Mailbox)
POPControl.MailServer = "MyPOPServer"
POPControl.User = "username"
POPControl.Password = "password"
POPControl.Connect()
POPControl.MessageNumber = 1
POPControl.Retrieve()
MessageText = POPControl.MessageText
MessageHeaders = POPControl.MessageHeaders
IPWorksException
public void delete()
throws IPWorksException
MessageNumber on the server.
Asks the MailServer to delete the message specified by MessageNumber . The message will not
actually be deleted from the server until the connection is closed. In order to cancel a previous
Delete, use the Reset method.
IPWorksException
public void disconnect()
throws IPWorksException
Makes the bean disconnect from the MailServer by sending the QUIT
command. If successful, all changes to the mailbox are committed by the server.
Otherwise, changes are rolled back to the initial state that the server was in before
the connection.
IPWorksException
public void doEvents()
throws IPWorksException
When DoEvents is called, the bean processes any
available events. If no events are available, it waits for a
preset period of time, and then returns.
IPWorksException
public void interrupt()
throws IPWorksException
If there is no method in progress, Interrupt simply returns doing nothing.
IPWorksException
public void listMessageSizes()
throws IPWorksException
For each message listed, a MessageList event will fire containing the number and size of the message.
IPWorksException
public void listMessageUIDs()
throws IPWorksException
For each message listed, a MessageList event will fire containing the number and UID of the message.
IPWorksException
public java.lang.String localizeDate(java.lang.String dateTime)
throws IPWorksException
This method can be used to convert an RFC 822 date/time string to the corresponding local date and time.
Dates will be returned in the format: "MM/dd/yyyy hh:mm:ss".
IPWorksException
public void reset()
throws IPWorksException
Asks the MailServer to reset all changes and revert back to the state
it was when connected.
IPWorksException
public void retrieve()
throws IPWorksException
MessageNumber from the server.
Asks the MailServer to retrieve the message specified by MessageNumber .
The message headers will arrive in the Header event, and the message text will
arrive in the Transfer event.
The MaxLines property defines the number of lines retrieved.
Example (Connect and Retrieve Message)
POPControl.MailServer = "MyPOPServer"
POPControl.User = "username"
POPControl.Password = "password"
POPControl.Connect()
POPControl.MessageNumber = 1
POPControl.retrieve()
IPWorksException
public void retrieveHeaders()
throws IPWorksException
MessageNumber .
Calling this method will retrieve the headers for the message specified
by the MessageNumber property. The message headers
will be provided by the Header event and also stored in the MessageHeaders property.
Example (Connect and Retrieve Message Headers)
POPControl.MailServer = "MyPOPServer"
POPControl.User = "username"
POPControl.Password = "password"
POPControl.Connect()
POPControl.MessageNumber = 1
POPControl.retrieveHeaders()
IPWorksException
public void addPopEventListener(PopEventListener l)
throws java.util.TooManyListenersException
java.util.TooManyListenersExceptionpublic void removePopEventListener(PopEventListener l)
|
IP*Works! V6 | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||