Path

ez components / documentation / api reference / 2007.1.1 / mail


eZ Components 2007.1.1

Mail: ezcMailPop3Transport

[ Tutorial ] [ Display example ] [ Mail listing example ] [ Rfcs ] [ Class tree ] [ Element index ] [ ChangeLog ] [ Credits ]

Class: ezcMailPop3Transport

ezcMailPop3Transport implements POP3 for mail retrieval. [source]
The implementation supports most of the basic commands specified in http://www.faqs.org/rfcs/rfc1939.html
The implementation also supports the following authentication methods: http://www.faqs.org/rfc/rfc1734.txt - auth

Constants

AUTH_APOP = 2 APOP authorization.
AUTH_PLAIN_TEXT = 1 Plain text authorization.

Properties

ezcMailPop3TransportOptions read/write  $options
Holds the options you can set to the POP3 transport.

Method Summary

public ezcMailPop3Transport __construct( $server, [$port = null], [$options = array()] )
Creates a new POP3 transport and connects to the $server at $port.
public void __destruct( )
Destructs the POP3 transport object.
public void authenticate( $user, $password, [$method = null] )
Authenticates the user to the POP3 server with $user and $password.
public void delete( $msgNum )
Deletes the message with the message number $msgNum from the server.
public void disconnect( )
Disconnects the transport from the POP3 server.
public ezcMailParserSet fetchAll( [$deleteFromServer = false] )
Returns a parserset with all the messages on the server.
public ezcMailPop3Set fetchByMessageNr( $number, [$deleteFromServer = false] )
Returns an ezcMailPop3Set containing only the $number -th message in the mailbox.
public ezcMailPop3Set fetchFromOffset( $offset, [$count = 0], [$deleteFromServer = false] )
Returns an ezcMailPop3Set with $count messages starting from $offset.
public array(int=>int) listMessages( )
Returns a list of the messages on the server and the size of the messages in bytes.
public array(int=>string) listUniqueIdentifiers( [$msgNum = null] )
Returns the unique identifiers for messages on the POP3 server.
public void noop( )
Sends a NOOP command to the server, use it to keep the connection alive.
public void status( &$numMessages, &$sizeMessages )
Returns the number of messages on the server and the combined size of the messages through the input variables $numMessages and $sizeMessages.
public string top( $msgNum, [$numLines = 0] )
Returns the headers and the $numLines first lines of the body of the mail with the message number $msgNum.

Methods

__construct

ezcMailPop3Transport __construct( string $server, [int $port = null], [ $options = array()] )
Creates a new POP3 transport and connects to the $server at $port.
You can specify the $port if the POP3 server is not on the default port 995 (for SSL connections) or 110 (for plain connections). Use the $options parameter to specify an SSL connection.
For options you can specify for POP3 see: ezcMailPop3TransportOptions

Parameters

Name Type Description
$server string  
$port int  
$options array(string=>mixed)  

Throws

ClassDescription
ezcMailTransportException if it was not possible to connect to the server
ezcBaseFeatureNotFoundException if trying to use SSL and the extension openssl is not installed
ezcBasePropertyNotFoundException if $options contains a property not defined
ezcBaseValueException if $options contains a property with a value not allowed

__destruct

void __destruct( )
Destructs the POP3 transport object.
If there is an open connection to the POP3 server it is closed.

authenticate

void authenticate( string $user, string $password, [mixed $method = null] )
Authenticates the user to the POP3 server with $user and $password.
You can choose the authentication method with the $method parameter. The default is to use plaintext username and password (specified in the ezcMailPop3TransportOptions class).
This method should be called directly after the construction of this object.

Parameters

Name Type Description
$user string  
$password string  

Throws

ClassDescription
ezcMailTransportException if there is no connection to the server or if already authenticated or if the authentication method is not accepted by the server or if the provided username/password combination did not work

delete

void delete( int $msgNum )
Deletes the message with the message number $msgNum from the server.
The message number must be a valid identifier fetched with e.g listMessages(). Any future reference to the message-number associated with the message in a command generates an error.

Parameters

Name Type Description
$msgNum int  

Throws

ClassDescription
ezcMailTransportException if there was no connection to the server or if the server sent a negative response

disconnect

void disconnect( )
Disconnects the transport from the POP3 server.

fetchAll

ezcMailParserSet fetchAll( [bool $deleteFromServer = false] )
Returns a parserset with all the messages on the server.
If $deleteFromServer is set to true the mail will be removed from the server after retrieval. If not it will be left.

Parameters

Name Type Description
$deleteFromServer bool  

Throws

ClassDescription
ezcMailTransportException if there was no connection to the server or if the server sent a negative response

fetchByMessageNr

ezcMailPop3Set fetchByMessageNr( int $number, [bool $deleteFromServer = false] )
Returns an ezcMailPop3Set containing only the $number -th message in the mailbox.
If $deleteFromServer is set to true the mail will be removed from the server after retrieval. If not it will be left. Note: for POP3 the first message is 1 (so for $number = 0 the exception will be thrown).

Parameters

Name Type Description
$number int  
$deleteFromServer bool  

Throws

ClassDescription
ezcMailTransportException if there was no connection to the server or if the server sent a negative response
ezcMailNoSuchMessageException if the message $number is out of range

fetchFromOffset

ezcMailPop3Set fetchFromOffset( int $offset, [int $count = 0], [bool $deleteFromServer = false] )
Returns an ezcMailPop3Set with $count messages starting from $offset.
Fetches $count messages starting from the $offset and returns them as a ezcMailPop3Set. If $count is not specified or if it is 0, it fetches all messages starting from the $offset.

Parameters

Name Type Description
$offset int  
$count int  
$deleteFromServer bool  

Throws

ClassDescription
ezcMailTransportException if there was no connection to the server or if the server sent a negative response
ezcMailInvalidLimitException if $count is negative
ezcMailOffsetOutOfRangeException if $offset is outside of the existing range of messages

listMessages

array(int=>int) listMessages( )
Returns a list of the messages on the server and the size of the messages in bytes.
The format of the returned array is array(message_id=>message_size)

Throws

ClassDescription
ezcMailTransportException if there was no connection to the server or if the server sent a negative response

listUniqueIdentifiers

array(int=>string) listUniqueIdentifiers( [int $msgNum = null] )
Returns the unique identifiers for messages on the POP3 server.
You can fetch the unique identifier for a specific message by providing the $msgNum parameter.
The unique identifier can be used to recognize mail from servers between requests. In contrast to the message numbers the unique numbers assigned to an email never changes.
The format of the returned array is array(message_num=>unique_identifier).
Note: POP3 servers are not required to support this command and it may fail.

Parameters

Name Type Description
$msgNum int  

Throws

ClassDescription
ezcMailTransportException if there was no connection to the server or if the server sent a negative response

noop

void noop( )
Sends a NOOP command to the server, use it to keep the connection alive.

Throws

ClassDescription
ezcMailTransportException if there was no connection to the server or if the server sent a negative response

status

void status( int &$numMessages, int &$sizeMessages )
Returns the number of messages on the server and the combined size of the messages through the input variables $numMessages and $sizeMessages.

Parameters

Name Type Description
&$numMessages int  
&$sizeMessages int  

Throws

ClassDescription
ezcMailTransportException if there was no connection to the server or if the server sent a negative response

top

string top( int $msgNum, [int $numLines = 0] )
Returns the headers and the $numLines first lines of the body of the mail with the message number $msgNum.
If the command failed or if it was not supported by the server an empty string is returned.
Note: POP3 servers are not required to support this command and it may fail.

Parameters

Name Type Description
$msgNum int  
$numLines int  

Throws

ClassDescription
ezcMailTransportException if there was no connection to the server or if the server sent a negative response

Last updated: Wed, 28 Nov 2007