Provides low-level methods for concrete adapters to communicate with a remote mail server and track requests and responses.

todo Implement proxy settings

 Methods

Constructor.

__construct(string $host, int $port) 

Parameters

$host

string

OPTIONAL Hostname of remote connection (default: 127.0.0.1)

$port

int

OPTIONAL Port number (default: null)

Exceptions

\Zend\Mail\Protocol\Exception\RuntimeException

Class destructor to cleanup open resources

__destruct() 

Create a connection to the remote host

connect() 

Concrete adapters for this class will implement their own unique connect scripts, using the _connect() method to create the socket resource.

Retrieve the transaction log

getLog() : string

Returns

string

Get the maximum log size

getMaximumLog() : int

Returns

intthe maximum log size

Retrieve the last client request

getRequest() : string

Returns

string

Retrieve the last server response

getResponse() : array

Returns

array

Reset the transaction log

resetLog() 

Set the maximum log size

setMaximumLog(int $maximumLog) 

Parameters

$maximumLog

int

Maximum log size

Add the transaction log

_addLog(string $value) 

Parameters

$value

string

new transaction

Connect to the server using the supplied transport and target

_connect(string $remote) : bool

An example $remote string may be 'tcp://mail.example.com:25' or 'ssh://hostname.com:2222'

Parameters

$remote

string

Remote

Exceptions

\Zend\Mail\Protocol\Exception\RuntimeException

Returns

bool

Disconnect from remote host and free resource

_disconnect() 

Parse server response for successful codes

_expect(string | array $code, int $timeout) : string

Read the response from the stream and check for expected return code. Throws a Zend\Mail\Protocol\Exception\ExceptionInterface if an unexpected code is returned.

Parameters

$code

stringarray

One or more codes that indicate a successful response

$timeout

int

Per-request timeout value if applicable

Exceptions

\Zend\Mail\Protocol\Exception\RuntimeException

Returns

stringLast line of response string

Get a line from the stream.

_receive(int $timeout) : string

Parameters

$timeout

int

Per-request timeout value if applicable

Exceptions

\Zend\Mail\Protocol\Exception\RuntimeException

Returns

string

Send the given request followed by a LINEEND to the server.

_send(string $request) : int | bool

Parameters

$request

string

Exceptions

\Zend\Mail\Protocol\Exception\RuntimeException

Returns

intboolNumber of bytes written to remote host

 Properties

 

Hostname or IP address of remote server

$host : string

 

Maximum of the transaction log

$maximumLog : int

 

Port number of connection

$port : int

 

Last request sent to server

$request : string

 

Array of server responses to last request

$response : array

 

Socket connection resource

$socket : resource

 

Instance of Zend\Validator\ValidatorChain to check hostnames

$validHost : \Zend\Validator\ValidatorChain

 

Log of mail requests and server responses for a session

$log : array

 Constants

 

Mail default EOL string

EOL 

 

Default timeout in seconds for initiating session

TIMEOUT_CONNECTION