Constants

ERROR_CREATE

ERROR_CREATE

ERROR_CONNECT

ERROR_CONNECT

ERROR_AUTH

ERROR_AUTH

ERROR_FROM

ERROR_FROM

ERROR_SENDER

ERROR_SENDER

ERROR_RECIPIENT

ERROR_RECIPIENT

ERROR_DATA

ERROR_DATA

Properties

$sep

$sep : string

Line terminator used for separating header lines.

Type

string

$greeting

$greeting : string

The SMTP greeting.

Type

string

$queuedAs

$queuedAs : string

The SMTP queued response.

Type

string

$eai

$eai : boolean

Does the transport driver support EAI (RFC 6532) headers? (@since 2.5.0)

Type

boolean

$_params

$_params : array

Configuration parameters.

Type

array

$_smtp

$_smtp : \Net_SMTP

SMTP connection object.

Type

\Net_SMTP

$_extparams

$_extparams : array

The list of service extension parameters to pass to the Net_SMTP mailFrom() command.

Type

array

Methods

__get()

__get(  $name) 

Parameters

$name

send()

send(mixed  $recipients, array  $headers, mixed  $body) 

Send a message.

Parameters

mixed $recipients

Either a comma-seperated list of recipients (RFC822 compliant), or an array of recipients, each RFC822 valid. This may contain recipients not specified in the headers, for Bcc:, resending messages, etc.

array $headers

The headers to send with the mail, in an associative array, where the array key is the header name (ie, 'Subject'), and the array value is the header value (ie, 'test'). The header produced from those values would be 'Subject: test'. If the '_raw' key exists, the value of this key will be used as the exact text for sending the message.

mixed $body

The full text of the message body, including any Mime parts, etc. Either a string or a stream resource.

prepareHeaders()

prepareHeaders(array  $headers) : mixed

Take an array of mail headers and return a string containing text usable in sending a message.

Parameters

array $headers

The array of headers to prepare, in an associative array, where the array key is the header name (ie, 'Subject'), and the array value is the header value (ie, 'test'). The header produced from those values would be 'Subject: test'. If the '_raw' key exists, the value of this key will be used as the exact text for sending the message.

Throws

\Horde_Mail_Exception

Returns

mixed —

Returns false if it encounters a bad address; otherwise returns an array containing two elements: Any From: address found in the headers, and the plain text version of the headers.

parseRecipients()

parseRecipients(mixed  $recipients) : array

Take a set of recipients and parse them, returning an array of bare addresses (forward paths) that can be passed to sendmail or an SMTP server with the 'RCPT TO:' command.

Parameters

mixed $recipients

Either a comma-separated list of recipients (RFC822 compliant), or an array of recipients, each RFC822 valid.

Throws

\Horde_Mail_Exception

Returns

array —

Forward paths (bare addresses, IDN encoded).

__construct()

__construct(array  $params = array()) 

Constructor.

Parameters

array $params

Additional parameters:

  • auth: (mixed) SMTP authentication. This value may be set to true, false or the name of a specific authentication method. If the value is set to true, the Net_SMTP package will attempt to use the best authentication method advertised by the remote SMTP server. DEFAULT: false.
  • debug: (boolean) Activate SMTP debug mode? DEFAULT: false
  • host: (string) The server to connect to. DEFAULT: localhost
  • localhost: (string) Hostname or domain that will be sent to the remote SMTP server in the HELO / EHLO message. DEFAULT: localhost
  • password: (string) The password to use for SMTP auth. DEFAULT: NONE
  • persist: (boolean) Should the SMTP connection persist? DEFAULT: false
  • pipelining: (boolean) Use SMTP command pipelining. Use SMTP command pipelining (specified in RFC 2920) if the SMTP server supports it. This speeds up delivery over high-latency connections. DEFAULT: false (use default value from Net_SMTP)
  • port: (integer) The port to connect to. DEFAULT: 25
  • timeout: (integer) The SMTP connection timeout. DEFAULT: NONE
  • username: (string) The username to use for SMTP auth. DEFAULT: NONE

getSMTPObject()

getSMTPObject() : \Net_SMTP

Connect to the SMTP server by instantiating a Net_SMTP object.

Throws

\Horde_Mail_Exception

Returns

\Net_SMTP —

The SMTP object.

addServiceExtensionParameter()

addServiceExtensionParameter(string  $keyword, string  $value = null) 

Add parameter associated with a SMTP service extension.

Parameters

string $keyword

Extension keyword.

string $value

Any value the keyword needs.

disconnect()

disconnect() : boolean

Disconnect and destroy the current SMTP connection.

Returns

boolean —

True if the SMTP connection no longer exists.

_sanitizeHeaders()

_sanitizeHeaders(array  $headers) : array

Sanitize an array of mail headers by removing any additional header strings present in a legitimate header's value. The goal of this filter is to prevent mail injection attacks.

Raw headers are sent as-is.

Parameters

array $headers

The associative array of headers to sanitize.

Returns

array —

The sanitized headers.

_normalizeEOL()

_normalizeEOL(string  $data) : string

Normalizes EOLs in string data.

Parameters

string $data

Data.

Returns

string —

Normalized data.

_getFrom()

_getFrom(string  $from, array  $headers) : string

Get the from address.

Parameters

string $from

From address.

array $headers

Headers array.

Throws

\Horde_Mail_Exception

Returns

string —

Address object.

_error()

_error(string  $text, \PEAR_Error  $error, integer  $e_code) 

Build a standardized string describing the current SMTP error.

Parameters

string $text

Custom string describing the error context.

\PEAR_Error $error

PEAR_Error object.

integer $e_code

Error code.

Throws

\Horde_Mail_Exception