Documentation

Horde_Mail_Transport_Smtp extends Horde_Mail_Transport
in package

SMTP implementation.

Tags
author

Chuck Hagenbuch chuck@horde.org

author

Jon Parise jon@php.net

author

Michael Slusarz slusarz@horde.org

category

Horde

copyright

2010-2016 Horde LLC

deprecated

Use Horde_Mail_Transport_Hordesmtp instead

license

http://www.horde.org/licenses/bsd New BSD License

Table of Contents

ERROR_AUTH  = 10002
ERROR_CONNECT  = 10001
ERROR_CREATE  = 10000
ERROR_DATA  = 10006
ERROR_FROM  = 10003
ERROR_RECIPIENT  = 10005
ERROR_SENDER  = 10004
$eai  : bool
$greeting  : string
The SMTP greeting.
$queuedAs  : string
The SMTP queued response.
$sep  : string
Line terminator used for separating header lines.
$_extparams  : array<string|int, mixed>
The list of service extension parameters to pass to the Net_SMTP mailFrom() command.
$_params  : array<string|int, mixed>
Configuration parameters.
$_smtp  : Net_SMTP
SMTP connection object.
__construct()  : mixed
Constructor.
__get()  : mixed
addServiceExtensionParameter()  : mixed
Add parameter associated with a SMTP service extension.
disconnect()  : bool
Disconnect and destroy the current SMTP connection.
getSMTPObject()  : Net_SMTP
Connect to the SMTP server by instantiating a Net_SMTP object.
parseRecipients()  : array<string|int, mixed>
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.
prepareHeaders()  : mixed
Take an array of mail headers and return a string containing text usable in sending a message.
send()  : mixed
Send a message.
_error()  : mixed
Build a standardized string describing the current SMTP error.
_getFrom()  : string
Get the from address.
_normalizeEOL()  : string
Normalizes EOLs in string data.
_sanitizeHeaders()  : array<string|int, mixed>
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.

Constants

ERROR_AUTH

public mixed ERROR_AUTH = 10002

ERROR_CONNECT

public mixed ERROR_CONNECT = 10001

ERROR_CREATE

public mixed ERROR_CREATE = 10000

ERROR_DATA

public mixed ERROR_DATA = 10006

ERROR_FROM

public mixed ERROR_FROM = 10003

ERROR_RECIPIENT

public mixed ERROR_RECIPIENT = 10005

ERROR_SENDER

public mixed ERROR_SENDER = 10004

Properties

$eai read-only

public bool $eai

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

$greeting

The SMTP greeting.

public string $greeting = \null

$queuedAs

The SMTP queued response.

public string $queuedAs = \null

$sep

Line terminator used for separating header lines.

public string $sep = \PHP_EOL

$_extparams

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

protected array<string|int, mixed> $_extparams = array()

$_params

Configuration parameters.

protected array<string|int, mixed> $_params = array()

$_smtp

SMTP connection object.

protected Net_SMTP $_smtp = \null

Methods

__construct()

Constructor.

public __construct([array<string|int, mixed> $params = array() ]) : mixed
Parameters
$params : array<string|int, mixed> = array()

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
Return values
mixed

__get()

public __get(mixed $name) : mixed
Parameters
$name : mixed
Return values
mixed

addServiceExtensionParameter()

Add parameter associated with a SMTP service extension.

public addServiceExtensionParameter(string $keyword[, string $value = null ]) : mixed
Parameters
$keyword : string

Extension keyword.

$value : string = null

Any value the keyword needs.

Return values
mixed

disconnect()

Disconnect and destroy the current SMTP connection.

public disconnect() : bool
Return values
bool

True if the SMTP connection no longer exists.

getSMTPObject()

Connect to the SMTP server by instantiating a Net_SMTP object.

public getSMTPObject() : Net_SMTP
Tags
throws
Horde_Mail_Exception
Return values
Net_SMTP

The SMTP object.

parseRecipients()

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.

public parseRecipients(mixed $recipients) : array<string|int, mixed>
Parameters
$recipients : mixed

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

Tags
throws
Horde_Mail_Exception
Return values
array<string|int, mixed>

Forward paths (bare addresses, IDN encoded).

prepareHeaders()

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

public prepareHeaders(array<string|int, mixed> $headers) : mixed
Parameters
$headers : array<string|int, mixed>

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.

Tags
throws
Horde_Mail_Exception
Return values
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.

send()

Send a message.

public send(mixed $recipients, array<string|int, mixed> $headers, mixed $body) : mixed
Parameters
$recipients : mixed

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.

$headers : array<string|int, mixed>

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.

$body : mixed

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

Return values
mixed

_error()

Build a standardized string describing the current SMTP error.

protected _error(string $text, PEAR_Error $error, int $e_code) : mixed
Parameters
$text : string

Custom string describing the error context.

$error : PEAR_Error

PEAR_Error object.

$e_code : int

Error code.

Tags
throws
Horde_Mail_Exception
Return values
mixed

_getFrom()

Get the from address.

protected _getFrom(string $from, array<string|int, mixed> $headers) : string
Parameters
$from : string

From address.

$headers : array<string|int, mixed>

Headers array.

Tags
throws
Horde_Mail_Exception
Return values
string

Address object.

_normalizeEOL()

Normalizes EOLs in string data.

protected _normalizeEOL(string $data) : string
Parameters
$data : string

Data.

Return values
string

Normalized data.

_sanitizeHeaders()

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.

protected _sanitizeHeaders(array<string|int, mixed> $headers) : array<string|int, mixed>

Raw headers are sent as-is.

Parameters
$headers : array<string|int, mixed>

The associative array of headers to sanitize.

Return values
array<string|int, mixed>

The sanitized headers.

Search results