mn8 Language Reference | Index    

SMTPHandler

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

Description

SMTPHandler encapsulates all the functionality necessary to send files through an SMTP server. This concept is able to connect and send message to SMTP server.

URL format is : smtp://<hostName>/

Possible options :

Usage

This example get a message form POP3 server and send it to SMTP server.

            $x from "pop3://hostName/retrieve?id=ID" options "user"="userName","pwd"="passwd"
            $x to "smtp://hostName/"

Version: 0.1
Authors:Szabo Csaba ()
Location:
Inherits: Concept, URIHandler

Constructor List

create (String $url)
top

Method List

static LogicalacceptsURI (String $uri)
LogicalcloseConnection
ConceptgetContent
Logicalinitialize (Map $options)
LogicalopenConnection
LogicalsetContent (Concept $value)
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
Methods inherited from: URIHandler
acceptsURI, closeConnection, getContent, initialize, openConnection, setContent

Detailed Constructor Info

create (String $url)
Parameters:
$url :The url with which this SMTPHandler will be created.

Creates a new SMTPHandler 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 SMTPHandler.acceptsURI("smtp://server")
                -- the result is --
                true
            

top
closeConnection
Returns: Logical

Returns true if the closing of this connection was successfull, false otherwise.

                $msg FROM "pop3://crow:crowp@server/"                                           
                $url = "smtp://server/"                                                         
                $smtp = SMTPHandler.create( $url )                                                 
                if $smtp.acceptsURI( $url ) then [                                               
                    $m typeof Map                                                               
                    if ( $smtp.initialize( $m ) ) then [                                             
                        if ( $smtp.openConnection ) then [                                         
                            print "Message sent:" + $smtp.setContent( $msg/1.toTXT )             

                            $smtp.closeConnection                                                

                        ]                                                                       
                    ]                                                                           
                ]
                -- the result is --
                Message sent: true
             

top
getContent
Returns: Concept

Return false.

top
initialize (Map $options)
Parameters:
$options : Contains a filter with which the returned content will be filtered.
Returns: Logical

Returns true if the SMTPHandler was initilized successfully, false otherwise.

                $msg FROM "pop3://crow:crowp@server/"                                           
                $url = "smtp://server/"                                                         
                $smtp = SMTPHandler.create( $url )                                                 
                if $smtp.acceptsURI( $url ) then [                                               
                    $m typeof Map                                                               
                    if ( $smtp.initialize( $m ) ) then [                                             
                        if ( $smtp.openConnection ) then [                                         
                            print "Message sent:" + $smtp.setContent( $msg/1.toTXT )             

                            $smtp.closeConnection                                                

                        ]                                                                       
                    ]                                                                           
                ]
                -- the result is --
                Message sent: true
             

top
openConnection
Returns: Logical
Exceptions:
connectionException :
(Error)
If the SMTP server refuzed connection or log on failed.
badURLException :
(Error)
If the URL is not valid..

Returns true if the connection can be establised with the remote server from this concept's url, false otherwise.

                $msg FROM "pop3://crow:crowp@server/"                                           
                $url = "smtp://server/"                                                         
                $smtp = SMTPHandler.create( $url )                                                 
                if $smtp.acceptsURI( $url ) then [                                               
                    $m typeof Map                                                               
                    if ( $smtp.initialize( $m ) ) then [
                                             
                        if ( $smtp.openConnection ) then [                                         

                            print "Message sent:" + $smtp.setContent( $msg/1.toTXT )             
                            $smtp.closeConnection                                                
                        ]                                                                       
                    ]                                                                           
                ]
                -- the result is --
                Message sent: true
             

top
setContent (Concept $value)
Parameters:
$value :The value to be set.
Returns: Logical
Exceptions:
sendException :
(Error)
If unable to send message to SMTP server.

Sets this SMTPHandler content to the specified $value.

                $msg FROM "pop3://crow:crowp@server/"                                           
                $url = "smtp://server/"                                                         
                $smtp = SMTPHandler.create( $url )                                                 
                if $smtp.acceptsURI( $url ) then [                                               
                    $m typeof Map                                                               
                    if ( $smtp.initialize( $m ) ) then [
                        if ( $smtp.openConnection ) then [                                         

                            print "Message sent:" + $smtp.setContent( $msg/1.toTXT )             
                        
                            $smtp.closeConnection                                                
                        ]                                                                       
                    ]                                                                           
                ]
                -- the result is --
                Message sent: true
             

top