Documentation

Message extends AbstractMessage
in package

Message class

Tags
category

Pop

author

Nick Sagona, III dev@nolainteractive.com

copyright

Copyright (c) 2009-2024 NOLA Interactive, LLC. (http://www.nolainteractive.com)

license

http://www.popphp.org/license New BSD License

version
4.0.0

Table of Contents

Constants

CRLF  = "\r\n"
Message newline constant

Properties

$addresses  : array<string|int, mixed>
Message addresses
$boundary  : string|null
Message boundary
$charSet  : string|null
Character set
$contentType  : string|null
Content type
$headers  : array<string|int, mixed>
Headers
$id  : string|null
Message or part ID
$idHeader  : string|null
Message or part ID header name
$parts  : array<string|int, mixed>
Message parts

Methods

__clone()  : void
Perform a "deep" clone of a message object
__construct()  : mixed
Constructor
__toString()  : string
Render message to string
addHeader()  : AbstractMessage
Add message part header
addHeaders()  : AbstractMessage
Add message part headers
addHtml()  : Message
Add HTML message part
addPart()  : Message
Add message part
addText()  : Message
Add text message part
attachFile()  : Message
Attach file message part
attachFileFromStream()  : Message
Attach file message part from stream
decodeText()  : string
Decode text
generateBoundary()  : Message
Generate message MIME boundary
generateId()  : string
Generate a new ID
getBcc()  : array<string|int, mixed>
Get BCC
getBody()  : string|null
Get message body
getBoundary()  : string
Get message MIME boundary
getCc()  : array<string|int, mixed>
Get CC
getCharSet()  : string|null
Get message part character set
getContentType()  : string|null
Get message part content type
getFrom()  : array<string|int, mixed>
Get From
getHeader()  : string|null
Get message part header
getHeaderAsString()  : string|null
Get header as string
getHeaders()  : array<string|int, mixed>
Get all message part headers
getHeadersAsString()  : string
Get all message headers as string
getId()  : string|null
Get the ID
getIdHeader()  : string|null
Get the ID
getPart()  : PartInterface|null
Get message part
getParts()  : array<string|int, mixed>
Get message parts
getReplyTo()  : array<string|int, mixed>
Get Reply-To
getReturnPath()  : array<string|int, mixed>
Get Return-Path
getSender()  : array<string|int, mixed>
Get Sender
getSubject()  : string|null
Get subject
getTo()  : array<string|int, mixed>
Get To
hasAttachments()  : bool
Has attachments
hasBcc()  : bool
Has BCC
hasCc()  : bool
Has CC
hasFrom()  : bool
Has From
hasHeader()  : bool
Determine if message part has header
hasReplyTo()  : bool
Has Reply-To
hasReturnPath()  : bool
Has Return-Path
hasSender()  : bool
Has Sender
hasTo()  : bool
Has To
load()  : Message
Load a message from a string source or file on disk
parse()  : Message
Parse message from string
parseAddresses()  : string|array<string|int, mixed>
Parse addresses
parseFromFile()  : Message
Parse message from file
parseNameAndEmail()  : array<string|int, mixed>
Parse a name and email from an address string
removeHeader()  : Message
Remove header
render()  : string
Render message
renderAsLines()  : array<string|int, mixed>
Render as an array of lines
save()  : void
Save message to file on disk
setBcc()  : AbstractMessage
Set BCC
setBody()  : Message
Set body
setBoundary()  : Message
Set message MIME boundary
setCc()  : AbstractMessage
Set CC
setCharSet()  : AbstractMessage
Set message part character set
setContentType()  : AbstractMessage
Set message part content type
setFrom()  : AbstractMessage
Set From
setId()  : AbstractMessage
Set the ID
setIdHeader()  : AbstractMessage
Set the ID header name
setReplyTo()  : AbstractMessage
Set Reply-To
setReturnPath()  : AbstractMessage
Set Return-Path
setSender()  : AbstractMessage
Set Sender
setSubject()  : AbstractMessage
Set Subject
setTo()  : AbstractMessage
Set To
toByteStream()  : void
Write this entire entity to a buffer
getRandomId()  : string
Returns a random ID
validateContentType()  : void
Validate content type based on message parts added to the message

Constants

CRLF

Message newline constant

public string CRLF = "\r\n"

Properties

$addresses

Message addresses

protected array<string|int, mixed> $addresses = ['To' => [], 'CC' => [], 'BCC' => [], 'From' => [], 'Reply-To' => [], 'Sender' => [], 'Return-Path' => []]

$boundary

Message boundary

protected string|null $boundary = null

$idHeader

Message or part ID header name

protected string|null $idHeader = null

$parts

Message parts

protected array<string|int, mixed> $parts = []

Methods

__clone()

Perform a "deep" clone of a message object

public __clone() : void

__construct()

Constructor

public __construct([string|null $subject = null ]) : mixed

Instantiate the message object

Parameters
$subject : string|null = null

__toString()

Render message to string

public __toString() : string
Return values
string

addHtml()

Add HTML message part

public addHtml(mixed $html) : Message
Parameters
$html : mixed
Return values
Message

addText()

Add text message part

public addText(mixed $text) : Message
Parameters
$text : mixed
Return values
Message

attachFile()

Attach file message part

public attachFile(string $file[, string $encoding = AbstractPart::BASE64 ]) : Message
Parameters
$file : string
$encoding : string = AbstractPart::BASE64
Return values
Message

attachFileFromStream()

Attach file message part from stream

public attachFileFromStream(string $stream[, string $basename = 'file.tmp' ][, string $encoding = AbstractPart::BASE64 ]) : Message
Parameters
$stream : string
$basename : string = 'file.tmp'
$encoding : string = AbstractPart::BASE64
Return values
Message

decodeText()

Decode text

public static decodeText(string $text) : string
Parameters
$text : string
Return values
string

generateBoundary()

Generate message MIME boundary

public generateBoundary() : Message
Return values
Message

generateId()

Generate a new ID

public generateId([string|null $domain = null ]) : string
Parameters
$domain : string|null = null
Tags
string

?string $domain

Return values
string

getBcc()

Get BCC

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

getBody()

Get message body

public getBody() : string|null
Return values
string|null

getBoundary()

Get message MIME boundary

public getBoundary() : string
Return values
string

getCc()

Get CC

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

getCharSet()

Get message part character set

public getCharSet() : string|null
Return values
string|null

getContentType()

Get message part content type

public getContentType() : string|null
Return values
string|null

getFrom()

Get From

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

getHeader()

Get message part header

public getHeader(string $header) : string|null
Parameters
$header : string
Return values
string|null

getHeaderAsString()

Get header as string

public getHeaderAsString(string $header) : string|null
Parameters
$header : string
Return values
string|null

getHeaders()

Get all message part headers

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

getHeadersAsString()

Get all message headers as string

public getHeadersAsString([array<string|int, mixed> $omitHeaders = [] ]) : string
Parameters
$omitHeaders : array<string|int, mixed> = []
Return values
string

getId()

Get the ID

public getId() : string|null
Return values
string|null

getIdHeader()

Get the ID

public getIdHeader() : string|null
Return values
string|null

getParts()

Get message parts

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

getReplyTo()

Get Reply-To

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

getReturnPath()

Get Return-Path

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

getSender()

Get Sender

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

getSubject()

Get subject

public getSubject() : string|null
Return values
string|null

getTo()

Get To

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

hasAttachments()

Has attachments

public hasAttachments() : bool
Return values
bool

hasBcc()

Has BCC

public hasBcc() : bool
Return values
bool

hasCc()

Has CC

public hasCc() : bool
Return values
bool

hasFrom()

Has From

public hasFrom() : bool
Return values
bool

hasHeader()

Determine if message part has header

public hasHeader(string $header) : bool
Parameters
$header : string
Return values
bool

hasReplyTo()

Has Reply-To

public hasReplyTo() : bool
Return values
bool

hasReturnPath()

Has Return-Path

public hasReturnPath() : bool
Return values
bool

hasSender()

Has Sender

public hasSender() : bool
Return values
bool

hasTo()

Has To

public hasTo() : bool
Return values
bool

load()

Load a message from a string source or file on disk

public static load(string $message) : Message
Parameters
$message : string
Tags
throws
Exception
Return values
Message

parse()

Parse message from string

public static parse(string $stream) : Message
Parameters
$stream : string
Tags
throws
Exception
Return values
Message

parseAddresses()

Parse addresses

public parseAddresses(mixed $addresses[, bool $asArray = false ]) : string|array<string|int, mixed>
Parameters
$addresses : mixed
$asArray : bool = false
Return values
string|array<string|int, mixed>

parseFromFile()

Parse message from file

public static parseFromFile(string $file) : Message
Parameters
$file : string
Tags
throws
Exception
Return values
Message

parseNameAndEmail()

Parse a name and email from an address string

public parseNameAndEmail(string $address) : array<string|int, mixed>
Parameters
$address : string
Return values
array<string|int, mixed>

removeHeader()

Remove header

public removeHeader(string $header) : Message
Parameters
$header : string
Return values
Message

render()

Render message

public render([array<string|int, mixed> $omitHeaders = [] ]) : string
Parameters
$omitHeaders : array<string|int, mixed> = []
Return values
string

renderAsLines()

Render as an array of lines

public renderAsLines([array<string|int, mixed> $omitHeaders = [] ]) : array<string|int, mixed>
Parameters
$omitHeaders : array<string|int, mixed> = []
Return values
array<string|int, mixed>

save()

Save message to file on disk

public save(string $to[, array<string|int, mixed> $omitHeaders = [] ]) : void
Parameters
$to : string
$omitHeaders : array<string|int, mixed> = []

setBoundary()

Set message MIME boundary

public setBoundary(string $boundary) : Message
Parameters
$boundary : string
Return values
Message

toByteStream()

Write this entire entity to a buffer

public toByteStream(BufferInterface $is[, array<string|int, mixed> $omitHeaders = [] ]) : void
Parameters
$is : BufferInterface
$omitHeaders : array<string|int, mixed> = []

getRandomId()

Returns a random ID

protected getRandomId([string|null $idRight = null ]) : string
Parameters
$idRight : string|null = null
Tags
string

?string $idRight

Return values
string

validateContentType()

Validate content type based on message parts added to the message

protected validateContentType() : void

        
On this page

Search results