The POP3 concept implements the client side of the Internet POP3 Protocol.
You can use like a simple client or handler (using URL for all)
It Have a lot methods (or commands in handler mode) for :
- connect and disconnect form POP3 server
- login to and logout from POP3 server
- check messages form mailbox
- get ids, headers and messages form mailbox
- delete or delete all specified message
In handler mode the URL format is the following:
pop3://<userInfo>@<hostName>/?query
Possible options (all options can use like query):
-
user
- this option specifying the userName for POP3
server connection.
-
pwd
- this option specifying the passwd for POP3
server connection.
-
cmd
- POP3 command
-
requests
- option for limit the numbers of messages,
headers, ids
-
filter
- can use an Expression concept to filter your list of
messages, headers, ids
-
id
- specify an id for command, this id is always a RFC822
message id
Possible POP3 commands :
-
check
- use this command to check (obtain the total message
numbers) your mailbox on POP3 server.
-
getID
- use this command to get message id list from
POP3 server.
-
getHeader
- use this command to get message header(s) from
POP3 server.
-
getMessage
- use this command to get message(s) from
POP3 server.
-
delete
- use this command to delete specified message from
POP3 server.
-
deleteAll
- use this command to delete all messages from
POP3 server.
Simple client example:
Connect to 'host' named POP3 server and login with
'user' and 'pwd', and get the content of first message from
the mailbox like an Emx concept.
$pop3 TYPEOF POP3
$connected = $pop3.openConnection("pop3://hostName/")
if $connected then [
print "You are connected to POP3 server."
$logined = $pop3.login( "userName", "passwd")
if $logined then [
print "You are logged."
$id = $pop3.getID/1
print $pop3.getMessage( $id )/1.toXML
$pop3.logout] else [
print "Login failed. " + $pop3@errorMessage]
$pop3.closeConnection] else [
print "Conncetion failed. " + $pop3@errorMessage]
Simple handler examples:
For more details of using filter and requests please read the Mbox usage.
Connecting to 'hostName' named POP3 server with 'userName' and 'password'
and get message ids, and shows it.
$x from "pop3://hostName/" options "user"="userName","pwd"="passowrd","cmd"="getID"
print $x
Connecting to 'hostName' named POP3 server with 'userName' and 'passwd'
and get all messages form the mailbox and show the first message (the message
is an Emx concept). I will using the command like query (of corse I can also put
in options)
$x from "pop3://hostName/?cmd=getMessage" options "user"="userName","pwd"="passwd"
print $x/1.toXML
Connecting to 'hostName' named POP3 server with 'userName' and 'passwd'
and delete the first message (for this I need to find the ID of first message).
#get the ids
$ids from "pop3://hostName/?cmd=getID" options "user"="userName","pwd"="passowrd"
#using the first id to delete the first message
$x from "pop3://hostName/" options "id"=$ids/1 "user"="userName","pwd"="passwd","cmd"="delete"
Methods inherited from: Concept
| cloneConcept, extendsConcept, fromXML, getAllInheritedConcepts, getConceptAttribute, getConceptAttributeField, getConceptAttributeFields, getConceptAttributes, getConceptConstructors, getConceptElement, getConceptElementField, getConceptElementFields, getConceptElements, getConceptLabel, getConceptMethod, getConceptMethods, getConceptOperators, getConceptType, getErrorHandler, getInheritedConcepts, getResourceURI, hasConceptAttribute, hasConceptElement, hasConceptMethod, hasPath, isHidden, loadContent, setConceptLabel, setErrorHandler, setHidden, setShowEmpty, showEmpty, toTXT, toXML, setResourceURI |
|
| Parameters: |
| : | The url to create the POP3 handler. |
|
Creates a new POP3 concept with the given url.
| Parameters: |
| $uri : |
The uri which will be tested if it is acceptable by this handler. |
|
Returns true if the given $uri is acceptable by this handler, false
otherwise.
print POP3.acceptsURI("pop3://server")
-- the result is --
true
| Exceptions: |
pop3OperationException :
(Error) | If unable to check the mailbox |
Checking the mailbox and returns the number of messages
$pop3 typeof POP3
$connected = $pop3.openConnection("pop3://server/")
if $connected then [
print "You are connected to POP3 server."
$logined = $pop3.login( "crow", "crowp")
if $logined then [
print "You are logined."
print "Number of message: " + $pop3.check
$pop3.logout
] else [
print "Login failed. " + $pop3@errorMessage
]
$pop3.closeConnection
] else [
print "Conncetion failed. " + $pop3@errorMessage
]
-- the result is --
You are connected to POP3 server.
You are logined.
Number of message: 1
| Exceptions: |
connectionException :
(Error) | If unable to close POP3 connection. |
Close the current connection.
$pop3 typeof POP3
$connected = $pop3.openConnection("pop3://server/")
if $connected then [
print "You are connected to POP3 server."
#...................
$pop3.closeConnection
] else [
print "Conncetion failed. " + $pop3@errorMessage
]
-- the result is --
You are connected to POP3 server.
| Parameters: |
| $messID : | The message ID to delete. |
|
| Exceptions: |
pop3OperationException :
(Error) | If unable to delete message. |
Delete message with named id
$pop3 typeof POP3
$connected = $pop3.openConnection("pop3://server/")
if $connected then [
print "You are connected to POP3 server."
$logined = $pop3.login( "crow", "crowp")
if $logined then [
print "You are logined."
print "Number of message: " + $pop3.check
print "Delete a message."
$pop3.delete( $pop3.getID/1/ )
print "Number of message: " + $pop3.check
$pop3.logout
] else [
print "Login failed. " + $pop3@errorMessage
]
$pop3.closeConnection
] else [
print "Conncetion failed. " + $pop3@errorMessage
]
-- the result is --
You are connected to POP3 server.
You are logined.
Number of message: 2
Delete a message.
Number of message: 1
| Exceptions: |
pop3OperationException :
(Error) | If unable to delete the all messages |
Deletes all messages
$pop3 typeof POP3
$connected = $pop3.openConnection("pop3://server/")
if $connected then [
print "You are connected to POP3 server."
$logined = $pop3.login( "crow", "crowp")
if $logined then [
print "You are logined."
print "Number of message: " + $pop3.check
print "Delete all messages."
$pop3.deleteAll( )
print "Number of message: " + $pop3.check
$pop3.logout
] else [
print "Login failed. " + $pop3@errorMessage
]
$pop3.closeConnection
] else [
print "Conncetion failed. " + $pop3@errorMessage
]
-- the result is --
You are connected to POP3 server.
You are logined.
Number of message: 2
Delete all messages.
Number of message: 0
| Exceptions: |
pop3OperationException :
(Error) | If unable to get the message headers |
Gets the named message header, if the parameter is empty will returns all the messages.
$pop3 typeof POP3
$connected = $pop3.openConnection("pop3://server/")
if $connected then [
print "You are connected to POP3 server."
$logined = $pop3.login( "crow", "crowp")
if $logined then [
print "You are logined.\n"
print $pop3.getHeader( $pop3.getID/1/ ).toXML
$pop3.logout
] else [
print "Login failed. " + $pop3@errorMessage
]
$pop3.closeConnection
] else [
print "Conncetion failed. " + $pop3@errorMessage
]
-- the result is --
You are connected to POP3 server.
You are logined.
<emx:Message xmlns:rfc822="URN:ietf:params:rfc822:" xmlns:emx="URN:ietf:params:email-xml:">
<emx:part>
<rfc822:content-type>text/xml</rfc822:content-type>
<emx:BodyPart>
From POP3URLConnection: this line must be removed!
Return-Path: <crow@nolimits.ro>
Delivered-To: crow@[192.168.1.22]
Received: from there (unknown [192.168.1.215])
by server.intranet (Postfix) with SMTP id 31FF023F25
for <crow@[192.168.1.22]>; Thu, 1 Aug 2002 20:33:08 -0400 (EDT)
Content-Type: text/plain; charset="iso-8859-15"
From: Szabo Csaba <crow@nolimits.ro>
Organization: noLimits Tehnologies
To: crow@[192.168.1.22]
Subject: Hello
Date: Thu, 1 Aug 2002 20:35:53 +0300
X-Mailer: KMail [version 1.3.1]
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
Message-Id: <20020802003308.31FF023F25@server.intranet>
Status: RO
</emx:BodyPart>
</emx:part>
</emx:Message>
Gets the message headers matching to the expression given as parameter
$pop3 typeof POP3
$connected = $pop3.openConnection("pop3://server/")
if $connected then [
print "You are connected to POP3 server."
$logined = $pop3.login( "crow", "crowp")
if $logined then [
print "You are logined.\n"
print $pop3.getHeader( Simlpex.create("*server*") ).toXML
$pop3.logout
] else [
print "Login failed. " + $pop3@errorMessage
]
$pop3.closeConnection
] else [
print "Conncetion failed. " + $pop3@errorMessage
]
-- the result is --
You are connected to POP3 server.
You are logined.
<emx:Message xmlns:rfc822="URN:ietf:params:rfc822:" xmlns:emx="URN:ietf:params:email-xml:">
<emx:part>
<rfc822:content-type>text/xml</rfc822:content-type>
<emx:BodyPart>
From POP3URLConnection: this line must be removed!
Return-Path: <crow@nolimits.ro>
Delivered-To: crow@[192.168.1.22]
Received: from there (unknown [192.168.1.215])
by server.intranet (Postfix) with SMTP id 31FF023F25
for <crow@[192.168.1.22]>; Thu, 1 Aug 2002 20:33:08 -0400 (EDT)
Content-Type: text/plain; charset="iso-8859-15"
From: Szabo Csaba <crow@nolimits.ro>
Organization: noLimits Tehnologies
To: crow@[192.168.1.22]
Subject: Hello
Date: Thu, 1 Aug 2002 20:35:53 +0300
X-Mailer: KMail [version 1.3.1]
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
Message-Id: <20020802003308.31FF023F25@server.intranet>
Status: RO
</emx:BodyPart>
</emx:part>
</emx:Message>
| Exceptions: |
pop3OperationException :
(Error) | If unable to get the message ids |
Gets the messages id
$pop3 typeof POP3
$connected = $pop3.openConnection("pop3://server/")
if $connected then [
print "You are connected to POP3 server."
$logined = $pop3.login( "crow", "crowp")
if $logined then [
print "You are logined."
print $pop3.getID
$pop3.logout
] else [
print "Login failed. " + $pop3@errorMessage
]
$pop3.closeConnection
] else [
print "Conncetion failed. " + $pop3@errorMessage
]
-- the result is --
You are connected to POP3 server.
You are logined.
<20020802003308.31FF023F25@server.intranet>
<20020802004456.524A939AE0@server.intranet>
<20020802004520.467DD24147@server.intranet>
Gets the ids matching to the expression given as parameter
$pop3 typeof POP3
$connected = $pop3.openConnection("pop3://server/")
if $connected then [
print "You are connected to POP3 server."
$logined = $pop3.login( "crow", "crowp")
if $logined then [
print "You are logined."
print $pop3.getID( Simplex.create("*2004*") )
$pop3.logout
] else [
print "Login failed. " + $pop3@errorMessage
]
$pop3.closeConnection
] else [
print "Conncetion failed. " + $pop3@errorMessage
]
-- the result is --
You are connected to POP3 server.
You are logined.
<20020802004456.524A939AE0@server.intranet>
<20020802004520.467DD24147@server.intranet>
Gets the messages matching to the expression given as parameter
$pop3 typeof POP3
$connected = $pop3.openConnection("pop3://server/")
if $connected then [
print "You are connected to POP3 server."
$logined = $pop3.login( "crow", "crowp")
if $logined then [
print "You are logined.\n"
print $pop3.getMessage( Simplex.create("*This*POP3*") ).toXML
$pop3.logout
] else [
print "Login failed. " + $pop3@errorMessage
]
$pop3.closeConnection
] else [
print "Conncetion failed. " + $pop3@errorMessage
]
-- the result is --
You are connected to POP3 server.
You are logined.
<emx:Message xmlns:rfc822="URN:ietf:params:rfc822:" xmlns:emx="URN:ietf:params:email-xml:">
<rfc822:return-path>
<emx:Address>
<emx:adrs>crow@nolimits.ro</emx:adrs>
</emx:Address>
</rfc822:return-path>
<rfc822:from>
<emx:Address>
<emx:adrs>crow@nolimits.ro</emx:adrs>
<emx:name>Szabo Csaba</emx:name>
</emx:Address>
</rfc822:from>
<rfc822:to>
<emx:Address>
<emx:adrs>crow@[192.168.1.22]</emx:adrs>
</emx:Address>
</rfc822:to>
<rfc822:subject>Hello</rfc822:subject>
<rfc822:received>
from there (unknown [192.168.1.215]) by server.intranet (Postfix)
with SMTP id 0AA4F535B7 for <crow@[192.168.1.22]>; Thu, 1 Aug 2002 20:54:04 -0400 (EDT)
</rfc822:received>
<rfc822:date>Thu, 1 Aug 2002 20:56:49 +0300</rfc822:date>
<rfc822:message-id><20020802005404.0AA4F535B7@server.intranet></rfc822:message-id>
<rfc822:extension-field>
<name>x-mailer</name>
<value>KMail [version 1.3.1]</value>
</rfc822:extension-field>
<rfc822:user-defined-field>
<name>from pop3urlconnection</name>
<value>this line must be removed!</value>
</rfc822:user-defined-field>
<rfc822:user-defined-field>
<name>delivered-to</name>
<value>crow@[192.168.1.22]</value>
</rfc822:user-defined-field>
<rfc822:user-defined-field>
<name>organization</name>
<value>noLimits Tehnologies</value>
</rfc822:user-defined-field>
<rfc822:user-defined-field>
<name>mime-version</name>
<value>1.0</value>
</rfc822:user-defined-field>
<rfc822:user-defined-field>
<name>status</name>
<value>RO</value>
</rfc822:user-defined-field>
<emx:part>
<rfc822:content-type charset="iso-8859-15">text/plain</rfc822:content-type>
<rfc822:content-transfer-encoding>8bit</rfc822:content-transfer-encoding>
<emx:BodyPart>
This is a POP3 test.
</emx:BodyPart>
</emx:part>
</emx:Message>
| Exceptions: |
pop3OperationException :
(Error) | If unable to get the messages |
Gets the named messages, if the parameter is empty will returns all the messages.
$pop3 typeof POP3
$connected = $pop3.openConnection("pop3://server/")
if $connected then [
print "You are connected to POP3 server."
$logined = $pop3.login( "crow", "crowp")
if $logined then [
print "You are logined.\n"
print $pop3.getMessage( $pop3.getID()/1/ ).toXML
$pop3.logout
] else [
print "Login failed. " + $pop3@errorMessage
]
$pop3.closeConnection
] else [
print "Conncetion failed. " + $pop3@errorMessage
]
-- the result is --
You are connected to POP3 server.
You are logined.
<emx:Message xmlns:rfc822="URN:ietf:params:rfc822:" xmlns:emx="URN:ietf:params:email-xml:">
<rfc822:return-path>
<emx:Address>
<emx:adrs>crow@nolimits.ro</emx:adrs>
</emx:Address>
</rfc822:return-path>
<rfc822:from>
<emx:Address>
<emx:adrs>crow@nolimits.ro</emx:adrs>
<emx:name>Szabo Csaba</emx:name>
</emx:Address>
</rfc822:from>
<rfc822:to>
<emx:Address>
<emx:adrs>crow@[192.168.1.22]</emx:adrs>
</emx:Address>
</rfc822:to>
<rfc822:subject>Hello</rfc822:subject>
<rfc822:received>
from there (unknown [192.168.1.215]) by server.intranet (Postfix)
with SMTP id 0AA4F535B7 for <crow@[192.168.1.22]>; Thu, 1 Aug 2002 20:54:04 -0400 (EDT)
</rfc822:received>
<rfc822:date>Thu, 1 Aug 2002 20:56:49 +0300</rfc822:date>
<rfc822:message-id><20020802005404.0AA4F535B7@server.intranet></rfc822:message-id>
<rfc822:extension-field>
<name>x-mailer</name>
<value>KMail [version 1.3.1]</value>
</rfc822:extension-field>
<rfc822:user-defined-field>
<name>from pop3urlconnection</name>
<value>this line must be removed!</value>
</rfc822:user-defined-field>
<rfc822:user-defined-field>
<name>delivered-to</name>
<value>crow@[192.168.1.22]</value>
</rfc822:user-defined-field>
<rfc822:user-defined-field>
<name>organization</name>
<value>noLimits Tehnologies</value>
</rfc822:user-defined-field>
<rfc822:user-defined-field>
<name>mime-version</name>
<value>1.0</value>
</rfc822:user-defined-field>
<rfc822:user-defined-field>
<name>status</name>
<value>RO</value>
</rfc822:user-defined-field>
<emx:part>
<rfc822:content-type charset="iso-8859-15">text/plain</rfc822:content-type>
<rfc822:content-transfer-encoding>8bit</rfc822:content-transfer-encoding>
<emx:BodyPart>
This is a POP3 test.
</emx:BodyPart>
</emx:part>
</emx:Message>
| Parameters: |
| $userName : | The user's name with which to connect. |
| $password : | The user's password with which to connect. |
|
| Exceptions: |
connectionException :
(Error) | If the login failed into POP3 server. |
Returns true if the logging in with the specified $userName and
$password was successfull, false otherwise.
$pop3 typeof POP3
$connected = $pop3.openConnection("pop3://server/")
if $connected then [
print "You are connected to POP3 server."
$logined = $pop3.login( "crow", "crowp")
if $logined then [
print "You are logined.\n"
$pop3.logout
] else [
print "Login failed. " + $pop3@errorMessage
]
$pop3.closeConnection
] else [
print "Conncetion failed. " + $pop3@errorMessage
]
-- the result is --
You are connected to POP3 server.
You are logined.
| Exceptions: |
connectionException :
(Error) | If the logout failed form POP3 server. |
Returns true if the logging out was successfull, false otherwise.
$pop3 typeof POP3
$connected = $pop3.openConnection("pop3://server/")
if $connected then [
print "You are connected to POP3 server."
$logined = $pop3.login( "crow", "crowp")
if $logined then [
print "You are logined.\n"
$pop3.logout
] else [
print "Login failed. " + $pop3@errorMessage
]
$pop3.closeConnection
] else [
print "Conncetion failed. " + $pop3@errorMessage
]
-- the result is --
You are connected to POP3 server.
You are logined.
| Parameters: |
| $url : | The url to the remote host or $url isn't valid. |
|
| Exceptions: |
badURLException :
(Error) | If missing host name for POP3 connection. |
connectionException :
(Error) | If the POP3 server refuzed connection. |
Returns true if the connection to the remote host with the specified
$url was successfull, false otherwise.
$pop3 typeof POP3
$connected = $pop3.openConnection("pop3://server/")
if $connected then [
print "You are connected to POP3 server."
$pop3.closeConnection
] else [
print "Conncetion failed. " + $pop3@errorMessage
]
-- the result is --
You are connected to POP3 server.