SMTP implementation of Zend\Mail\Protocol\AbstractProtocol

Minimum implementation according to RFC2821: EHLO, MAIL FROM, RCPT TO, DATA, RSET, NOOP, QUIT

package Default
inherited_from \Zend\Mail\Protocol\AbstractProtocol

 Methods

Constructor.

__construct(string|array $host = '127.0.0.1', null|integer $port = null, null|array $config = null

The first argument may be an array of all options. If so, it must include the 'host' and 'port' keys in order to ensure that all required values are present.

inherited_from \Zend\Mail\Protocol\AbstractProtocol::__construct()

Parameters

$host

stringarray

$port

nullinteger

$config

nullarray

Exceptions

\Zend\Mail\Protocol\Exception\InvalidArgumentException

Constructor.

__construct(string $host = '127.0.0.1', integer $port = null
Inherited

Parameters

$host

string

OPTIONAL Hostname of remote connection (default: 127.0.0.1)

$port

integer

OPTIONAL Port number (default: null)

Exceptions

\Zend\Mail\Protocol\Exception\RuntimeException

Class destructor to cleanup open resources

__destruct() 
Inherited

Default authentication method

auth() 

This default method is implemented by AUTH adapters to properly authenticate to a remote host.

Exceptions

\Zend\Mail\Protocol\Exception\RuntimeException

Connect to the server with the parameters given in the constructor.

connect() : boolean

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

inherited_from \Zend\Mail\Protocol\AbstractProtocol::connect()

Returns

boolean

Create a connection to the remote host

connect() 
Inherited

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

Issues DATA command

data(string $data) 

Parameters

$data

string

Exceptions

\Zend\Mail\Protocol\Exception\RuntimeException

Closes connection

disconnect() 

Retrieve the transaction log

getLog() : string
Inherited

Returns

string

Get the maximum log size

getMaximumLog() : integer
Inherited

Returns

integerthe maximum log size

Retrieve the last client request

getRequest() : string
Inherited

Returns

string

Retrieve the last server response

getResponse() : array
Inherited

Returns

array

Returns the perceived session status

hasSession() : boolean

Returns

boolean

Initiate HELO/EHLO sequence and set flag to indicate valid smtp session

helo(string $host = '127.0.0.1'

Parameters

$host

string

The client hostname or IP address (default: 127.0.0.1)

Exceptions

\Zend\Mail\Protocol\Exception\RuntimeException

Issues MAIL command

mail(string $from) 

Parameters

$from

string

Sender mailbox

Exceptions

\Zend\Mail\Protocol\Exception\RuntimeException

Issues the NOOP command end validates answer

noop() 

Not used by Zend\Mail, could be used to keep a connection alive or check if it is still open.

Issues the QUIT command and clears the current session

quit() 

Issues RCPT command

rcpt(string $to) 

Parameters

$to

string

Receiver(s) mailbox

Exceptions

\Zend\Mail\Protocol\Exception\RuntimeException

Reset the transaction log

resetLog() 
Inherited

Issues the RSET command end validates answer

rset() 

Can be used to restore a clean smtp communication state when a transaction has been cancelled or commencing a new transaction.

Set the maximum log size

setMaximumLog(integer $maximumLog) 
Inherited

Parameters

$maximumLog

integer

Maximum log size

Issues the VRFY command end validates answer

vrfy(string $user) 

Not used by Zend\Mail.

Parameters

$user

string

User Name or eMail to verify

Add the transaction log

_addLog(string $value) 
Inherited

Parameters

$value

string

new transaction

Connect to the server using the supplied transport and target

_connect(string $remote) : boolean
Inherited

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

boolean

Disconnect from remote host and free resource

_disconnect() 
inherited_from \Zend\Mail\Protocol\AbstractProtocol::_disconnect()

Disconnect from remote host and free resource

_disconnect() 
Inherited

Send EHLO or HELO depending on capabilities of smtp host

_ehlo(string $host) 

Parameters

$host

string

The client hostname or IP address (default: 127.0.0.1)

Exceptions

\Exception\Zend\Mail\Protocol\Exception\ExceptionInterface

Parse server response for successful codes

_expect(string|array $code, integer $timeout = null) : string
Inherited

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

integer

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(integer $timeout = null) : string
Inherited

Parameters

$timeout

integer

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) : integer | boolean
Inherited

Parameters

$request

string

Exceptions

\Zend\Mail\Protocol\Exception\RuntimeException

Returns

integerbooleanNumber of bytes written to remote host

Start mail session

_startSession() 

Stop mail session

_stopSession() 

 Properties

 

Indicates an smtp AUTH has been issued and authenticated

$auth : boolean

Default

false
 

Indicates that DATA has been issued and sent

$data : boolean

Default

null
 

Hostname or IP address of remote server

$host : string

Default

 

Indicates a MAIL command has been issued

$mail : boolean

Default

false
 

Maximum of the transaction log

$maximumLog : integer

Default

64
 

Port number of connection

$port : integer

Default

 

Indicates one or more RCTP commands have been issued

$rcpt : boolean

Default

false
 

Last request sent to server

$request : string

Default

 

Array of server responses to last request

$response : array

Default

 

Indicates that a session is requested to be secure

$secure : string

Default

 

Indicates an smtp session has been started by the HELO command

$sess : boolean

Default

false
 

Socket connection resource

$socket : resource

Default

 

The transport method for the socket

$transport : string

Default

'tcp'
 

Instance of Zend\Validator\ValidatorChain to check hostnames

$validHost : \Zend\Validator\ValidatorChain

Default

 

Log of mail requests and server responses for a session

$log : array

Default

array()

 Constants

 

Mail default EOL string

EOL = "\r\n" 
 

Default timeout in seconds for initiating session

TIMEOUT_CONNECTION = 30