function calculate_references - calculate correct References string Adds the current message ID, and makes sure it doesn't grow forever, to that extent it drops message-ID's in a smart way until the string length is under the recommended value of 1000 ("References: <986>\r\n").
It always keeps the first and the last three ID's.
function clean_crlf - change linefeeds and newlines to legal characters
The SMTP format only allows CRLF as line terminators. This function replaces illegal teminators with the correct terminator.
void
clean_crlf
(string &$s)
-
string
&$s: string to clean linefeeds on
Fold header lines per RFC 2822/2.2.3 and RFC 822/3.1.1
Herein "soft" folding/wrapping (with whitespace tokens) is what we refer to as the preferred method of wrapping - that which we'd like to do within the $soft_wrap limit, but if not possible, we will try to do as soon as possible after $soft_wrap up to the $hard_wrap limit. Encoded words don't need to be detected in this phase, since they cannot contain spaces.
"Hard" folding/wrapping (with "hard" tokens) is what we refer to as less ideal wrapping that will be done to keep within the $hard_wrap limit. This adds other syntactical breaking elements such as commas and encoded words.
string
foldLine
(string $header, [integer $soft_wrap = 78], [string $indent = ''], [string $hard_wrap = 998])
-
string
$header: The header content being folded
-
integer
$soft_wrap: The desirable maximum line length (OPTIONAL; default is 78, per RFC)
-
string
$indent: Wrapped lines will already have whitespace following the CRLF wrap, but you can add more indentation (or whatever) with this. The use of this parameter is DISCOURAGED, since it can corrupt the redisplay (unfolding) of headers whose content is space- sensitive, like subjects, etc. (OPTIONAL; default is an empty string)
-
string
$hard_wrap: The absolute maximum line length (OPTIONAL; default is 998, per RFC)
function getBCC - reserved for extended functionality
This function is not yet implemented. Reserved for extended functionality.
void
getBCC
()
function initStream - reserved for extended functionality
This function is not yet implemented. Reserved for extended functionality. UPDATE: It is implemented in Deliver_SMTP and Deliver_SendMail classes, but it remains unimplemented in this base class (and thus not in Deliver_IMAP or other child classes that don't define it)
NOTE: some parameters are specific to the child class that is implementing this method
handle
initStream
(
Message $message,
string $domain, [
integer $length =
0], [
string $host =
''], [
integer $port =
''], [
string $user =
''], [
string $pass =
''], [
boolean $authpop =
false], [
string $pop_host =
''], [
array $stream_options =
array()])
-
Message
$message: Message object
-
string
$domain
-
integer
$length
-
string
$host: host name or IP to connect to
-
integer
$port
-
string
$user: username to log into the SMTP server with
-
string
$pass: password to log into the SMTP server with
-
boolean
$authpop: whether or not to use POP-before-SMTP authorization
-
string
$pop_host: host name or IP to connect to for POP-before-SMTP authorization
-
array
$stream_options: Stream context options, see config_local.example.php for more details (OPTIONAL)
Redefined in descendants as:
Converts ip address to hexadecimal string
Function is used to convert ipv4 and ipv6 addresses to hex strings. It removes all delimiter symbols from ip addresses, converts decimal ipv4 numbers to hex and pads strings in order to present full length address. ipv4 addresses are represented as 8 byte strings, ipv6 addresses are represented as 32 byte string.
If function fails to detect address format, it returns unprocessed string.
string
ip2hex
(string $string)
-
string
$string: ip address string
function mail - send the message parts to the SMTP stream
integer
mail
(
&$message, [
resource $stream =
false], [
string $reply_id =
0], [
string $reply_ent_id =
0], [
resource $imap_stream =
NULL], [
mixed $extra =
NULL],
Message $message)
-
Message
$message: Message object to send NOTE that this is passed by reference and will be modified upon return with updated fields such as Message ID, References, In-Reply-To and Date headers.
-
resource
$stream: Handle to the outgoing stream (when FALSE, nothing will be written to the stream; this can be used to determine the actual number of bytes that will be written to the stream)
-
string
$reply_id: Identifies message being replied to (OPTIONAL; caller should ONLY specify a value for this when the message being sent is a reply)
-
string
$reply_ent_id: Identifies message being replied to in the case it was an embedded/attached message inside another (OPTIONAL; caller should ONLY specify a value for this when the message being sent is a reply)
-
resource
$imap_stream: If there is an open IMAP stream in the caller's context, it should be passed in here. This is OPTIONAL, as one will be created if not given, but as some IMAP servers may baulk at opening more than one connection at a time, the caller should always abide if possible. Currently, this stream is only used when $reply_id is also non-zero, but that is subject to change.
-
mixed
$extra: Any implementation-specific variables can be passed in here and used in an overloaded version of this method if needed.
-
&$message
function mimeBoundary - calculates the mime boundary to use
This function will generate a random mime boundary base part for the message if the boundary has not already been set.
string
mimeBoundary
()
function prepareMIME_Header - creates the mime header
string
prepareMIME_Header
(
Message $message,
string $boundary)
-
Message
$message: Message object to act on
-
string
$boundary: mime boundary from fn MimeBoundary
function prepareRFC822_Header - prepares the RFC822 header string from Rfc822Header object(s)
This function takes the Rfc822Header object(s) and formats them into the RFC822Header string to send to the SMTP server as part of the SMTP message.
string
prepareRFC822_Header
(
&$rfc822_header,
Rfc822Header $reply_rfc822_header,
integer &$raw_length,
Rfc822Header $rfc822_header)
-
Rfc822Header
$rfc822_header
-
Rfc822Header
$reply_rfc822_header
-
integer
&$raw_length: length of the message
-
&$rfc822_header
function preWriteToStream - reserved for extended functionality
This function is not yet implemented. Reserved for extended functionality.
void
preWriteToStream
(string &$s)
-
string
&$s: string to operate on
Redefined in descendants as:
function send_mail - send the message parts to the IMAP stream
void
send_mail
(
Message $message,
string $header,
string $boundary, [
resource $stream =
false],
int &$raw_length, [
mixed $extra =
NULL])
-
Message
$message: Message object to send
-
string
$header: Headers ready to send
-
string
$boundary: Message parts boundary
-
resource
$stream: Handle to the SMTP stream (when FALSE, nothing will be written to the stream; this can be used to determine the actual number of bytes that will be written to the stream)
-
int
&$raw_length: The number of bytes written (or that would have been written) to the output stream - NOTE that this is passed by reference
-
mixed
$extra: Any implementation-specific variables can be passed in here and used in an overloaded version of this method if needed.
Redefined in descendants as:
function strip_crlf - strip linefeeds and newlines from a string
The SMTP format only allows CRLF as line terminators. This function strips all line terminators from the string.
void
strip_crlf
(string &$s)
-
string
&$s: string to clean linefeeds on
function timezone - Time offset for correct timezone
string
timezone
()
function writeBody - generate and write the mime boundaries around each part to the stream
Recursively formats and writes the MIME boundaries of the $message to the output stream.
void
writeBody
(
Message $message,
resource $stream,
integer &$length_raw, [
string $boundary =
''])
-
Message
$message: Message object to transform
-
resource
$stream: SMTP output stream (when FALSE, nothing will be written to the stream; this can be used to determine the actual number of bytes that will be written to the stream)
-
integer
&$length_raw: raw length of the message (part) as returned by mail fn
-
string
$boundary: custom boundary to call, usually for subparts
function writeBodyPart - write each individual mimepart
Recursively called by WriteBody to write each mime part to the SMTP stream
void
writeBodyPart
(
Message $message,
resource $stream,
integer &$length)
-
Message
$message: Message object to transform
-
resource
$stream: SMTP output stream (when FALSE, nothing will be written to the stream; this can be used to determine the actual number of bytes that will be written to the stream)
-
integer
&$length: length of the message part as returned by mail fn
function writeToStream - write data to the SMTP stream
void
writeToStream
(resource $stream, string $data)
-
resource
$stream: SMTP output stream
-
string
$data: string with data to send to the SMTP stream