SMTP implementation of Zend\Mail\Protocol\AbstractProtocol

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

 Methods

Constructor.

__construct(string | array $host, null | int $port, array $config) 

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.

Parameters

$host

stringarray

$port

nullint

$config

nullarray

Exceptions

\Zend\Mail\Protocol\Exception\InvalidArgumentException

Class destructor to cleanup open resources

__destruct() 
Inherited

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

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() : bool

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

Returns

bool

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

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

Returns

string

Get the maximum log size

getMaximumLog() : int
Inherited

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

Returns

intthe maximum log size

Retrieve the last client request

getRequest() : string
Inherited

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

Returns

string

Retrieve the last server response

getResponse() : array
Inherited

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

Returns

array

Returns the perceived session status

hasSession() : bool

Returns

bool

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

helo(string $host) 

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

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

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(int $maximumLog) 
Inherited

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

Parameters

$maximumLog

int

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

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

Parameters

$value

string

new transaction

Connect to the server using the supplied transport and target

_connect(string $remote) : bool
Inherited

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

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

Parameters

$remote

string

Remote

Exceptions

\Zend\Mail\Protocol\Exception\RuntimeException

Returns

bool

Disconnect from remote host and free resource

_disconnect() 

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, int $timeout) : 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.

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

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
Inherited

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

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
Inherited

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

Parameters

$request

string

Exceptions

\Zend\Mail\Protocol\Exception\RuntimeException

Returns

intboolNumber 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 : bool

 

Indicates that DATA has been issued and sent

$data : bool

 

Hostname or IP address of remote server

$host : string
Inherited

inherited_from \Zend\Mail\Protocol\AbstractProtocol::$$host
 

Indicates a MAIL command has been issued

$mail : bool

 

Maximum of the transaction log

$maximumLog : int
Inherited

inherited_from \Zend\Mail\Protocol\AbstractProtocol::$$maximumLog
 

Port number of connection

$port : int
Inherited

inherited_from \Zend\Mail\Protocol\AbstractProtocol::$$port
 

Indicates one or more RCTP commands have been issued

$rcpt : bool

 

Last request sent to server

$request : string
Inherited

inherited_from \Zend\Mail\Protocol\AbstractProtocol::$$request
 

Array of server responses to last request

$response : array
Inherited

inherited_from \Zend\Mail\Protocol\AbstractProtocol::$$response
 

Indicates that a session is requested to be secure

$secure : string

 

Indicates an smtp session has been started by the HELO command

$sess : bool

 

Socket connection resource

$socket : resource
Inherited

inherited_from \Zend\Mail\Protocol\AbstractProtocol::$$socket
 

The transport method for the socket

$transport : string

 

Instance of Zend\Validator\ValidatorChain to check hostnames

$validHost : \Zend\Validator\ValidatorChain
Inherited

inherited_from \Zend\Mail\Protocol\AbstractProtocol::$$validHost
 

Log of mail requests and server responses for a session

$log : array
Inherited

inherited_from \Zend\Mail\Protocol\AbstractProtocol::$$log

 Constants

 

Mail default EOL string

EOL 
Inherited

inherited_from \Zend\Mail\Protocol\AbstractProtocol::EOL
 

Default timeout in seconds for initiating session

TIMEOUT_CONNECTION 
Inherited

inherited_from \Zend\Mail\Protocol\AbstractProtocol::TIMEOUT_CONNECTION