mn8 Language Reference | Index    

POP3

SUMMARY: NO ATTRIBUTES  NO ELEMENTS  CONSTRUCTORS SUMMARY  NO OPERATORS  METHODS SUMMARYDETAIL: NO ATTRIBUTES  NO ELEMENTS  CONSTRUCTOR DETAILS  NO OPERATORS  METHOD DETAILS

Description

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 :

In handler mode the URL format is the following: pop3://<userInfo>@<hostName>/?query

Possible options (all options can use like query):

Possible POP3 commands :

Usage

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"

Version: 0.1
Authors:Szabo Csaba ()
Antal Attila ()
Location:
Inherits: Concept

Constructor List

create (String )
top

Method List

static LogicalacceptsURI (String $uri)
Integercheck
nullcloseConnection
delete (String $messID)
deleteAll
SeriesgetHeader (String )
SeriesgetHeader (Expression )
SeriesgetID
SeriesgetID (Expression )
SeriesgetMessage (Expression )
SeriesgetMessage (String )
Logicallogin (String $userName, String $password)
Logicallogout
LogicalopenConnection (String $url)
top
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

Detailed Constructor Info

create (String )
Parameters:
:The url to create the POP3 handler.

Creates a new POP3 concept with the given url.

top

Detailed Method Info

static acceptsURI (String $uri)
Parameters:
$uri : The uri which will be tested if it is acceptable by this handler.
Returns: Logical

Returns true if the given $uri is acceptable by this handler, false otherwise.

                print POP3.acceptsURI("pop3://server")
                -- the result is --
                true
            

top
check
Returns: Integer
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
            

top
closeConnection
Returns: null
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.
            

top
delete (String $messID)
Parameters:
$messID :The message ID to delete.
Returns:
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
            

top
deleteAll
Returns:
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
            

top
getHeader (String )
Parameters:
:Message id
Returns: Series
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: &lt;crow@nolimits.ro&gt;
                      Delivered-To: crow@[192.168.1.22]
                      Received: from there (unknown [192.168.1.215])
                          by server.intranet (Postfix) with SMTP id 31FF023F25
                          for &lt;crow@[192.168.1.22]&gt;; Thu,  1 Aug 2002 20:33:08 -0400 (EDT)
                      Content-Type: text/plain; charset=&quot;iso-8859-15&quot;
                      From: Szabo Csaba &lt;crow@nolimits.ro&gt;
                      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: &lt;20020802003308.31FF023F25@server.intranet&gt;
                      Status: RO
                    </emx:BodyPart>
                  </emx:part>
                </emx:Message>
            

top
getHeader (Expression )
Parameters:
:Expression concept
Returns: Series

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: &lt;crow@nolimits.ro&gt;
                      Delivered-To: crow@[192.168.1.22]
                      Received: from there (unknown [192.168.1.215])
                          by server.intranet (Postfix) with SMTP id 31FF023F25
                          for &lt;crow@[192.168.1.22]&gt;; Thu,  1 Aug 2002 20:33:08 -0400 (EDT)
                      Content-Type: text/plain; charset=&quot;iso-8859-15&quot;
                      From: Szabo Csaba &lt;crow@nolimits.ro&gt;
                      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: &lt;20020802003308.31FF023F25@server.intranet&gt;
                      Status: RO
                    </emx:BodyPart>
                  </emx:part>
                </emx:Message>
            

top
getID
Returns: Series
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>
            

top
getID (Expression )
Parameters:
:Expression concept
Returns: Series

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>
            

top
getMessage (Expression )
Parameters:
:Expression concept
Returns: Series

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 &lt;crow@[192.168.1.22]&gt;; 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>&lt;20020802005404.0AA4F535B7@server.intranet&gt;</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>
            

top
getMessage (String )
Parameters:
:Message id
Returns: Series
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 &lt;crow@[192.168.1.22]&gt;; 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>&lt;20020802005404.0AA4F535B7@server.intranet&gt;</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>
            

top
login (String $userName, String $password)
Parameters:
$userName :The user's name with which to connect.
$password :The user's password with which to connect.
Returns: Logical
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.
            

top
logout
Returns: Logical
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.
            

top
openConnection (String $url)
Parameters:
$url :The url to the remote host or $url isn't valid.
Returns: Logical
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.
            

top