Documentation

Swift_Message extends Swift_Mime_SimpleMessage
in package

The Message class for building emails.

Tags
author

Chris Corbyn

Table of Contents

LEVEL_ALTERNATIVE  = 4096
An entity which nests with the same precedence as a mime part
LEVEL_MIXED  = 256
An entity which nests with the same precedence as an attachment
LEVEL_RELATED  = 65536
An entity which nests with the same precedence as embedded content
LEVEL_TOP  = 16
Main message document; there can only be one of these
PRIORITY_HIGH  = 2
PRIORITY_HIGHEST  = 1
PRIORITY_LOW  = 4
PRIORITY_LOWEST  = 5
PRIORITY_NORMAL  = 3
$userCharset  : mixed
The charset last specified by the user
$userContentType  : mixed
$userDelSp  : mixed
The delsp parameter last specified by the user
$userFormat  : mixed
The format parameter last specified by the user
$alternativePartOrder  : mixed
The order in which alternative mime types should appear
$body  : mixed
The body as a string, or a stream
$bodySigners  : array<string|int, Swift_Signers_BodySigner>
$boundary  : mixed
A mime boundary, if any is used
$cache  : mixed
A KeyCache instance used during encoding and streaming
$cacheKey  : mixed
The key used for accessing the cache
$children  : mixed
All descendants of this entity
$compositeRanges  : mixed
Mime types to be used based on the nesting level
$compoundLevelFilters  : mixed
A set of filter rules to define what level an entity should be nested at
$encoder  : mixed
The encoder that encodes the body into a streamable format
$headers  : mixed
A collection of Headers for this mime entity
$headerSigners  : array<string|int, Swift_Signers_HeaderSigner>
$id  : mixed
The CID of this entity
$idGenerator  : mixed
Message ID generator
$immediateChildren  : mixed
Direct descendants of this entity
$maxLineLength  : mixed
The maximum line length of the body of this entity
$nestingLevel  : mixed
The nesting level of this entity
$savedMessage  : array<string|int, mixed>
__clone()  : mixed
Clone Message Signers.
__construct()  : mixed
Create a new Message.
__destruct()  : mixed
Empties it's own contents from the cache.
__toString()  : string
Returns a string representation of this object.
__wakeup()  : mixed
addBcc()  : $this
Add a Bcc: address to this message.
addCc()  : $this
Add a Cc: address to this message.
addFrom()  : $this
Add a From: address to this message.
addPart()  : $this
Add a MimePart to this Message.
addReplyTo()  : $this
Add a Reply-To: address to this message.
addTo()  : $this
Add a To: address to this message.
attach()  : $this
Attach a {@link Swift_Mime_SimpleMimeEntity} such as an Attachment or MimePart.
attachSigner()  : $this
Attach a new signature handler to the message.
charsetChanged()  : mixed
Receive notification that the charset of this entity, or a parent entity has changed.
clearSigners()  : $this
Clear all signature handlers attached to the message.
detach()  : $this
Remove an already attached entity.
detachSigner()  : $this
Detach a signature handler from a message.
embed()  : string
Attach a {@link Swift_Mime_SimpleMimeEntity} and return it's CID source.
encoderChanged()  : mixed
Receive notification that the encoder of this entity or a parent entity has changed.
generateId()  : string
Generate a new Content-ID or Message-ID for this MIME entity.
getBcc()  : array<string|int, mixed>
Get the Bcc addresses of this message.
getBody()  : string
Get the body of this entity as a string.
getBodyContentType()  : string
Get the Body Content-type of this entity.
getBoundary()  : string
Get the boundary used to separate children in this entity.
getCc()  : array<string|int, mixed>
Get the Cc address of this message.
getCharset()  : string
Get the character set of this entity.
getChildren()  : array<string|int, Swift_Mime_SimpleMimeEntity>
Get all children added to this entity.
getContentType()  : string
Get the Content-type of this entity.
getDate()  : DateTimeInterface
Get the date at which this message was created.
getDelSp()  : bool
Test if delsp is being used for this entity.
getDescription()  : string
Get the description of this entity.
getEncoder()  : Swift_Mime_ContentEncoder
Get the encoder used for the body of this entity.
getFormat()  : string
Get the format of this entity (i.e. flowed or fixed).
getFrom()  : mixed
Get the from address of this message.
getHeaders()  : Swift_Mime_SimpleHeaderSet
Get the {@link Swift_Mime_SimpleHeaderSet} for this entity.
getId()  : string
Get the CID of this entity.
getMaxLineLength()  : int
Get the maximum line length of the body of this entity.
getNestingLevel()  : int
Get the nesting level of this entity.
getPriority()  : int
Get the priority of this message.
getReadReceiptTo()  : string
Get the addresses to which a read-receipt will be sent.
getReplyTo()  : string
Get the reply-to address of this message.
getReturnPath()  : string
Get the return-path (bounce address) of this message.
getSender()  : string
Get the sender of this message.
getSubject()  : string
Get the subject of this message.
getTo()  : array<string|int, mixed>
Get the To addresses of this message.
setBcc()  : $this
Set the Bcc addresses of this message.
setBody()  : $this
Set the body of this entity, either as a string, or as an instance of {@link Swift_OutputByteStream}.
setBoundary()  : $this
Set the boundary used to separate children in this entity.
setCc()  : $this
Set the Cc addresses of this message.
setCharset()  : $this
Set the character set of this entity.
setChildren()  : $this
Set all children of this entity.
setContentType()  : $this
Set the Content-type of this entity.
setDate()  : $this
Set the date at which this message was created.
setDelSp()  : $this
Turn delsp on or off for this entity.
setDescription()  : $this
Set the description of this entity.
setEncoder()  : $this
Set the encoder used for the body of this entity.
setFormat()  : $this
Set the format of this entity (flowed or fixed).
setFrom()  : $this
Set the from address of this message.
setId()  : $this
Set the CID of this entity.
setMaxLineLength()  : $this
Set the maximum line length of lines in this body.
setPriority()  : $this
Set the priority of this message.
setReadReceiptTo()  : $this
Ask for a delivery receipt from the recipient to be sent to $addresses.
setReplyTo()  : $this
Set the reply-to address of this message.
setReturnPath()  : $this
Set the return-path (the bounce address) of this message.
setSender()  : $this
Set the sender of this message.
setSubject()  : $this
Set the subject of this message.
setTo()  : $this
Set the to addresses of this message.
toByteStream()  : mixed
Write this message to a {@link Swift_InputByteStream}.
toString()  : string
Get this message as a complete string.
becomeMimePart()  : mixed
Turn the body of this message into a child of itself if needed
bodyToByteStream()  : mixed
Write this entire entity to a {@link Swift_InputByteStream}.
bodyToString()  : string
Get this entire entity as a string.
clearCache()  : mixed
Empty the KeyCache for this entity.
convertString()  : mixed
Encode charset when charset is not utf-8
doSign()  : mixed
loops through signers and apply the signatures.
fixHeaders()  : mixed
Re-evaluate what content type and encoding should be used on this entity.
getCache()  : Swift_KeyCache
Get the KeyCache used in this entity.
getHeaderFieldModel()  : mixed
Get the model data (usually an array or a string) for $field.
getHeaderParameter()  : mixed
Get the parameter value of $parameter on $field header.
getIdField()  : mixed
Get the name of the header that provides the ID of this entity.
getIdGenerator()  : Swift_IdGenerator
Get the ID generator.
restoreHeaders()  : mixed
Remove or restore altered headers.
restoreMessage()  : mixed
Restore message body.
saveHeaders()  : mixed
save the original headers.
saveMessage()  : mixed
save the message before any signature is applied.
setHeaderFieldModel()  : mixed
Set the model data for $field.
setHeaderParameter()  : mixed
Set the parameter value of $parameter on $field header.
assertValidBoundary()  : mixed
createChild()  : mixed
getCompoundLevel()  : mixed
getNeededChildLevel()  : mixed
getTopNestingLevel()  : mixed
Get the highest nesting level nested inside this message
notifyCharsetChanged()  : mixed
notifyEncoderChanged()  : mixed
readStream()  : mixed
setContentTypeInHeaders()  : mixed
setEncoding()  : mixed
setNestingLevel()  : mixed
sortChildren()  : mixed

Constants

LEVEL_ALTERNATIVE

An entity which nests with the same precedence as a mime part

public mixed LEVEL_ALTERNATIVE = 4096

LEVEL_MIXED

An entity which nests with the same precedence as an attachment

public mixed LEVEL_MIXED = 256

An entity which nests with the same precedence as embedded content

public mixed LEVEL_RELATED = 65536

LEVEL_TOP

Main message document; there can only be one of these

public mixed LEVEL_TOP = 16

Properties

$userCharset

The charset last specified by the user

protected mixed $userCharset

$userDelSp

The delsp parameter last specified by the user

protected mixed $userDelSp

$userFormat

The format parameter last specified by the user

protected mixed $userFormat

$alternativePartOrder

The order in which alternative mime types should appear

private mixed $alternativePartOrder = ['text/plain' => 1, 'text/html' => 2, 'multipart/related' => 3]

$cache

A KeyCache instance used during encoding and streaming

private mixed $cache

$compositeRanges

Mime types to be used based on the nesting level

private mixed $compositeRanges = ['multipart/mixed' => [self::LEVEL_TOP, self::LEVEL_MIXED], 'multipart/alternative' => [self::LEVEL_MIXED, self::LEVEL_ALTERNATIVE], 'multipart/related' => [self::LEVEL_ALTERNATIVE, self::LEVEL_RELATED]]

$compoundLevelFilters

A set of filter rules to define what level an entity should be nested at

private mixed $compoundLevelFilters = []

$encoder

The encoder that encodes the body into a streamable format

private mixed $encoder

$headers

A collection of Headers for this mime entity

private mixed $headers

$immediateChildren

Direct descendants of this entity

private mixed $immediateChildren = []

$maxLineLength

The maximum line length of the body of this entity

private mixed $maxLineLength = 78

$nestingLevel

The nesting level of this entity

private mixed $nestingLevel = self::LEVEL_ALTERNATIVE

$savedMessage

private array<string|int, mixed> $savedMessage = []

Methods

__construct()

Create a new Message.

public __construct([string $subject = null ][, string $body = null ][, string $contentType = null ][, string $charset = null ]) : mixed

Details may be optionally passed into the constructor.

Parameters
$subject : string = null
$body : string = null
$contentType : string = null
$charset : string = null
Return values
mixed

__destruct()

Empties it's own contents from the cache.

public __destruct() : mixed
Return values
mixed

__toString()

Returns a string representation of this object.

public __toString() : string
Tags
see
toString()
Return values
string

__wakeup()

public __wakeup() : mixed
Return values
mixed

addBcc()

Add a Bcc: address to this message.

public addBcc(string $address[, string $name = null ]) : $this

If $name is passed this name will be associated with the address.

Parameters
$address : string
$name : string = null

optional

Return values
$this

addCc()

Add a Cc: address to this message.

public addCc(string $address[, string $name = null ]) : $this

If $name is passed this name will be associated with the address.

Parameters
$address : string
$name : string = null

optional

Return values
$this

addFrom()

Add a From: address to this message.

public addFrom(string $address[, string $name = null ]) : $this

If $name is passed this name will be associated with the address.

Parameters
$address : string
$name : string = null

optional

Return values
$this

addPart()

Add a MimePart to this Message.

public addPart(string|Swift_OutputByteStream $body[, string $contentType = null ][, string $charset = null ]) : $this
Parameters
$body : string|Swift_OutputByteStream
$contentType : string = null
$charset : string = null
Return values
$this

addReplyTo()

Add a Reply-To: address to this message.

public addReplyTo(string $address[, string $name = null ]) : $this

If $name is passed this name will be associated with the address.

Parameters
$address : string
$name : string = null

optional

Return values
$this

addTo()

Add a To: address to this message.

public addTo(string $address[, string $name = null ]) : $this

If $name is passed this name will be associated with the address.

Parameters
$address : string
$name : string = null

optional

Return values
$this

attachSigner()

Attach a new signature handler to the message.

public attachSigner(Swift_Signer $signer) : $this
Parameters
$signer : Swift_Signer
Return values
$this

charsetChanged()

Receive notification that the charset of this entity, or a parent entity has changed.

public charsetChanged(string $charset) : mixed
Parameters
$charset : string
Return values
mixed

clearSigners()

Clear all signature handlers attached to the message.

public clearSigners() : $this
Return values
$this

detachSigner()

Detach a signature handler from a message.

public detachSigner(Swift_Signer $signer) : $this
Parameters
$signer : Swift_Signer
Return values
$this

generateId()

Generate a new Content-ID or Message-ID for this MIME entity.

public generateId() : string
Return values
string

getBcc()

Get the Bcc addresses of this message.

public getBcc() : array<string|int, mixed>
Return values
array<string|int, mixed>

getBody()

Get the body of this entity as a string.

public getBody() : string
Return values
string

getBodyContentType()

Get the Body Content-type of this entity.

public getBodyContentType() : string
Return values
string

getBoundary()

Get the boundary used to separate children in this entity.

public getBoundary() : string
Return values
string

getCc()

Get the Cc address of this message.

public getCc() : array<string|int, mixed>
Return values
array<string|int, mixed>

getCharset()

Get the character set of this entity.

public getCharset() : string
Return values
string

getContentType()

Get the Content-type of this entity.

public getContentType() : string
Return values
string

getDate()

Get the date at which this message was created.

public getDate() : DateTimeInterface
Return values
DateTimeInterface

getDelSp()

Test if delsp is being used for this entity.

public getDelSp() : bool
Return values
bool

getDescription()

Get the description of this entity.

public getDescription() : string

This value comes from the Content-Description header if set.

Return values
string

getFormat()

Get the format of this entity (i.e. flowed or fixed).

public getFormat() : string
Return values
string

getFrom()

Get the from address of this message.

public getFrom() : mixed
Return values
mixed

getId()

Get the CID of this entity.

public getId() : string

The CID will only be present in headers if a Content-ID header is present.

Return values
string

getMaxLineLength()

Get the maximum line length of the body of this entity.

public getMaxLineLength() : int
Return values
int

getNestingLevel()

Get the nesting level of this entity.

public getNestingLevel() : int
Tags
see

LEVEL_TOP, LEVEL_MIXED, LEVEL_RELATED, LEVEL_ALTERNATIVE

Return values
int

getPriority()

Get the priority of this message.

public getPriority() : int

The returned value is an integer where 1 is the highest priority and 5 is the lowest.

Return values
int

getReadReceiptTo()

Get the addresses to which a read-receipt will be sent.

public getReadReceiptTo() : string
Return values
string

getReplyTo()

Get the reply-to address of this message.

public getReplyTo() : string
Return values
string

getReturnPath()

Get the return-path (bounce address) of this message.

public getReturnPath() : string
Return values
string

getSender()

Get the sender of this message.

public getSender() : string
Return values
string

getSubject()

Get the subject of this message.

public getSubject() : string
Return values
string

getTo()

Get the To addresses of this message.

public getTo() : array<string|int, mixed>
Return values
array<string|int, mixed>

setBcc()

Set the Bcc addresses of this message.

public setBcc(mixed $addresses[, string $name = null ]) : $this

If $name is passed and the first parameter is a string, this name will be associated with the address.

Parameters
$addresses : mixed
$name : string = null

optional

Return values
$this

setBody()

Set the body of this entity, either as a string, or as an instance of {@link Swift_OutputByteStream}.

public setBody(mixed $body[, string $contentType = null ]) : $this
Parameters
$body : mixed
$contentType : string = null

optional

Return values
$this

setBoundary()

Set the boundary used to separate children in this entity.

public setBoundary(string $boundary) : $this
Parameters
$boundary : string
Tags
throws
Swift_RfcComplianceException
Return values
$this

setCc()

Set the Cc addresses of this message.

public setCc(mixed $addresses[, string $name = null ]) : $this

If $name is passed and the first parameter is a string, this name will be associated with the address.

Parameters
$addresses : mixed
$name : string = null

optional

Return values
$this

setCharset()

Set the character set of this entity.

public setCharset(string $charset) : $this
Parameters
$charset : string
Return values
$this

setContentType()

Set the Content-type of this entity.

public setContentType(string $type) : $this
Parameters
$type : string
Return values
$this

setDate()

Set the date at which this message was created.

public setDate(DateTimeInterface $dateTime) : $this
Parameters
$dateTime : DateTimeInterface
Return values
$this

setDelSp()

Turn delsp on or off for this entity.

public setDelSp([bool $delsp = true ]) : $this
Parameters
$delsp : bool = true
Return values
$this

setDescription()

Set the description of this entity.

public setDescription(string $description) : $this

This method sets a value in the Content-ID header.

Parameters
$description : string
Return values
$this

setFormat()

Set the format of this entity (flowed or fixed).

public setFormat(string $format) : $this
Parameters
$format : string
Return values
$this

setFrom()

Set the from address of this message.

public setFrom(string|array<string|int, mixed> $addresses[, string $name = null ]) : $this

You may pass an array of addresses if this message is from multiple people.

If $name is passed and the first parameter is a string, this name will be associated with the address.

Parameters
$addresses : string|array<string|int, mixed>
$name : string = null

optional

Return values
$this

setId()

Set the CID of this entity.

public setId(string $id) : $this
Parameters
$id : string
Return values
$this

setMaxLineLength()

Set the maximum line length of lines in this body.

public setMaxLineLength(int $length) : $this

Though not enforced by the library, lines should not exceed 1000 chars.

Parameters
$length : int
Return values
$this

setPriority()

Set the priority of this message.

public setPriority(int $priority) : $this

The value is an integer where 1 is the highest priority and 5 is the lowest.

Parameters
$priority : int
Return values
$this

setReadReceiptTo()

Ask for a delivery receipt from the recipient to be sent to $addresses.

public setReadReceiptTo(array<string|int, mixed> $addresses) : $this
Parameters
$addresses : array<string|int, mixed>
Return values
$this

setReplyTo()

Set the reply-to address of this message.

public setReplyTo(mixed $addresses[, string $name = null ]) : $this

You may pass an array of addresses if replies will go to multiple people.

If $name is passed and the first parameter is a string, this name will be associated with the address.

Parameters
$addresses : mixed
$name : string = null

optional

Return values
$this

setReturnPath()

Set the return-path (the bounce address) of this message.

public setReturnPath(string $address) : $this
Parameters
$address : string
Return values
$this

setSender()

Set the sender of this message.

public setSender(string $address[, string $name = null ]) : $this

This does not override the From field, but it has a higher significance.

Parameters
$address : string
$name : string = null

optional

Return values
$this

setSubject()

Set the subject of this message.

public setSubject(string $subject) : $this
Parameters
$subject : string
Return values
$this

setTo()

Set the to addresses of this message.

public setTo(mixed $addresses[, string $name = null ]) : $this

If multiple recipients will receive the message an array should be used. Example: array('receiver@domain.org', 'other@domain.org' => 'A name')

If $name is passed and the first parameter is a string, this name will be associated with the address.

Parameters
$addresses : mixed
$name : string = null

optional

Return values
$this

toString()

Get this message as a complete string.

public toString() : string
Return values
string

becomeMimePart()

Turn the body of this message into a child of itself if needed

protected becomeMimePart() : mixed
Return values
mixed

bodyToString()

Get this entire entity as a string.

protected bodyToString() : string
Return values
string

clearCache()

Empty the KeyCache for this entity.

protected clearCache() : mixed
Return values
mixed

convertString()

Encode charset when charset is not utf-8

protected convertString(mixed $string) : mixed
Parameters
$string : mixed
Return values
mixed

doSign()

loops through signers and apply the signatures.

protected doSign() : mixed
Return values
mixed

fixHeaders()

Re-evaluate what content type and encoding should be used on this entity.

protected fixHeaders() : mixed
Return values
mixed

getHeaderFieldModel()

Get the model data (usually an array or a string) for $field.

protected getHeaderFieldModel(mixed $field) : mixed
Parameters
$field : mixed
Return values
mixed

getHeaderParameter()

Get the parameter value of $parameter on $field header.

protected getHeaderParameter(mixed $field, mixed $parameter) : mixed
Parameters
$field : mixed
$parameter : mixed
Return values
mixed

getIdField()

Get the name of the header that provides the ID of this entity.

protected getIdField() : mixed
Return values
mixed

restoreHeaders()

Remove or restore altered headers.

protected restoreHeaders() : mixed
Return values
mixed

restoreMessage()

Restore message body.

protected restoreMessage() : mixed
Return values
mixed

saveHeaders()

save the original headers.

protected saveHeaders(array<string|int, mixed> $altered) : mixed
Parameters
$altered : array<string|int, mixed>
Return values
mixed

saveMessage()

save the message before any signature is applied.

protected saveMessage() : mixed
Return values
mixed

setHeaderFieldModel()

Set the model data for $field.

protected setHeaderFieldModel(mixed $field, mixed $model) : mixed
Parameters
$field : mixed
$model : mixed
Return values
mixed

setHeaderParameter()

Set the parameter value of $parameter on $field header.

protected setHeaderParameter(mixed $field, mixed $parameter, mixed $value) : mixed
Parameters
$field : mixed
$parameter : mixed
$value : mixed
Return values
mixed

assertValidBoundary()

private assertValidBoundary(mixed $boundary) : mixed
Parameters
$boundary : mixed
Return values
mixed

getCompoundLevel()

private getCompoundLevel(mixed $children) : mixed
Parameters
$children : mixed
Return values
mixed

getNeededChildLevel()

private getNeededChildLevel(mixed $child, mixed $compoundLevel) : mixed
Parameters
$child : mixed
$compoundLevel : mixed
Return values
mixed

getTopNestingLevel()

Get the highest nesting level nested inside this message

private getTopNestingLevel() : mixed
Return values
mixed

notifyCharsetChanged()

private notifyCharsetChanged(mixed $charset) : mixed
Parameters
$charset : mixed
Return values
mixed

setContentTypeInHeaders()

private setContentTypeInHeaders(mixed $type) : mixed
Parameters
$type : mixed
Return values
mixed

setEncoding()

private setEncoding(mixed $encoding) : mixed
Parameters
$encoding : mixed
Return values
mixed

setNestingLevel()

private setNestingLevel(mixed $level) : mixed
Parameters
$level : mixed
Return values
mixed

Search results