\Horde_Mail_Transport_Smtphorde

SMTP implementation using Horde_Smtp.

Summary

Methods
Properties
Constants
__get()
send()
prepareHeaders()
parseRecipients()
__construct()
getSMTPObject()
$sep
$send8bit
$eai
No constants found
_sanitizeHeaders()
_normalizeEOL()
_getFrom()
$_params
$_smtp
N/A
No private methods found
No private properties found
N/A

Properties

$sep

$sep : string

Line terminator used for separating header lines.

Type

string

$send8bit

$send8bit : 

Type

$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 : \Horde_Smtp

SMTP object.

Type

\Horde_Smtp

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:

  • chunk_size: (integer) If CHUNKING is supported on the server, the chunk size (in octets) to send. 0 will disable chunking. @since Horde_Smtp 1.7.0
  • context: (array) Any context parameters passed to stream_create_context(). @since Horde_Smtp 1.9.0
  • debug: (string) If set, will output debug information to the stream provided. The value can be any PHP supported wrapper that can be opened via fopen(). DEFAULT: No debug output
  • host: (string) The SMTP server. DEFAULT: localhost
  • localhost: (string) The hostname of the localhost. (since Horde_Smtp 1.9.0) DEFAULT: Auto-determined.
  • password: (string) The SMTP password. DEFAULT: NONE
  • port: (string) The SMTP port. DEFAULT: 587
  • secure: (string) Use SSL or TLS to connect. DEFAULT: true (use 'tls' option, if available)
    • false (No encryption)
    • 'ssl' (Auto-detect SSL version)
    • 'sslv2' (Force SSL version 2)
    • 'sslv3' (Force SSL version 3)
    • 'tls' (TLS; started via protocol-level negotation over unencrypted channel; RECOMMENDED way of initiating secure connection)
    • 'tlsv1' (TLS direct version 1.x connection to server) [@since Horde_Smtp .3.0]
    • true (Use TLS, if available) [@since Horde_Smtp 1.2.0] DEFAULT: No encryption
  • timeout: (integer) Connection timeout, in seconds. DEFAULT: 30 seconds
  • username: (string) The SMTP username. DEFAULT: NONE
  • xoauth2_token: (string) If set, will authenticate via the XOAUTH2 mechanism (if available) with this token. Either a string or a Horde_Smtp_Password object (since Horde_Smtp 1.1.0).

getSMTPObject()

getSMTPObject() : \Horde_Smtp

Connect to the SMTP server by instantiating a Horde_Smtp object.

Throws

\Horde_Mail_Exception

Returns

\Horde_Smtp —

The SMTP object.

_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.