\Horde_Mail_Transport_Smtpmx

SMTP MX implementation.

Summary

Methods
Properties
Constants
__get()
send()
prepareHeaders()
parseRecipients()
__construct()
__destruct()
$sep
$eai
No constants found
_sanitizeHeaders()
_normalizeEOL()
_getFrom()
_getMx()
_loadNetDns()
_error()
$_params
$_smtp
$_resolver
$_errorCode
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

$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

$_resolver

$_resolver : \Net_DNS2_Resolver

Net_DNS2_Resolver object.

Type

\Net_DNS2_Resolver

$_errorCode

$_errorCode : array

Internal error codes.

Translate internal error identifier to human readable messages.

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

Parameters

array $params

Additional options:

  • debug: (boolean) Activate SMTP debug mode? DEFAULT: false
  • mailname: (string) The name of the local mail system (a valid hostname which matches the reverse lookup) DEFAULT: Auto-determined
  • netdns: (boolean) Use PEAR:Net_DNS2 (true) or the PHP builtin getmxrr(). DEFAULT: true
  • port: (integer) Port. DEFAULT: Auto-determined
  • test: (boolean) Activate test mode? DEFAULT: false
  • timeout: (integer) The SMTP connection timeout (in seconds). DEFAULT: 10
  • verp: (boolean) Whether to use VERP. If not a boolean, the string value will be used as the VERP separators. DEFAULT: false
  • vrfy: (boolean) Whether to use VRFY. DEFAULT: false

__destruct()

__destruct() 

Destructor implementation to ensure that we disconnect from any potentially-alive persistent SMTP connections.

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

_getMx()

_getMx(string  $host) : mixed

Recieve MX records for a host.

Parameters

string $host

Mail host.

Returns

mixed —

Sorted MX list or false on error.

_loadNetDns()

_loadNetDns() 

Initialize Net_DNS2_Resolver.

_error()

_error(string  $id, array  $info = array()) 

Format error message.

Parameters

string $id

Maps error ids to codes and message.

array $info

Optional information in associative array.

Throws

\Horde_Mail_Exception